feat: require an api key to schedule

This commit is contained in:
2026-06-08 15:54:05 +01:00
parent a0bff2beb1
commit 458b7897dd
5 changed files with 53 additions and 3 deletions
+13
View File
@@ -61,3 +61,16 @@ function error_out(string $message, int $status = 400): never
{
json_out(['error' => $message], $status);
}
/**
* Aborts with 400 if no Clickatell API key has been configured.
*/
function require_api_key(): void
{
$stmt = db()->prepare("SELECT setting_value FROM `system` WHERE setting_name = 'clickatell_api_key'");
$stmt->execute();
$key = $stmt->fetchColumn();
if ($key === false || trim((string) $key) === '') {
error_out('No Clickatell API key is configured. Set one in Admin → Clickatell Settings before sending or scheduling messages.', 400);
}
}