AlertService
class AlertService
Traits
Trait aggregating all channel notification traits.
Trait for sending Mail notifications.
Trait for sending Telegram notifications.
Trait for sending Discord notifications.
Methods
Send an alert notification via Email.
Send an alert notification via Telegram.
Send an alert notification via Discord.
Flatten a multidimensional array of alert details into a single-level array.
Send an alert to configured recipients based on type.
Check if the current environment is allowed to send alerts.
Check if an alert is currently in cooldown for a specific recipient.
Log that an alert was skipped due to cooldown.
Dispatch the alert to the specific channel.
Record the alert attempt in the database.
Log the alert attempt result.
Details
in
MailNotification at line 23
void
mailAlert(AlertRecipient|object $recipient, string $type, string $message, array<string,mixed> $details = [], string|null $subject = null)
Send an alert notification via Email.
in
TelegramNotification at line 25
void
telegramAlert(AlertRecipient|object $recipient, string $type, string $message, array<string,mixed> $details = [], string|null $subject = null)
Send an alert notification via Telegram.
in
DiscordNotification at line 22
void
discordAlert(AlertRecipient|object $recipient, string $type, string $message, array<string,mixed> $details = [], string|null $subject = null)
Send an alert notification via Discord.
in
AllChannelsTraits at line 29
array
flattenAlertDetails(array $details)
Flatten a multidimensional array of alert details into a single-level array.
Nested keys are concatenated with dots (e.g., 'parent.child').
at line 30
void
send(string $type, string $message, array $details = [], array $options = [])
Send an alert to configured recipients based on type.
This method retrieves active recipients for the given alert type, checks for cooldowns, and dispatches alerts via supported channels (Mail, Telegram, Discord). It also handles logging and database recording of the alert attempt.
at line 87
protected bool
isEnvironmentAllowed()
Check if the current environment is allowed to send alerts.
at line 102
protected bool
isInCooldown(string $type, string $address, string $channel, string $message, int $cooldown)
Check if an alert is currently in cooldown for a specific recipient.
at line 129
protected void
logCooldownSkip(AlertRecipient $recipient, string $type, string $message, array<string,mixed> $details, string $subject, array<int,array<string,string>> $logRecipients, int $cooldown)
Log that an alert was skipped due to cooldown.
at line 157
protected void
sendAlertViaChannel(AlertRecipient $recipient, string $type, string $message, array $details, string $subject)
Dispatch the alert to the specific channel.
at line 175
void
handleDB(bool $success, array $info)
Record the alert attempt in the database.
at line 203
void
handleLog(bool $success, array $info)
Log the alert attempt result.