bsky-sdk 0.1.24

ATrium-based SDK for Bluesky
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
use super::decision::{DecisionContext, Priority};
use super::error::Error;
use atrium_api::agent::bluesky::BSKY_LABELER_DID;
use atrium_api::app::bsky::actor::defs::{
    MutedWord, ProfileView, ProfileViewBasic, ProfileViewDetailed, ViewerState,
};
use atrium_api::app::bsky::graph::defs::{ListView, ListViewBasic};
use atrium_api::com::atproto::label::defs::{Label, LabelValueDefinitionStrings};
use atrium_api::types::string::Did;
use serde::{Deserialize, Deserializer, Serialize};
use std::{collections::HashMap, str::FromStr};

// behaviors

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum BehaviorValue {
    Blur,
    Alert,
    Inform,
}

/// Moderation behaviors for different contexts.
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ModerationBehavior {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub profile_list: Option<ProfileListBehavior>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub profile_view: Option<ProfileViewBehavior>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub avatar: Option<AvatarBehavior>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub banner: Option<BannerBehavior>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub display_name: Option<DisplayNameBehavior>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub content_list: Option<ContentListBehavior>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub content_view: Option<ContentViewBehavior>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub content_media: Option<ContentMediaBehavior>,
}

impl ModerationBehavior {
    pub(crate) const BLOCK_BEHAVIOR: Self = Self {
        profile_list: Some(ProfileListBehavior::Blur),
        profile_view: Some(ProfileViewBehavior::Alert),
        avatar: Some(AvatarBehavior::Blur),
        banner: Some(BannerBehavior::Blur),
        display_name: None,
        content_list: Some(ContentListBehavior::Blur),
        content_view: Some(ContentViewBehavior::Blur),
        content_media: None,
    };
    pub(crate) const MUTE_BEHAVIOR: Self = Self {
        profile_list: Some(ProfileListBehavior::Inform),
        profile_view: Some(ProfileViewBehavior::Alert),
        avatar: None,
        banner: None,
        display_name: None,
        content_list: Some(ContentListBehavior::Blur),
        content_view: Some(ContentViewBehavior::Inform),
        content_media: None,
    };
    pub(crate) const MUTEWORD_BEHAVIOR: Self = Self {
        profile_list: None,
        profile_view: None,
        avatar: None,
        banner: None,
        display_name: None,
        content_list: Some(ContentListBehavior::Blur),
        content_view: Some(ContentViewBehavior::Blur),
        content_media: None,
    };
    pub(crate) const HIDE_BEHAVIOR: Self = Self {
        profile_list: None,
        profile_view: None,
        avatar: None,
        banner: None,
        display_name: None,
        content_list: Some(ContentListBehavior::Blur),
        content_view: Some(ContentViewBehavior::Blur),
        content_media: None,
    };
    pub(crate) fn behavior_for(&self, context: DecisionContext) -> Option<BehaviorValue> {
        match context {
            DecisionContext::ProfileList => self.profile_list.clone().map(Into::into),
            DecisionContext::ProfileView => self.profile_view.clone().map(Into::into),
            DecisionContext::Avatar => self.avatar.clone().map(Into::into),
            DecisionContext::Banner => self.banner.clone().map(Into::into),
            DecisionContext::DisplayName => self.display_name.clone().map(Into::into),
            DecisionContext::ContentList => self.content_list.clone().map(Into::into),
            DecisionContext::ContentView => self.content_view.clone().map(Into::into),
            DecisionContext::ContentMedia => self.content_media.clone().map(Into::into),
        }
    }
}

/// Moderation behaviors for the profile list.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ProfileListBehavior {
    Blur,
    Alert,
    Inform,
}

impl From<ProfileListBehavior> for BehaviorValue {
    fn from(b: ProfileListBehavior) -> Self {
        match b {
            ProfileListBehavior::Blur => Self::Blur,
            ProfileListBehavior::Alert => Self::Alert,
            ProfileListBehavior::Inform => Self::Inform,
        }
    }
}

