Skip to content

Commit

Permalink
MMA-8008 Error and warning with Plesk v18.0.50 (#60)
Browse files Browse the repository at this point in the history
* Fix get-domain-list status check

* Update domain/exists response check to avoid warnings

* Show an error when addAlias fails
  • Loading branch information
dbistriceanu authored Mar 20, 2023
1 parent 589ffcd commit 55bb6d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plib/library/Plesk/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getCustomerDomains($resellerId)

$response = $this->xmlapi($request);

if ("ok" == $response->customer->{"get-domain-list"}->{result}->{status}) {
if ("ok" == $response->customer->{"get-domain-list"}->result->status) {
foreach ($response->customer->children() as $customerDomains) {
foreach ($customerDomains->result->domains as $domain) {
foreach ($domain->children() as $item) {
Expand Down
3 changes: 2 additions & 1 deletion plib/library/SpamFilter/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public function checkDomain($domain)

try {
$response = $this->call("/api/domain/exists/domain/$domain");
$result = (1 == json_decode($response, true)['present']);
$decoded_response = json_decode($response, true);
$result = $decoded_response && 1 === $decoded_response['present'];
} catch (Exception $e) {
$response = "Error: " . $e->getMessage() . " | Code: " . $e->getCode();
$result = false;
Expand Down
9 changes: 9 additions & 0 deletions plib/library/SpamFilter/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ public function protectAlias($updateDns = true)
$this->pleskDomain->getDomain()
);

if (!$domainAddOk) {
throw new \RuntimeException(
sprintf(
"Failed to add the domain '%s' as an alias into the spamfilter",
htmlentities($this->pleskDomain->getDomain(), ENT_QUOTES, 'UTF-8')
)
);
}

if ($domainAddOk && !empty($spamfilterMx)) {
$this->dns->replaceDomainsMxRecords($this->pleskDomain, $spamfilterMx);
}
Expand Down

0 comments on commit 55bb6d8

Please sign in to comment.