Add bridge ping endpoint

[MAILPOET-6030]
This commit is contained in:
alex-mpoet
2024-06-04 13:54:43 +03:00
committed by Aschepikov
parent 7aa006d9f7
commit a6caf0a1e6
5 changed files with 74 additions and 4 deletions

View File

@@ -290,6 +290,23 @@ class Services extends APIEndpoint {
]);
}
public function pingBridge() {
try {
$bridgePingResponse = $this->bridge->pingBridge();
} catch (\Exception $e) {
return $this->errorResponse([
APIError::UNKNOWN => $e->getMessage(),
]);
}
if (!$this->bridge->validateBridgePingResponse($bridgePingResponse)) {
$code = $bridgePingResponse ?: Bridge::CHECK_ERROR_UNKNOWN;
return $this->errorResponse([
APIError::UNKNOWN => $this->getErrorDescriptionByCode($code),
]);
}
return $this->successResponse();
}
public function refreshMSSKeyStatus() {
$key = $this->settings->get('mta.mailpoet_api_key');
return $this->checkMSSKey(['key' => $key]);