autopulse_service/settings/webhooks/
mod.rs

1/// Discord - Discord Webhook
2///
3/// Sends a message to a Discord Webhook on events
4///
5/// # Example
6///
7/// ```yml
8/// webhooks:
9///   my_discord:
10///     type: discord
11///     url: "https://discord.com/api/webhooks/..."
12/// ```
13///
14/// or
15///
16/// ```yml
17/// webhooks:
18///   my_discord:
19///     type: discord
20///     avatar_url: "https://example.com/avatar.png"
21///     username: "autopulse"
22/// ```
23///
24/// See [`DiscordWebhook`] for all options
25pub mod discord;
26
27#[doc(hidden)]
28pub mod manager;
29
30#[doc(hidden)]
31pub use manager::*;
32
33use discord::DiscordWebhook;
34use serde::Deserialize;
35
36#[derive(Deserialize, Clone)]
37#[serde(tag = "type", rename_all = "lowercase")]
38pub enum Webhook {
39    Discord(DiscordWebhook),
40}
41
42impl Webhook {
43    pub async fn send(&self, batch: &WebhookBatch) -> anyhow::Result<()> {
44        match self {
45            Self::Discord(d) => d.send(batch, 3).await,
46        }
47    }
48}