One notification, every channel the user has.
Send a notification to a notifiable and it is delivered to each channel it asks for: the database (an in-app bell), mail, Discord.
What you get
- Channels: database, mail and Discord.
- A receipt records what was delivered where; a channel that failed is a
NotificationFailedevent. - Honest limit: notifications are not queued yet — queue a job that sends one.
In the docs
src/app/notifications/post_live.rs
// One notification, every channel the user can be reached on: the
// database (the in-app bell), mail, Discord.
Notify::instance().send(&author, &PostLive { post }).await?;
impl Notifiable for User {
fn notifiable_id(&self) -> String {
self.id.to_string()
}
fn notifiable_type(&self) -> &'static str {
"User"
}
fn route_for(&self, channel: &str) -> Option<String> {
match channel {
"mail" => Some(self.email.clone()),
_ => None,
}
}
}
Up close
Select an image to see it full size.