mastodon_async_entities/
relationship.rs

1//! module containing everything relating to a relationship with
2//! another account.
3
4use std::fmt::Display;
5
6use serde::{Deserialize, Serialize};
7
8/// A struct containing information about a relationship with another account.
9#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
10pub struct Relationship {
11    /// Target account id
12    pub id: RelationshipId,
13    /// Whether the application client follows the account.
14    pub following: bool,
15    /// Whether the account follows the application client.
16    pub followed_by: bool,
17    /// Whether the application client blocks the account.
18    pub blocking: bool,
19    /// Whether the application client blocks the account.
20    pub muting: bool,
21    /// Whether the application client has requested to follow the account.
22    pub requested: bool,
23    /// Whether the user is also muting notifications
24    pub muting_notifications: bool,
25    /// Whether the user is currently blocking the accounts's domain
26    pub domain_blocking: bool,
27    /// Whether the user's reblogs will show up in the home timeline
28    pub showing_reblogs: bool,
29    /// Whether the user is currently endorsing the account
30    ///
31    /// This field is not techincally nullable with mastodon >= 2.5.0, but
32    /// making it `Option<bool>` here means we shouldn't get deser errors when
33    /// making calls to pleroma or mastodon<2.5.0 instances
34    pub endorsed: Option<bool>,
35}
36
37/// Wrapper type for a relationship ID string
38#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
39#[serde(transparent)]
40pub struct RelationshipId(String);
41
42impl AsRef<str> for RelationshipId {
43    fn as_ref(&self) -> &str {
44        &self.0
45    }
46}
47
48impl RelationshipId {
49    pub fn new(value: impl Into<String>) -> Self {
50        Self(value.into())
51    }
52}
53impl Display for RelationshipId {
54    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
55        write!(f, "{}", self.0)
56    }
57}
58
59static_assertions::assert_not_impl_any!(
60    RelationshipId: PartialEq<crate::account::AccountId>,
61    PartialEq<crate::attachment::AttachmentId>,
62    PartialEq<crate::filter::FilterId>,
63    PartialEq<crate::push::SubscriptionId>,
64    PartialEq<crate::mention::MentionId>,
65    PartialEq<crate::notification::NotificationId>,
66    PartialEq<crate::list::ListId>,
67    PartialEq<crate::report::ReportId>,
68    PartialEq<crate::status::StatusId>,
69);