diff options
author | D. Scott Boggs <scott@tams.tech> | 2023-01-29 10:37:16 -0500 |
---|---|---|
committer | D. Scott Boggs <scott@tams.tech> | 2023-01-29 10:38:37 -0500 |
commit | e881c94170d374b44bf29c543d511d796a71cfeb (patch) | |
tree | 7ffba519cd1f52f681e749d8040acbd3bfcca906 | |
parent | 9d436d622850e148ba13e5c3d6ddedb6c85a1cb9 (diff) |
Add entity for dealing with domain blocks
-rw-r--r-- | entities/src/admin/domain.rs | 55 | ||||
-rw-r--r-- | entities/src/admin/domain_allow.rs | 18 | ||||
-rw-r--r-- | entities/src/admin/mod.rs | 2 | ||||
-rw-r--r-- | entities/src/ids.rs | 2 |
4 files changed, 57 insertions, 20 deletions
diff --git a/entities/src/admin/domain.rs b/entities/src/admin/domain.rs new file mode 100644 index 0000000..f809e73 --- /dev/null +++ b/entities/src/admin/domain.rs @@ -0,0 +1,55 @@ +use serde::{Deserialize, Serialize}; +use time::{serde::iso8601, OffsetDateTime}; + +use crate::DomainId; + +/// Represents a domain allowed to federate. +/// +/// See also [the API documentation](https://docs.joinmastodon.org/entities/Admin_DomainAllow/) +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct Allow { + /// The ID of the DomainAllow in the database. + pub id: DomainId, + /// The domain that is allowed to federate. + pub domain: String, + /// When the domain was allowed to federate. + #[serde(with = "iso8601")] + pub created_at: OffsetDateTime, +} + +/// Represents a domain limited from federating. +/// +/// See also [the API documentation](https://docs.joinmastodon.org/entities/Admin_DomainBlock/) +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct Block { + /// The ID of the DomainBlock in the database. + pub id: DomainId, + /// The domain that is not allowed to federate. + pub domain: String, + /// When the domain was blocked from federating. + #[serde(with = "iso8601")] + pub created_at: OffsetDateTime, + /// The policy to be applied by this domain block. + pub severity: BlockSeverity, + /// Whether to reject media attachments from this domain + pub reject_media: bool, + /// Whether to reject reports from this domain + pub reject_reports: bool, + /// A private comment + pub private_comment: Option<String>, + /// A public comment + pub public_comment: Option<String>, + /// Whether to obfuscate public displays of this domain block + pub obfuscate: bool, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum BlockSeverity { + /// Account statuses from this domain will be hidden by default + Silence, + /// All incoming data from this domain will be rejected + Suspend, + /// Do nothing. Allows for rejecting media or reports + Noop, +} diff --git a/entities/src/admin/domain_allow.rs b/entities/src/admin/domain_allow.rs deleted file mode 100644 index 3e600a8..0000000 --- a/entities/src/admin/domain_allow.rs +++ /dev/null @@ -1,18 +0,0 @@ -use serde::{Deserialize, Serialize}; -use time::{serde::iso8601, OffsetDateTime}; - -use crate::AllowedDomainId; - -/// Represents a domain allowed to federate. -/// -/// See also [the API documentation](https://docs.joinmastodon.org/entities/Admin_DomainAllow/) -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub struct DomainAllow { - /// The ID of the DomainAllow in the database. - pub id: AllowedDomainId, - /// The domain that is allowed to federate. - pub domain: String, - /// When the domain was allowed to federate. - #[serde(with = "iso8601")] - pub created_at: OffsetDateTime, -} diff --git a/entities/src/admin/mod.rs b/entities/src/admin/mod.rs index 025e5ad..a338fb0 100644 --- a/entities/src/admin/mod.rs +++ b/entities/src/admin/mod.rs @@ -2,7 +2,7 @@ pub mod account; pub mod canonical_email_block; pub mod cohort; pub mod dimension; -pub mod domain_allow; +pub mod domain; pub use account::*; pub use canonical_email_block::*; diff --git a/entities/src/ids.rs b/entities/src/ids.rs index 372b38a..814cdc2 100644 --- a/entities/src/ids.rs +++ b/entities/src/ids.rs @@ -51,5 +51,5 @@ define_ids!( CanonicalEmailBlockId, DimensionKey, DimensionDataKey, - AllowedDomainId, + DomainId, ); |