impl TryFrom<BehaviorValue> for ProfileListBehavior {
    type Error = Error;

    fn try_from(b: BehaviorValue) -> Result<Self, Self::Error> {
        match b {
            BehaviorValue::Blur => Ok(Self::Blur),
            BehaviorValue::Alert => Ok(Self::Alert),
            BehaviorValue::Inform => Ok(Self::Inform),
        }
    }
}

/// Moderation behaviors for the profile view.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ProfileViewBehavior {
    Blur,
    Alert,
    Inform,
}

impl From<ProfileViewBehavior> for BehaviorValue {
    fn from(b: ProfileViewBehavior) -> Self {
        match b {
            ProfileViewBehavior::Blur => Self::Blur,
            ProfileViewBehavior::Alert => Self::Alert,
            ProfileViewBehavior::Inform => Self::Inform,
        }
    }
}

impl TryFrom<BehaviorValue> for ProfileViewBehavior {
    type Error = Error;

    fn try_from(b: BehaviorValue) -> Result<Self, Self::Error> {
        match b {
            BehaviorValue::Blur => Ok(Self::Blur),
            BehaviorValue::Alert => Ok(Self::Alert),
            BehaviorValue::Inform => Ok(Self::Inform),
        }
    }
}

/// Moderation behaviors for the user's avatar.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum AvatarBehavior {
    Blur,
    Alert,
}

impl From<AvatarBehavior> for BehaviorValue {
    fn from(b: AvatarBehavior) -> Self {
        match b {
            AvatarBehavior::Blur => Self::Blur,
            AvatarBehavior::Alert => Self::Alert,
        }
    }
}

impl TryFrom<BehaviorValue> for AvatarBehavior {
    type Error = Error;

    fn try_from(b: BehaviorValue) -> Result<Self, Self::Error> {
        match b {
            BehaviorValue::Blur => Ok(Self::Blur),
            BehaviorValue::Alert => Ok(Self::Alert),
            BehaviorValue::Inform => Err(Error::BehaviorValue),
        }
    }
}

/// Moderation behaviors for the user's banner.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum BannerBehavior {
    Blur,
}

impl From<BannerBehavior> for BehaviorValue {
    fn from(b: BannerBehavior) -> Self {
        match b {
            BannerBehavior::Blur => Self::Blur,
        }
    }
}

impl TryFrom<BehaviorValue> for BannerBehavior {
    type Error = Error;

    fn try_from(b: BehaviorValue) -> Result<Self, Self::Error> {
        match b {
            BehaviorValue::Blur => Ok(Self::Blur),
            _ => Err(Error::BehaviorValue),
        }
    }
}

/// Moderation behaviors for the user's display name.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum DisplayNameBehavior {
    Blur,
}

impl From<DisplayNameBehavior> for BehaviorValue {
    fn from(b: DisplayNameBehavior) -> Self {
        match b {
            DisplayNameBehavior::Blur => Self::Blur,
        }
    }
}

impl TryFrom<BehaviorValue> for DisplayNameBehavior {
    type Error = Error;

    fn try_from(b: BehaviorValue) -> Result<Self, Self::Error> {
        match b {
            BehaviorValue::Blur => Ok(Self::Blur),
            _ => Err(Error::BehaviorValue),
        }
    }
}

/// Moderation behaviors for the content list.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ContentListBehavior {
    Blur,
    Alert,
    Inform,
}

impl From<ContentListBehavior> for BehaviorValue {
    fn from(b: ContentListBehavior) -> Self {
        match b {
            ContentListBehavior::Blur => Self::Blur,
            ContentListBehavior::Alert => Self::Alert,
            ContentListBehavior::Inform => Self::Inform,
        }
    }
}

impl TryFrom<BehaviorValue> for ContentListBehavior {
    type Error = Error;

