Skip to content

Commit e100f0e

Browse files
committed
updated the activation handling so that when there is an error it will send a chat notification message with some of the info about the package and error.
1 parent 19de671 commit e100f0e

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/Plugin.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,16 @@ public static function getActivate(GenericEvent $event)
5252
myadmin_log(self::$module, 'info', 'cPanel Activation', __LINE__, __FILE__, self::$module, $serviceClass->getId());
5353
function_requirements('activate_cpanel');
5454
$response = activate_cpanel($serviceClass->getIp(), $event['field1']);
55-
$serviceClass
56-
->setKey($response['licenseid'])
57-
->save();
55+
if ($response === false || !is_array($response) || empty($response['licenseid'])) {
56+
$event['success'] = false;
57+
$errText = is_array($response) ? json_encode($response) : var_export($response, true);
58+
myadmin_log(self::$module, 'error', 'cPanel activate_cpanel failed for IP '.$serviceClass->getIp().' Response: '.$errText, __LINE__, __FILE__, self::$module, $serviceClass->getId());
59+
chatNotify('Failed [License '.$serviceClass->getId().'](https://my.interserver.net/admin/view_service?id='.$serviceClass->getId().'&module=licenses) cPanel Activation IP:'.$serviceClass->getIp().' Type:'.$event['field1'].' - '.$errText, 'notifications');
60+
} else {
61+
$serviceClass
62+
->setKey($response['licenseid'])
63+
->save();
64+
}
5865
$event->stopPropagation();
5966
}
6067
}

0 commit comments

Comments
 (0)