1use core::fmt;
4use std::str::FromStr;
5
6use crate::error::{Error, Kind};
7use crate::oauth::{AppData, TokenData};
8use crate::response::Response;
9use crate::{entities, Streaming};
10use async_trait::async_trait;
11use chrono::{DateTime, Utc};
12use serde::Serialize;
13use tokio::{fs::File, io::AsyncRead};
14
15#[async_trait]
17pub trait Megalodon {
18 async fn register_app(
20 &self,
21 client_name: String,
22 options: &AppInputOptions,
23 ) -> Result<AppData, Error>;
24
25 async fn create_app(
27 &self,
28 client_name: String,
29 options: &AppInputOptions,
30 ) -> Result<AppData, Error>;
31
32 async fn fetch_access_token(
38 &self,
39 client_id: String,
40 client_secret: String,
41 code: String,
42 redirect_uri: String,
43 ) -> Result<TokenData, Error>;
44
45 async fn refresh_access_token(
48 &self,
49 client_id: String,
50 client_secret: String,
51 refresh_token: String,
52 ) -> Result<TokenData, Error>;
53
54 async fn revoke_access_token(
56 &self,
57 client_id: String,
58 client_secret: String,
59 access_token: String,
60 ) -> Result<Response<()>, Error>;
61
62 async fn verify_app_credentials(&self) -> Result<Response<entities::Application>, Error>;
67
68 async fn register_account(
73 &self,
74 username: String,
75 email: String,
76 password: String,
77 agreement: String,
78 locale: String,
79 reason: Option<String>,
80 ) -> Result<Response<entities::Token>, Error>;
81
82 async fn verify_account_credentials(&self) -> Result<Response<entities::Account>, Error>;
84
85 async fn update_credentials(
87 &self,
88 options: Option<&UpdateCredentialsInputOptions>,
89 ) -> Result<Response<entities::Account>, Error>;
90
91 async fn get_account(&self, id: String) -> Result<Response<entities::Account>, Error>;
93
94 async fn get_account_statuses(
96 &self,
97 id: String,
98 options: Option<&GetAccountStatusesInputOptions>,
99 ) -> Result<Response<Vec<entities::Status>>, Error>;
100
101 async fn get_account_favourites(
103 &self,
104 id: String,
105 options: Option<&GetAccountFavouritesInputOptions>,
106 ) -> Result<Response<Vec<entities::Status>>, Error>;
107
108 async fn subscribe_account(
110 &self,
111 id: String,
112 ) -> Result<Response<entities::Relationship>, Error>;
113
114 async fn unsubscribe_account(
116 &self,
117 id: String,
118 ) -> Result<Response<entities::Relationship>, Error>;
119
120 async fn get_account_followers(
122 &self,
123 id: String,
124 options: Option<&AccountFollowersInputOptions>,
125 ) -> Result<Response<Vec<entities::Account>>, Error>;
126
127 async fn get_account_following(
129 &self,
130 id: String,
131 options: Option<&AccountFollowersInputOptions>,
132 ) -> Result<Response<Vec<entities::Account>>, Error>;
133
134 async fn get_account_lists(&self, id: String) -> Result<Response<Vec<entities::List>>, Error>;
136
137 async fn get_identity_proofs(
139 &self,
140 id: String,
141 ) -> Result<Response<Vec<entities::IdentityProof>>, Error>;
142
143 async fn follow_account(
145 &self,
146 id: String,
147 options: Option<&FollowAccountInputOptions>,
148 ) -> Result<Response<entities::Relationship>, Error>;
149
150 async fn unfollow_account(&self, id: String)
152 -> Result<Response<entities::Relationship>, Error>;
153
154 async fn block_account(&self, id: String) -> Result<Response<entities::Relationship>, Error>;
156
157 async fn unblock_account(&self, id: String) -> Result<Response<entities::Relationship>, Error>;
159
160 async fn mute_account(
162 &self,
163 id: String,
164 notifications: bool,
165 ) -> Result<Response<entities::Relationship>, Error>;
166
167 async fn unmute_account(&self, id: String) -> Result<Response<entities::Relationship>, Error>;
169
170 async fn pin_account(&self, id: String) -> Result<Response<entities::Relationship>, Error>;
172
173 async fn unpin_account(&self, id: String) -> Result<Response<entities::Relationship>, Error>;
175
176 async fn set_account_note(
178 &self,
179 id: String,
180 note: Option<String>,
181 ) -> Result<Response<entities::Relationship>, Error>;
182
183 async fn get_relationships(
185 &self,
186 ids: Vec<String>,
187 ) -> Result<Response<Vec<entities::Relationship>>, Error>;
188
189 async fn search_account(
191 &self,
192 q: String,
193 options: Option<&SearchAccountInputOptions>,
194 ) -> Result<Response<Vec<entities::Account>>, Error>;
195
196 async fn lookup_account(&self, acct: String) -> Result<Response<entities::Account>, Error>;
198
199 async fn get_bookmarks(
204 &self,
205 options: Option<&GetBookmarksInputOptions>,
206 ) -> Result<Response<Vec<entities::Status>>, Error>;
207
208 async fn get_favourites(
213 &self,
214 options: Option<&GetFavouritesInputOptions>,
215 ) -> Result<Response<Vec<entities::Status>>, Error>;
216
217 async fn get_mutes(
222 &self,
223 options: Option<&GetMutesInputOptions>,
224 ) -> Result<Response<Vec<entities::Account>>, Error>;
225
226 async fn get_blocks(
231 &self,
232 options: Option<&GetBlocksInputOptions>,
233 ) -> Result<Response<Vec<entities::Account>>, Error>;
234
235 async fn get_domain_blocks(
240 &self,
241 options: Option<&GetDomainBlocksInputOptions>,
242 ) -> Result<Response<Vec<String>>, Error>;
243
244 async fn block_domain(&self, domain: String) -> Result<Response<()>, Error>;
246
247 async fn unblock_domain(&self, domain: String) -> Result<Response<()>, Error>;
249
250 async fn get_filters(&self) -> Result<Response<Vec<entities::Filter>>, Error>;
255
256 async fn get_filter(&self, id: String) -> Result<Response<entities::Filter>, Error>;
258
259 async fn create_filter(
261 &self,
262 phrase: String,
263 context: Vec<entities::filter::FilterContext>,
264 options: Option<&FilterInputOptions>,
265 ) -> Result<Response<entities::Filter>, Error>;
266
267 async fn update_filter(
269 &self,
270 id: String,
271 phrase: String,
272 context: Vec<entities::filter::FilterContext>,
273 options: Option<&FilterInputOptions>,
274 ) -> Result<Response<entities::Filter>, Error>;
275
276 async fn delete_filter(&self, id: String) -> Result<Response<()>, Error>;
278
279 async fn report(
284 &self,
285 account_id: String,
286 options: Option<&ReportInputOptions>,
287 ) -> Result<Response<entities::Report>, Error>;
288
289 async fn get_follow_requests(
294 &self,
295 limit: Option<u32>,
296 ) -> Result<Response<Vec<FollowRequestOutput>>, Error>;
297
298 async fn accept_follow_request(
300 &self,
301 id: String,
302 ) -> Result<Response<entities::Relationship>, Error>;
303
304 async fn reject_follow_request(
306 &self,
307 id: String,
308 ) -> Result<Response<entities::Relationship>, Error>;
309
310 async fn get_endorsements(
315 &self,
316 options: Option<&GetEndorsementsInputOptions>,
317 ) -> Result<Response<Vec<entities::Account>>, Error>;
318
319 async fn get_featured_tags(&self) -> Result<Response<Vec<entities::FeaturedTag>>, Error>;
324
325 async fn create_featured_tag(
327 &self,
328 name: String,
329 ) -> Result<Response<entities::FeaturedTag>, Error>;
330
331 async fn delete_featured_tag(&self, id: String) -> Result<Response<()>, Error>;
333
334 async fn get_suggested_tags(&self) -> Result<Response<Vec<entities::Tag>>, Error>;
336
337 async fn get_preferences(&self) -> Result<Response<entities::Preferences>, Error>;
342
343 async fn get_followed_tags(&self) -> Result<Response<Vec<entities::Tag>>, Error>;
348
349 async fn get_suggestions(
354 &self,
355 limit: Option<u32>,
356 ) -> Result<Response<Vec<entities::Account>>, Error>;
357
358 async fn get_tag(&self, id: String) -> Result<Response<entities::Tag>, Error>;
363
364 async fn follow_tag(&self, id: String) -> Result<Response<entities::Tag>, Error>;
366
367 async fn unfollow_tag(&self, id: String) -> Result<Response<entities::Tag>, Error>;
369
370 async fn post_status(
375 &self,
376 status: String,
377 options: Option<&PostStatusInputOptions>,
378 ) -> Result<Response<PostStatusOutput>, Error>;
379
380 async fn get_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
382
383 async fn get_status_source(
385 &self,
386 id: String,
387 ) -> Result<Response<entities::StatusSource>, Error>;
388
389 async fn edit_status(
391 &self,
392 id: String,
393 options: &EditStatusInputOptions,
394 ) -> Result<Response<entities::Status>, Error>;
395
396 async fn delete_status(&self, id: String) -> Result<Response<()>, Error>;
398
399 async fn get_status_context(
401 &self,
402 id: String,
403 options: Option<&GetStatusContextInputOptions>,
404 ) -> Result<Response<entities::Context>, Error>;
405
406 async fn get_status_reblogged_by(
408 &self,
409 id: String,
410 ) -> Result<Response<Vec<entities::Account>>, Error>;
411
412 async fn get_status_favourited_by(
414 &self,
415 id: String,
416 ) -> Result<Response<Vec<entities::Account>>, Error>;
417
418 async fn favourite_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
420
421 async fn unfavourite_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
423
424 async fn reblog_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
426
427 async fn unreblog_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
429
430 async fn bookmark_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
432
433 async fn unbookmark_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
435
436 async fn mute_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
438
439 async fn unmute_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
441
442 async fn pin_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
444
445 async fn unpin_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
447
448 async fn upload_media(
453 &self,
454 file_path: String,
455 options: Option<&UploadMediaInputOptions>,
456 ) -> Result<Response<entities::UploadMedia>, Error> {
457 let file = File::open(file_path.clone()).await?;
458 self.upload_media_reader(Box::new(file), options, Some(file_path)).await
459 }
460
461 async fn upload_media_reader(
462 &self,
463 reader: Box<dyn AsyncRead + Sync + Send + Unpin>,
464 options: Option<&UploadMediaInputOptions>,
465 file_name: Option<String>,
466 ) -> Result<Response<entities::UploadMedia>, Error>;
467
468 async fn get_media(&self, id: String) -> Result<Response<entities::Attachment>, Error>;
470
471 async fn update_media(
473 &self,
474 id: String,
475 options: Option<&UpdateMediaInputOptions>,
476 ) -> Result<Response<entities::Attachment>, Error>;
477
478 async fn get_poll(&self, id: String) -> Result<Response<entities::Poll>, Error>;
483
484 async fn vote_poll(
486 &self,
487 id: String,
488 choices: Vec<u32>,
489 status_id: Option<String>,
490 ) -> Result<Response<entities::Poll>, Error>;
491
492 async fn get_scheduled_statuses(
497 &self,
498 options: Option<&GetScheduledStatusesInputOptions>,
499 ) -> Result<Response<Vec<entities::ScheduledStatus>>, Error>;
500
501 async fn get_scheduled_status(
503 &self,
504 id: String,
505 ) -> Result<Response<entities::ScheduledStatus>, Error>;
506
507 async fn schedule_status(
509 &self,
510 id: String,
511 scheduled_at: Option<DateTime<Utc>>,
512 ) -> Result<Response<entities::ScheduledStatus>, Error>;
513
514 async fn cancel_scheduled_status(&self, id: String) -> Result<Response<()>, Error>;
516
517 async fn get_public_timeline(
522 &self,
523 options: Option<&GetPublicTimelineInputOptions>,
524 ) -> Result<Response<Vec<entities::Status>>, Error>;
525
526 async fn get_local_timeline(
528 &self,
529 options: Option<&GetLocalTimelineInputOptions>,
530 ) -> Result<Response<Vec<entities::Status>>, Error>;
531
532 async fn get_tag_timeline(
534 &self,
535 hashtag: String,
536 options: Option<&GetTagTimelineInputOptions>,
537 ) -> Result<Response<Vec<entities::Status>>, Error>;
538
539 async fn get_home_timeline(
541 &self,
542 options: Option<&GetHomeTimelineInputOptions>,
543 ) -> Result<Response<Vec<entities::Status>>, Error>;
544
545 async fn get_list_timeline(
547 &self,
548 list_id: String,
549 options: Option<&GetListTimelineInputOptions>,
550 ) -> Result<Response<Vec<entities::Status>>, Error>;
551
552 async fn get_conversation_timeline(
557 &self,
558 options: Option<&GetConversationTimelineInputOptions>,
559 ) -> Result<Response<Vec<entities::Conversation>>, Error>;
560
561 async fn delete_conversation(&self, id: String) -> Result<Response<()>, Error>;
563
564 async fn read_conversation(
566 &self,
567 id: String,
568 ) -> Result<Response<entities::Conversation>, Error>;
569
570 async fn get_lists(&self) -> Result<Response<Vec<entities::List>>, Error>;
575
576 async fn get_list(&self, id: String) -> Result<Response<entities::List>, Error>;
578
579 async fn create_list(&self, title: String) -> Result<Response<entities::List>, Error>;
581
582 async fn update_list(
584 &self,
585 id: String,
586 title: String,
587 ) -> Result<Response<entities::List>, Error>;
588
589 async fn delete_list(&self, id: String) -> Result<Response<()>, Error>;
591
592 async fn get_accounts_in_list(
594 &self,
595 id: String,
596 options: Option<&GetAccountsInListInputOptions>,
597 ) -> Result<Response<Vec<entities::Account>>, Error>;
598
599 async fn add_accounts_to_list(
601 &self,
602 id: String,
603 account_ids: Vec<String>,
604 ) -> Result<Response<entities::List>, Error>;
605
606 async fn delete_accounts_from_list(
608 &self,
609 id: String,
610 account_ids: Vec<String>,
611 ) -> Result<Response<()>, Error>;
612
613 async fn get_markers(&self, timeline: Vec<String>)
618 -> Result<Response<entities::Marker>, Error>;
619
620 async fn save_markers(
622 &self,
623 options: Option<&SaveMarkersInputOptions>,
624 ) -> Result<Response<entities::Marker>, Error>;
625
626 async fn get_notifications(
631 &self,
632 options: Option<&GetNotificationsInputOptions>,
633 ) -> Result<Response<Vec<entities::Notification>>, Error>;
634
635 async fn get_notification(&self, id: String)
637 -> Result<Response<entities::Notification>, Error>;
638
639 async fn dismiss_notifications(&self) -> Result<Response<()>, Error>;
641
642 async fn dismiss_notification(&self, id: String) -> Result<Response<()>, Error>;
644
645 async fn read_notifications(
647 &self,
648 options: &ReadNotificationsInputOptions,
649 ) -> Result<Response<()>, Error>;
650
651 async fn subscribe_push_notification(
656 &self,
657 subscription: &SubscribePushNotificationInputSubscription,
658 data: Option<&SubscribePushNotificationInputData>,
659 ) -> Result<Response<entities::PushSubscription>, Error>;
660
661 async fn get_push_subscription(&self) -> Result<Response<entities::PushSubscription>, Error>;
663
664 async fn update_push_subscription(
666 &self,
667 data: Option<&SubscribePushNotificationInputData>,
668 ) -> Result<Response<entities::PushSubscription>, Error>;
669
670 async fn delete_push_subscription(&self) -> Result<Response<()>, Error>;
672
673 async fn search(
678 &self,
679 q: String,
680 options: Option<&SearchInputOptions>,
681 ) -> Result<Response<entities::Results>, Error>;
682
683 async fn get_instance(&self) -> Result<Response<entities::Instance>, Error>;
688
689 async fn get_instance_peers(&self) -> Result<Response<Vec<String>>, Error>;
691
692 async fn get_instance_activity(&self) -> Result<Response<Vec<entities::Activity>>, Error>;
694
695 async fn get_instance_trends(
700 &self,
701 limit: Option<u32>,
702 ) -> Result<Response<Vec<entities::Tag>>, Error>;
703
704 async fn get_instance_directory(
709 &self,
710 options: Option<&GetInstanceDirectoryInputOptions>,
711 ) -> Result<Response<Vec<entities::Account>>, Error>;
712
713 async fn get_instance_custom_emojis(&self) -> Result<Response<Vec<entities::Emoji>>, Error>;
718
719 async fn get_instance_announcements(
724 &self,
725 ) -> Result<Response<Vec<entities::Announcement>>, Error>;
726
727 async fn dismiss_instance_announcement(&self, id: String) -> Result<Response<()>, Error>;
729
730 async fn add_reaction_to_announcement(
732 &self,
733 id: String,
734 name: String,
735 ) -> Result<Response<()>, Error>;
736
737 async fn remove_reaction_from_announcement(
739 &self,
740 id: String,
741 name: String,
742 ) -> Result<Response<()>, Error>;
743
744 async fn create_emoji_reaction(
749 &self,
750 id: String,
751 emoji: String,
752 ) -> Result<Response<entities::Status>, Error>;
753
754 async fn delete_emoji_reaction(
756 &self,
757 id: String,
758 emoji: String,
759 ) -> Result<Response<entities::Status>, Error>;
760
761 async fn get_emoji_reactions(
763 &self,
764 id: String,
765 ) -> Result<Response<Vec<entities::Reaction>>, Error>;
766
767 async fn get_emoji_reaction(
769 &self,
770 id: String,
771 emoji: String,
772 ) -> Result<Response<entities::Reaction>, Error>;
773
774 async fn streaming_url(&self) -> String;
779
780 async fn user_streaming(&self) -> Box<dyn Streaming + Send + Sync>;
782
783 async fn public_streaming(&self) -> Box<dyn Streaming + Send + Sync>;
785
786 async fn local_streaming(&self) -> Box<dyn Streaming + Send + Sync>;
788
789 async fn direct_streaming(&self) -> Box<dyn Streaming + Send + Sync>;
791
792 async fn tag_streaming(&self, tag: String) -> Box<dyn Streaming + Send + Sync>;
794
795 async fn list_streaming(&self, list_id: String) -> Box<dyn Streaming + Send + Sync>;
797}
798
799#[derive(Debug, Clone, Default)]
801pub struct AppInputOptions {
802 pub scopes: Option<Vec<String>>,
804 pub redirect_uris: Option<String>,
806 pub website: Option<String>,
808}
809
810#[derive(Debug, Clone, Default)]
812pub struct UpdateCredentialsInputOptions {
813 pub discoverable: Option<bool>,
815 pub bot: Option<bool>,
817 pub display_name: Option<String>,
819 pub note: Option<String>,
821 pub avatar: Option<String>,
823 pub header: Option<String>,
825 pub locked: Option<bool>,
827 pub source: Option<CredentialsSource>,
829 pub fields_attributes: Option<Vec<CredentialsFieldAttribute>>,
831}
832
833#[derive(Debug, Serialize, Clone, Default)]
835pub struct CredentialsSource {
836 pub privacy: Option<String>,
838 pub sensitive: Option<bool>,
840 pub language: Option<String>,
842}
843
844#[derive(Debug, Serialize, Clone)]
846pub struct CredentialsFieldAttribute {
847 pub name: String,
849 pub value: String,
851}
852
853#[derive(Debug, Clone, Default)]
855pub struct GetAccountStatusesInputOptions {
856 pub limit: Option<u32>,
858 pub max_id: Option<String>,
860 pub since_id: Option<String>,
862 pub pinned: Option<bool>,
864 pub exclude_replies: Option<bool>,
866 pub exclude_reblogs: Option<bool>,
868 pub only_media: Option<bool>,
870 pub only_public: Option<bool>,
872}
873
874#[derive(Debug, Clone, Default)]
876pub struct GetAccountFavouritesInputOptions {
877 pub limit: Option<u32>,
879 pub max_id: Option<String>,
881 pub since_id: Option<String>,
883}
884
885#[derive(Debug, Clone, Default)]
887pub struct AccountFollowersInputOptions {
888 pub limit: Option<u32>,
890 pub max_id: Option<String>,
892 pub since_id: Option<String>,
894}
895
896#[derive(Debug, Clone, Default)]
898pub struct FollowAccountInputOptions {
899 pub reblog: Option<bool>,
901 pub notify: Option<bool>,
903}
904
905#[derive(Debug, Clone, Default)]
907pub struct SearchAccountInputOptions {
908 pub following: Option<bool>,
910 pub resolve: Option<bool>,
912 pub limit: Option<u32>,
914 pub max_id: Option<String>,
916 pub since_id: Option<String>,
918}
919
920pub type GetBookmarksInputOptions = GetArrayWithSinceOptions;
922
923pub type GetFavouritesInputOptions = GetArrayOptions;
925
926pub type GetMutesInputOptions = GetArrayOptions;
928
929pub type GetBlocksInputOptions = GetArrayOptions;
931
932pub type GetDomainBlocksInputOptions = GetArrayOptions;
934
935#[derive(Debug, Clone, Default)]
937pub struct GetArrayOptions {
938 pub limit: Option<u32>,
940 pub max_id: Option<String>,
942 pub min_id: Option<String>,
944}
945
946#[derive(Debug, Clone, Default)]
948pub struct GetArrayWithSinceOptions {
949 pub limit: Option<u32>,
951 pub max_id: Option<String>,
953 pub since_id: Option<String>,
955 pub min_id: Option<String>,
957}
958
959#[derive(Debug, Clone, Default)]
961pub struct FilterInputOptions {
962 pub irreversible: Option<bool>,
964 pub whole_word: Option<bool>,
966 pub expires_in: Option<u64>,
968}
969
970#[derive(Debug, Clone, Default)]
972pub struct ReportInputOptions {
973 pub status_ids: Option<Vec<String>>,
975 pub comment: Option<String>,
977 pub forward: Option<bool>,
979 pub category: Option<entities::report::Category>,
981 pub rule_ids: Option<Vec<u64>>,
983}
984
985#[derive(Debug, Clone, Default)]
987pub struct GetEndorsementsInputOptions {
988 pub limit: Option<u32>,
990 pub max_id: Option<String>,
992 pub since_id: Option<String>,
994}
995
996#[derive(Debug, Clone, Default)]
998pub struct PostStatusInputOptions {
999 pub media_ids: Option<Vec<String>>,
1001 pub poll: Option<PollOptions>,
1003 pub in_reply_to_id: Option<String>,
1005 pub sensitive: Option<bool>,
1007 pub spoiler_text: Option<String>,
1009 pub visibility: Option<entities::status::StatusVisibility>,
1011 pub scheduled_at: Option<DateTime<Utc>>,
1013 pub language: Option<String>,
1015 pub quote_id: Option<String>,
1017}
1018
1019#[derive(Debug, Clone, Default)]
1021pub struct EditStatusInputOptions {
1022 pub status: Option<String>,
1024 pub spoiler_text: Option<String>,
1026 pub sensitive: Option<bool>,
1028 pub language: Option<String>,
1030 pub media_ids: Option<Vec<String>>,
1032 pub poll: Option<PollOptions>,
1034}
1035
1036#[derive(Debug, Serialize, Clone, Default)]
1038pub struct PollOptions {
1039 pub options: Vec<String>,
1041 pub expires_in: Option<u64>,
1043 pub multiple: Option<bool>,
1045 pub hide_totals: Option<bool>,
1047}
1048
1049#[derive(Debug, Clone, Default)]
1051pub struct GetStatusContextInputOptions {
1052 pub limit: Option<u32>,
1054 pub max_id: Option<String>,
1056 pub since_id: Option<String>,
1058}
1059
1060#[derive(Debug, Clone, Default)]
1062pub struct UploadMediaInputOptions {
1063 pub description: Option<String>,
1065 pub focus: Option<String>,
1067}
1068
1069#[derive(Debug, Clone, Default)]
1071pub struct UpdateMediaInputOptions {
1072 pub file_path: Option<String>,
1074 pub description: Option<String>,
1076 pub focus: Option<String>,
1078}
1079
1080pub type GetScheduledStatusesInputOptions = GetArrayWithSinceOptions;
1082
1083pub type GetPublicTimelineInputOptions = GetTimelineOptions;
1085pub type GetLocalTimelineInputOptions = GetTimelineOptions;
1087pub type GetTagTimelineInputOptions = GetTimelineOptionsWithLocal;
1089pub type GetHomeTimelineInputOptions = GetTimelineOptionsWithLocal;
1091pub type GetListTimelineInputOptions = GetArrayWithSinceOptions;
1093pub type GetConversationTimelineInputOptions = GetArrayWithSinceOptions;
1095
1096pub type GetAccountsInListInputOptions = GetArrayOptions;
1098
1099#[derive(Debug, Clone, Default)]
1101pub struct GetTimelineOptions {
1102 pub only_media: Option<bool>,
1104 pub limit: Option<u32>,
1106 pub max_id: Option<String>,
1108 pub since_id: Option<String>,
1110 pub min_id: Option<String>,
1112}
1113
1114#[derive(Debug, Clone, Default)]
1116pub struct GetTimelineOptionsWithLocal {
1117 pub only_media: Option<bool>,
1119 pub limit: Option<u32>,
1121 pub max_id: Option<String>,
1123 pub since_id: Option<String>,
1125 pub min_id: Option<String>,
1127 pub local: Option<bool>,
1129}
1130
1131#[derive(Debug, Clone, Default)]
1133pub struct SaveMarkersInputOptions {
1134 pub home: Option<Marker>,
1136 pub notifications: Option<Marker>,
1138}
1139
1140#[derive(Debug, Serialize, Clone)]
1142pub struct Marker {
1143 pub last_reading_id: String,
1145}
1146
1147#[derive(Debug, Clone, Default)]
1149pub struct GetNotificationsInputOptions {
1150 pub limit: Option<u32>,
1152 pub max_id: Option<String>,
1154 pub since_id: Option<String>,
1156 pub min_id: Option<String>,
1158 pub exclude_types: Option<Vec<entities::notification::NotificationType>>,
1160 pub account_id: Option<String>,
1162}
1163
1164#[derive(Debug, Clone, Default)]
1166pub struct ReadNotificationsInputOptions {
1167 pub id: Option<String>,
1169 pub max_id: Option<String>,
1171}
1172
1173#[derive(Debug, Serialize, Clone)]
1175pub struct SubscribePushNotificationInputSubscription {
1176 pub endpoint: String,
1178 pub keys: SubscriptionKeys,
1180}
1181
1182#[derive(Debug, Serialize, Clone)]
1184pub struct SubscriptionKeys {
1185 pub p256h: String,
1187 pub auth: String,
1189}
1190
1191#[derive(Debug, Serialize, Clone, Default)]
1193pub struct SubscribePushNotificationInputData {
1194 pub alerts: Option<DataAlerts>,
1196}
1197
1198#[derive(Debug, Serialize, Clone, Default)]
1200pub struct DataAlerts {
1201 pub follow: Option<bool>,
1203 pub favourite: Option<bool>,
1205 pub reblog: Option<bool>,
1207 pub mention: Option<bool>,
1209 pub poll: Option<bool>,
1211}
1212
1213#[derive(Debug, Clone)]
1215pub enum SearchType {
1216 Accounts,
1218 Hashtags,
1220 Statuses,
1222}
1223
1224impl fmt::Display for SearchType {
1225 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1226 match self {
1227 SearchType::Accounts => write!(f, "accounts"),
1228 SearchType::Hashtags => write!(f, "hashtags"),
1229 SearchType::Statuses => write!(f, "statuses"),
1230 }
1231 }
1232}
1233
1234impl FromStr for SearchType {
1235 type Err = Error;
1236
1237 fn from_str(s: &str) -> Result<Self, Self::Err> {
1238 match s {
1239 "accounts" => Ok(SearchType::Accounts),
1240 "hashtags" => Ok(SearchType::Hashtags),
1241 "statuses" => Ok(SearchType::Statuses),
1242 _ => Err(Error::new_own(
1243 s.to_owned(),
1244 Kind::ParseError,
1245 None,
1246 None,
1247 None,
1248 )),
1249 }
1250 }
1251}
1252
1253#[derive(Debug, Clone, Default)]
1255pub struct SearchInputOptions {
1256 pub r#type: Option<SearchType>,
1258 pub limit: Option<u32>,
1260 pub max_id: Option<String>,
1262 pub min_id: Option<String>,
1264 pub resolve: Option<bool>,
1266 pub offset: Option<u64>,
1268 pub following: Option<bool>,
1270 pub account_id: Option<String>,
1272 pub exclude_unreviewed: Option<bool>,
1274}
1275
1276#[derive(Debug, Clone, Default)]
1278pub struct GetInstanceDirectoryInputOptions {
1279 pub limit: Option<u32>,
1281 pub offset: Option<u64>,
1283 pub order: Option<Order>,
1285 pub local: Option<bool>,
1287}
1288
1289#[derive(Debug, Clone)]
1291pub enum Order {
1292 Active,
1294 New,
1296}
1297
1298impl fmt::Display for Order {
1299 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1300 match self {
1301 Order::Active => write!(f, "active"),
1302 Order::New => write!(f, "new"),
1303 }
1304 }
1305}
1306
1307impl FromStr for Order {
1308 type Err = Error;
1309
1310 fn from_str(s: &str) -> Result<Self, Self::Err> {
1311 match s {
1312 "active" => Ok(Order::Active),
1313 "new" => Ok(Order::New),
1314 _ => Err(Error::new_own(
1315 s.to_owned(),
1316 Kind::ParseError,
1317 None,
1318 None,
1319 None,
1320 )),
1321 }
1322 }
1323}
1324
1325#[derive(Debug, Clone)]
1327pub enum FollowRequestOutput {
1328 Account(entities::Account),
1330 FollowRequest(entities::FollowRequest),
1332}
1333
1334#[derive(Debug, Clone)]
1336pub enum PostStatusOutput {
1337 Status(entities::Status),
1339 ScheduledStatus(entities::ScheduledStatus),
1341}