mastodon_async_entities/
push.rs1use std::fmt::Display;
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
7pub struct Alerts {
8 pub follow: Option<bool>,
10 pub favourite: Option<bool>,
12 pub reblog: Option<bool>,
14 pub mention: Option<bool>,
16}
17
18#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
20pub struct Subscription {
21 pub id: SubscriptionId,
23 pub endpoint: String,
25 pub server_key: String,
27 pub alerts: Option<Alerts>,
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
33#[serde(transparent)]
34pub struct SubscriptionId(String);
35
36impl AsRef<str> for SubscriptionId {
37 fn as_ref(&self) -> &str {
38 &self.0
39 }
40}
41
42impl SubscriptionId {
43 pub fn new(value: impl Into<String>) -> Self {
44 Self(value.into())
45 }
46}
47
48impl Display for SubscriptionId {
49 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
50 write!(f, "{}", self.0)
51 }
52}
53
54static_assertions::assert_not_impl_any!(
55 SubscriptionId: PartialEq<crate::account::AccountId>,
56 PartialEq<crate::attachment::AttachmentId>,
57 PartialEq<crate::filter::FilterId>,
58 PartialEq<crate::mention::MentionId>,
59 PartialEq<crate::notification::NotificationId>,
60 PartialEq<crate::relationship::RelationshipId>,
61 PartialEq<crate::report::ReportId>,
62 PartialEq<crate::status::StatusId>,
63);
64
65pub mod add_subscription {
66 use serde::Serialize;
67
68 use super::Alerts;
69
70 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
71 pub struct Form {
72 pub subscription: Subscription,
73 pub data: Option<Data>,
74 }
75
76 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
77 pub struct Subscription {
78 pub endpoint: String,
79 pub keys: Keys,
80 }
81
82 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
83 pub struct Keys {
84 pub p256dh: String,
85 pub auth: String,
86 }
87
88 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
89 pub struct Data {
90 pub alerts: Option<Alerts>,
91 }
92}
93
94pub mod update_data {
95 use serde::Serialize;
96
97 use super::Alerts;
98
99 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
100 pub struct Data {
101 pub alerts: Option<Alerts>,
102 }
103
104 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
105 pub struct Form {
106 pub id: String,
107 pub data: Data,
108 }
109}