mastodon-async/entities/src/notification.rs

40 lines
1.3 KiB
Rust
Raw Normal View History

2022-11-27 14:44:43 +00:00
//! Module containing all info about notifications.
use super::{account::Account, status::Status};
2022-12-07 20:58:28 +00:00
use serde::{Deserialize, Serialize};
use time::{serde::iso8601, OffsetDateTime};
2022-11-27 14:44:43 +00:00
/// A struct containing info about a notification.
#[allow(clippy::derive_partial_eq_without_eq)]
2022-12-07 20:58:28 +00:00
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
2022-11-27 14:44:43 +00:00
pub struct Notification {
/// The notification ID.
pub id: String,
/// The type of notification.
#[serde(rename = "type")]
pub notification_type: NotificationType,
/// The time the notification was created.
#[serde(with = "iso8601")]
pub created_at: OffsetDateTime,
2022-11-27 14:44:43 +00:00
/// The Account sending the notification to the user.
pub account: Account,
/// The Status associated with the notification, if applicable.
pub status: Option<Status>,
}
/// The type of notification.
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
2022-11-27 14:44:43 +00:00
#[serde(rename_all = "lowercase")]
pub enum NotificationType {
/// Someone mentioned the application client in another status.
Mention,
/// Someone reblogged one of the application client's statuses.
Reblog,
/// Someone favourited one of the application client's statuses.
Favourite,
/// Someone followed the application client.
Follow,
2023-01-07 15:56:09 +00:00
/// A poll the application client previously voted in has ended.
Poll,
2022-11-27 14:44:43 +00:00
}