    fn try_from(b: BehaviorValue) -> Result<Self, Self::Error> {
        match b {
            BehaviorValue::Blur => Ok(Self::Blur),
            BehaviorValue::Alert => Ok(Self::Alert),
            BehaviorValue::Inform => Ok(Self::Inform),
        }
    }
}

/// Moderation behaviors for the content view.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ContentViewBehavior {
    Blur,
    Alert,
    Inform,
}

impl From<ContentViewBehavior> for BehaviorValue {
    fn from(b: ContentViewBehavior) -> Self {
        match b {
            ContentViewBehavior::Blur => Self::Blur,
            ContentViewBehavior::Alert => Self::Alert,
            ContentViewBehavior::Inform => Self::Inform,
        }
    }
}

impl TryFrom<BehaviorValue> for ContentViewBehavior {
    type Error = Error;

    fn try_from(b: BehaviorValue) -> Result<Self, Self::Error> {
        match b {
            BehaviorValue::Blur => Ok(Self::Blur),
            BehaviorValue::Alert => Ok(Self::Alert),
            BehaviorValue::Inform => Ok(Self::Inform),
        }
    }
}

/// Moderation behaviors for the content media.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ContentMediaBehavior {
    Blur,
}

impl From<ContentMediaBehavior> for BehaviorValue {
    fn from(b: ContentMediaBehavior) -> Self {
        match b {
            ContentMediaBehavior::Blur => Self::Blur,
        }
    }
}

impl TryFrom<BehaviorValue> for ContentMediaBehavior {
    type Error = Error;

    fn try_from(b: BehaviorValue) -> Result<Self, Self::Error> {
        match b {
            BehaviorValue::Blur => Ok(Self::Blur),
            _ => Err(Error::BehaviorValue),
        }
    }
}

// labels

/// The target of a label.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LabelTarget {
    Account,
    Profile,
    Content,
}

/// The preference for a label.
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum LabelPreference {
    Ignore,
    Warn,
    Hide,
}

impl AsRef<str> for LabelPreference {
    fn as_ref(&self) -> &str {
        match self {
            Self::Ignore => "ignore",
            Self::Warn => "warn",
            Self::Hide => "hide",
        }
    }
}

impl FromStr for LabelPreference {
    type Err = Error;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "ignore" => Ok(Self::Ignore),
            "warn" => Ok(Self::Warn),
            "hide" => Ok(Self::Hide),
            _ => Err(Error::LabelPreference),
        }
    }
}

/// A flag for a label value definition.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum LabelValueDefinitionFlag {
    NoOverride,
    Adult,
    Unauthed,
    NoSelf,
}

/// The blurs for a label value definition.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum LabelValueDefinitionBlurs {
    Content,
    Media,
    None,
}

impl AsRef<str> for LabelValueDefinitionBlurs {
    fn as_ref(&self) -> &str {
        match self {
            Self::Content => "content",
            Self::Media => "media",
            Self::None => "none",
        }
    }
}

impl FromStr for LabelValueDefinitionBlurs {
    type Err = Error;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "content" => Ok(Self::Content),
            "media" => Ok(Self::Media),
            "none" => Ok(Self::None),
            _ => Err(Error::LabelValueDefinitionBlurs),
        }
    }
}

/// The severity for a label value definition.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum LabelValueDefinitionSeverity {
    Inform,
    Alert,
    None,
}

impl AsRef<str> for LabelValueDefinitionSeverity {
    fn as_ref(&self) -> &str {
        match self {
            Self::Inform => "inform",
            Self::Alert => "alert",
            Self::None => "none",
        }
    }
}

impl FromStr for LabelValueDefinitionSeverity {
    type Err = Error;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "inform" => Ok(Self::Inform),
            "alert" => Ok(Self::Alert),
            "none" => Ok(Self::None),
            _ => Err(Error::LabelValueDefinitionSeverity),
        }
    }
}

