Allow multiple Pushover users

This commit is contained in:
darcy (iris system) 2021-09-02 12:47:15 +12:00
parent bb7cf80704
commit b8374a27d9
2 changed files with 40 additions and 36 deletions

View File

@ -17,13 +17,17 @@ final class ApplicationAlerters {
list($user, $tilde, $message) = $params; list($user, $tilde, $message) = $params;
$application = new Pushover\Application($_ENV[IX_ENVBASE . '_PUSHOVER_API_TOKEN']); $application = new Pushover\Application($_ENV[IX_ENVBASE . '_PUSHOVER_API_TOKEN']);
$recipient = new Pushover\Recipient($_ENV[IX_ENVBASE . '_PUSHOVER_USER_KEY']);
$pushovermessage = new PushoverMessage( $pushovermessage = new PushoverMessage(
"from {$user}@{$tilde}\n> {$message}", "from {$user}@{$tilde}\n> {$message}",
'new neotel application', 'new neotel application',
); );
$pushoverusers = explode(',', $_ENV[IX_ENVBASE . '_PUSHOVER_USER_KEYS']);
foreach ($pushoverusers as $userkey) {
$recipient = new Pushover\Recipient($userkey);
$notification = new PushoverNotification($application, $recipient, $pushovermessage); $notification = new PushoverNotification($application, $recipient, $pushovermessage);
$response = $notification->push(); $response = $notification->push();
}
return [$user, $tilde, $message]; return [$user, $tilde, $message];
} }

View File

@ -44,7 +44,7 @@ class Configuration {
// Pushover application and user keys // Pushover application and user keys
$dotenv->required(IX_ENVBASE . '_PUSHOVER_API_TOKEN')->notEmpty(); $dotenv->required(IX_ENVBASE . '_PUSHOVER_API_TOKEN')->notEmpty();
$dotenv->required(IX_ENVBASE . '_PUSHOVER_USER_KEY')->notEmpty(); $dotenv->required(IX_ENVBASE . '_PUSHOVER_USER_KEYS')->notEmpty();
// Discord webhook URL // Discord webhook URL
$dotenv->required(IX_ENVBASE . '_DISCORD_WEBHOOK_URL')->notEmpty(); $dotenv->required(IX_ENVBASE . '_DISCORD_WEBHOOK_URL')->notEmpty();