File: //usr/local/mailchannels/hooks/PostAccountsUnSuspend.php
<?php
namespace MailChannels;
class PostAccountsUnSuspend extends PostAccountsCreate {
public function execute($hookData) {
if ($this->inboundEnabled()) {
if (isset($hookData['data']) && isset($hookData['data']['args']) && isset($hookData['data']['args']['user'])) {
$isAutoProtectionEnabled = $this->inboundConfig->isAutomaticDomainProtectionEnabled();
if ($isAutoProtectionEnabled) {
try {
$user = $hookData['data']['args']['user'];
$account = $this->inboundSmtpService->getWHMAccount($user);
$domain = $account->getDomain();
return $this->inboundProvision($domain);
} catch (\Exception $e) {
$errorMessage = $e->getTraceAsString();
return array(false, "unexpected error un-suspending the account for $user: $errorMessage");
}
}
$strIsAutoProtectionEnabled = var_export($isAutoProtectionEnabled, true);
$message = "no action taken; automaticDomainProtectionEnabled: $strIsAutoProtectionEnabled";
return array(true, $message);
}
return array(false, "could not find the user in the hook data");
}
return array(true, "action not taken; inbound not enabled");
}
public static function category() {
return 'Whostmgr';
}
public static function event() {
return 'Accounts::unsuspendacct';
}
public static function stage() {
return 'post';
}
}