/// A label value definition.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InterpretedLabelValueDefinition {
    // from com.atproto.label/defs#labelValueDefinition, with type narrowing
    pub adult_only: bool,
    pub blurs: LabelValueDefinitionBlurs,
    pub default_setting: LabelPreference,
    pub identifier: String,
    pub locales: Vec<LabelValueDefinitionStrings>,
    pub severity: LabelValueDefinitionSeverity,
    // others
    #[serde(skip_serializing_if = "Option::is_none")]
    pub defined_by: Option<Did>,
    pub configurable: bool,
    pub flags: Vec<LabelValueDefinitionFlag>,
    pub behaviors: InterpretedLabelValueDefinitionBehaviors,
}

/// The behaviors for a label value definition.
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct InterpretedLabelValueDefinitionBehaviors {
    pub account: ModerationBehavior,
    pub profile: ModerationBehavior,
    pub content: ModerationBehavior,
}

impl InterpretedLabelValueDefinitionBehaviors {
    pub(crate) fn behavior_for(&self, target: LabelTarget) -> ModerationBehavior {
        match target {
            LabelTarget::Account => self.account.clone(),
            LabelTarget::Profile => self.profile.clone(),
            LabelTarget::Content => self.content.clone(),
        }
    }
}

// subjects

/// A subject profile.
#[derive(Debug)]
pub enum SubjectProfile {
    ProfileViewBasic(Box<ProfileViewBasic>),
    ProfileView(Box<ProfileView>),
    ProfileViewDetailed(Box<ProfileViewDetailed>),
}

impl SubjectProfile {
    pub(crate) fn did(&self) -> &Did {
        match self {
            Self::ProfileViewBasic(p) => &p.did,
            Self::ProfileView(p) => &p.did,
            Self::ProfileViewDetailed(p) => &p.did,
        }
    }
    pub(crate) fn labels(&self) -> &Option<Vec<Label>> {
        match self {
            Self::ProfileViewBasic(p) => &p.labels,
            Self::ProfileView(p) => &p.labels,
            Self::ProfileViewDetailed(p) => &p.labels,
        }
    }
    pub(crate) fn viewer(&self) -> &Option<ViewerState> {
        match self {
            Self::ProfileViewBasic(p) => &p.viewer,
            Self::ProfileView(p) => &p.viewer,
            Self::ProfileViewDetailed(p) => &p.viewer,
        }
    }
}

impl From<ProfileViewBasic> for SubjectProfile {
    fn from(p: ProfileViewBasic) -> Self {
        Self::ProfileViewBasic(Box::new(p))
    }
}

impl From<ProfileView> for SubjectProfile {
    fn from(p: ProfileView) -> Self {
        Self::ProfileView(Box::new(p))
    }
}

impl From<ProfileViewDetailed> for SubjectProfile {
    fn from(p: ProfileViewDetailed) -> Self {
        Self::ProfileViewDetailed(Box::new(p))
    }
}

/// A subject post.
pub type SubjectPost = atrium_api::app::bsky::feed::defs::PostView;

/// A subject notification.
pub type SubjectNotification =
    atrium_api::app::bsky::notification::list_notifications::Notification;

/// A subject feed generator.
pub type SubjectFeedGenerator = atrium_api::app::bsky::feed::defs::GeneratorView;

/// A subject user list.
#[derive(Debug)]
pub enum SubjectUserList {
    ListView(Box<ListView>),
    ListViewBasic(Box<ListViewBasic>),
}

impl From<ListView> for SubjectUserList {
    fn from(list_view: ListView) -> Self {
        Self::ListView(Box::new(list_view))
    }
}

impl From<ListViewBasic> for SubjectUserList {
    fn from(list_view_basic: ListViewBasic) -> Self {
        Self::ListViewBasic(Box::new(list_view_basic))
    }
}

/// A cause for moderation decisions.
#[derive(Debug, Clone)]
pub enum ModerationCause {
    Blocking(Box<ModerationCauseOther>),
    BlockedBy(Box<ModerationCauseOther>),
    // BlockOther(Box<ModerationCauseOther>),
    Label(Box<ModerationCauseLabel>),
    Muted(Box<ModerationCauseOther>),
    MuteWord(Box<ModerationCauseOther>),
    Hidden(Box<ModerationCauseOther>),
}

