2022-11-29 23:50:29 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2023-01-02 11:34:09 +00:00
|
|
|
use time::{serde::iso8601, OffsetDateTime};
|
2022-11-29 23:50:29 +00:00
|
|
|
|
2022-11-27 14:44:43 +00:00
|
|
|
/// Represents a single Filter
|
2022-12-27 18:07:49 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
2022-11-27 14:44:43 +00:00
|
|
|
pub struct Filter {
|
|
|
|
|
id: String,
|
|
|
|
|
phrase: String,
|
|
|
|
|
context: Vec<FilterContext>,
|
2023-01-02 11:34:09 +00:00
|
|
|
#[serde(with = "iso8601::option")]
|
|
|
|
|
expires_at: Option<OffsetDateTime>,
|
2022-11-27 14:44:43 +00:00
|
|
|
irreversible: bool,
|
|
|
|
|
whole_word: bool,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Represents the various types of Filter contexts
|
2022-12-27 18:05:52 +00:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
2022-11-27 14:44:43 +00:00
|
|
|
pub enum FilterContext {
|
|
|
|
|
/// Represents the "home" context
|
|
|
|
|
#[serde(rename = "home")]
|
|
|
|
|
Home,
|
|
|
|
|
/// Represents the "notifications" context
|
|
|
|
|
#[serde(rename = "notifications")]
|
|
|
|
|
Notifications,
|
|
|
|
|
/// Represents the "public" context
|
|
|
|
|
#[serde(rename = "public")]
|
|
|
|
|
Public,
|
|
|
|
|
/// Represents the "thread" context
|
|
|
|
|
#[serde(rename = "thread")]
|
|
|
|
|
Thread,
|
|
|
|
|
}
|