Compare commits
3 Commits
bb7cf80704
...
6c598b172e
Author | SHA1 | Date |
---|---|---|
darcy (iris system) | 6c598b172e | |
darcy (iris system) | 66f9240c31 | |
darcy (iris system) | b8374a27d9 |
|
@ -0,0 +1,15 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
indent_style = tab
|
||||
|
||||
[*.{toml,json,yml,yaml}]
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
|
||||
[*.nix]
|
||||
indent_size = 2
|
||||
indent_style = space
|
|
@ -8,46 +8,50 @@ use Serhiy\Pushover\Api\Message\Message as PushoverMessage;
|
|||
use Serhiy\Pushover\Api\Message\Notification as PushoverNotification;
|
||||
|
||||
final class ApplicationAlerters {
|
||||
/**
|
||||
* @param string[] $key Hook key (unused)
|
||||
* @param mixed[] $params Array of [user, tilde, message]
|
||||
* @return mixed[] Array of [user, tilde, message]
|
||||
*/
|
||||
public static function pushover(array $key, array $params): array {
|
||||
list($user, $tilde, $message) = $params;
|
||||
/**
|
||||
* @param string[] $key Hook key (unused)
|
||||
* @param mixed[] $params Array of [user, tilde, message]
|
||||
* @return mixed[] Array of [user, tilde, message]
|
||||
*/
|
||||
public static function pushover(array $key, array $params): array {
|
||||
list($user, $tilde, $message) = $params;
|
||||
|
||||
$application = new Pushover\Application($_ENV[IX_ENVBASE . '_PUSHOVER_API_TOKEN']);
|
||||
$recipient = new Pushover\Recipient($_ENV[IX_ENVBASE . '_PUSHOVER_USER_KEY']);
|
||||
$pushovermessage = new PushoverMessage(
|
||||
"from {$user}@{$tilde}\n> {$message}",
|
||||
'new neotel application',
|
||||
);
|
||||
$notification = new PushoverNotification($application, $recipient, $pushovermessage);
|
||||
$response = $notification->push();
|
||||
$application = new Pushover\Application($_ENV[IX_ENVBASE . '_PUSHOVER_API_TOKEN']);
|
||||
$pushovermessage = new PushoverMessage(
|
||||
"from {$user}@{$tilde}\n> {$message}",
|
||||
'new neotel application',
|
||||
);
|
||||
|
||||
return [$user, $tilde, $message];
|
||||
}
|
||||
$pushoverusers = explode(',', $_ENV[IX_ENVBASE . '_PUSHOVER_USER_KEYS']);
|
||||
foreach ($pushoverusers as $userkey) {
|
||||
$recipient = new Pushover\Recipient($userkey);
|
||||
$notification = new PushoverNotification($application, $recipient, $pushovermessage);
|
||||
$response = $notification->push();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $key Hook key (unused)
|
||||
* @param mixed[] $params Array of [user, tilde, message]
|
||||
* @return mixed[] Array of [user, tilde, message]
|
||||
*/
|
||||
public static function discord(array $key, array $params): array {
|
||||
list($user, $tilde, $message) = $params;
|
||||
return [$user, $tilde, $message];
|
||||
}
|
||||
|
||||
$data = json_encode([
|
||||
"content" => "From `{$user}@{$tilde}` \n> {$message}",
|
||||
]);
|
||||
/**
|
||||
* @param string[] $key Hook key (unused)
|
||||
* @param mixed[] $params Array of [user, tilde, message]
|
||||
* @return mixed[] Array of [user, tilde, message]
|
||||
*/
|
||||
public static function discord(array $key, array $params): array {
|
||||
list($user, $tilde, $message) = $params;
|
||||
|
||||
$curl_opts = [
|
||||
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
|
||||
CURLOPT_POST => 1,
|
||||
CURLOPT_POSTFIELDS => $data,
|
||||
];
|
||||
$data = json_encode([
|
||||
"content" => "From `{$user}@{$tilde}` \n> {$message}",
|
||||
]);
|
||||
|
||||
$response = CurlHelpers::fetchUrl($_ENV[IX_ENVBASE . "_DISCORD_WEBHOOK_URL"], $curl_opts, true);
|
||||
$curl_opts = [
|
||||
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
|
||||
CURLOPT_POST => 1,
|
||||
CURLOPT_POSTFIELDS => $data,
|
||||
];
|
||||
|
||||
return [$user, $tilde, $message];
|
||||
}
|
||||
$response = CurlHelpers::fetchUrl($_ENV[IX_ENVBASE . "_DISCORD_WEBHOOK_URL"], $curl_opts, true);
|
||||
|
||||
return [$user, $tilde, $message];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class Configuration {
|
|||
|
||||
// Pushover application and user keys
|
||||
$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
|
||||
$dotenv->required(IX_ENVBASE . '_DISCORD_WEBHOOK_URL')->notEmpty();
|
||||
|
|
|
@ -111,6 +111,9 @@ class IndexController extends Controller {
|
|||
$form_values['message'] ?? '[no message provided]',
|
||||
]);
|
||||
|
||||
// Destroy the session
|
||||
$session->destroy();
|
||||
|
||||
// And return a success message
|
||||
$html = $this->container->get('html');
|
||||
$response->getBody()->write($html->renderDocument(
|
||||
|
|
Loading…
Reference in New Issue