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};
|
2022-12-29 15:18:16 +00:00
|
|
|
use time::{serde::iso8601, OffsetDateTime};
|
2022-11-27 14:44:43 +00:00
|
|
|
|
|
|
|
/// A struct containing info about a notification.
|
2022-12-27 18:01:42 +00:00
|
|
|
#[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.
|
2022-12-29 15:18:16 +00:00
|
|
|
#[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.
|
2022-12-27 18:01:06 +00:00
|
|
|
#[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
|
|
|
}
|