impl ModerationCause {
    pub fn priority(&self) -> u8 {
        match self {
            Self::Blocking(_) => *Priority::Priority3.as_ref(),
            Self::BlockedBy(_) => *Priority::Priority4.as_ref(),
            Self::Label(label) => *label.priority.as_ref(),
            Self::Muted(_) => *Priority::Priority6.as_ref(),
            Self::MuteWord(_) => *Priority::Priority6.as_ref(),
            Self::Hidden(_) => *Priority::Priority6.as_ref(),
        }
    }
    pub fn downgrade(&mut self) {
        match self {
            Self::Blocking(blocking) => blocking.downgraded = true,
            Self::BlockedBy(blocked_by) => blocked_by.downgraded = true,
            Self::Label(label) => label.downgraded = true,
            Self::Muted(muted) => muted.downgraded = true,
            Self::MuteWord(mute_word) => mute_word.downgraded = true,
            Self::Hidden(hidden) => hidden.downgraded = true,
        }
    }
}

/// The source of a moderation cause.
#[derive(Debug, Clone)]
pub enum ModerationCauseSource {
    User,
    List(Box<ListViewBasic>),
    Labeler(Did),
}

/// A label moderation cause.
#[derive(Debug, Clone)]
pub struct ModerationCauseLabel {
    pub source: ModerationCauseSource,
    pub label: Label,
    pub label_def: InterpretedLabelValueDefinition,
    pub target: LabelTarget,
    pub setting: LabelPreference,
    pub behavior: ModerationBehavior,
    pub no_override: bool,
    pub(crate) priority: Priority,
    pub downgraded: bool,
}

/// An other moderation cause.
#[derive(Debug, Clone)]
pub struct ModerationCauseOther {
    pub source: ModerationCauseSource,
    pub downgraded: bool,
}

// moderation preferences

/// The labeler preferences for moderation.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ModerationPrefsLabeler {
    pub did: Did,
    pub labels: HashMap<String, LabelPreference>,
    #[serde(skip_serializing, skip_deserializing)]
    pub is_default_labeler: bool,
}

impl Default for ModerationPrefsLabeler {
    fn default() -> Self {
        Self {
            did: BSKY_LABELER_DID.parse().expect("invalid did"),
            labels: HashMap::default(),
            is_default_labeler: true,
        }
    }
}

/// The moderation preferences.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct ModerationPrefs {
    pub adult_content_enabled: bool,
    pub labels: HashMap<String, LabelPreference>,
    #[serde(deserialize_with = "deserialize_labelers")]
    pub labelers: Vec<ModerationPrefsLabeler>,
    pub muted_words: Vec<MutedWord>,
    pub hidden_posts: Vec<String>,
}

fn deserialize_labelers<'de, D>(deserializer: D) -> Result<Vec<ModerationPrefsLabeler>, D::Error>
where
    D: Deserializer<'de>,
{
    let mut labelers: Vec<ModerationPrefsLabeler> = Deserialize::deserialize(deserializer)?;
    for labeler in labelers.iter_mut() {
        if labeler.did.as_str() == BSKY_LABELER_DID {
            labeler.is_default_labeler = true;
        }
    }
    Ok(labelers)
}

impl Default for ModerationPrefs {
    fn default() -> Self {
        Self {
            adult_content_enabled: false,
            labels: HashMap::from_iter([
                (String::from("porn"), LabelPreference::Hide),
                (String::from("sexual"), LabelPreference::Warn),
                (String::from("nudity"), LabelPreference::Ignore),
                (String::from("graphic-media"), LabelPreference::Warn),
            ]),
            labelers: Vec::default(),
            muted_words: Vec::default(),
            hidden_posts: Vec::default(),
        }
    }
}