tangled
alpha
login
or
join now
blooym.dev
/
jacquard
forked from
nonbinary.computer/jacquard
0
fork
atom
A better Rust ATProto crate
0
fork
atom
overview
issues
pulls
pipelines
some test fixes with new enum stuff
Orual
2 months ago
22a09f81
9d9e59ef
+33
-33
2 changed files
expand all
collapse all
unified
split
crates
jacquard
src
moderation
tests.rs
examples
subscribe_repos.rs
+19
-16
crates/jacquard/src/moderation/tests.rs
···
4
4
};
5
5
use jacquard_api::app_bsky::feed::FeedViewPost;
6
6
use jacquard_api::app_bsky::labeler::get_services::GetServicesOutput;
7
7
-
use jacquard_api::com_atproto::label::{Label, LabelValueDefinition};
7
7
+
use jacquard_api::com_atproto::label::{
8
8
+
Label, LabelValueDefinition, LabelValueDefinitionBlurs, LabelValueDefinitionDefaultSetting,
9
9
+
LabelValueDefinitionSeverity,
10
10
+
};
8
11
use jacquard_common::CowStr;
9
12
use jacquard_common::types::string::{Datetime, Did, Uri};
10
13
use serde::Deserialize;
···
50
53
// Create a label definition with defaultSetting: "hide"
51
54
let spam_def = LabelValueDefinition {
52
55
identifier: CowStr::from("spam"),
53
53
-
blurs: CowStr::from("content"),
54
54
-
severity: CowStr::from("inform"),
55
55
-
default_setting: Some(CowStr::from("hide")),
56
56
+
blurs: LabelValueDefinitionBlurs::Content,
57
57
+
severity: LabelValueDefinitionSeverity::Inform,
58
58
+
default_setting: Some(LabelValueDefinitionDefaultSetting::Hide),
56
59
adult_only: Some(false),
57
60
locales: vec![],
58
61
extra_data: None,
···
102
105
103
106
let def = LabelValueDefinition {
104
107
identifier: CowStr::from("test-label"),
105
105
-
blurs: CowStr::from("content"),
106
106
-
severity: CowStr::from("alert"),
107
107
-
default_setting: Some(CowStr::from("hide")),
108
108
+
blurs: LabelValueDefinitionBlurs::Content,
109
109
+
severity: LabelValueDefinitionSeverity::Alert,
110
110
+
default_setting: Some(LabelValueDefinitionDefaultSetting::Hide),
108
111
adult_only: Some(false),
109
112
locales: vec![],
110
113
extra_data: None,
···
221
224
// Media blur
222
225
let media_def = LabelValueDefinition {
223
226
identifier: CowStr::from("media-label"),
224
224
-
blurs: CowStr::from("media"),
225
225
-
severity: CowStr::from("alert"),
226
226
-
default_setting: Some(CowStr::from("warn")),
227
227
+
blurs: LabelValueDefinitionBlurs::Media,
228
228
+
severity: LabelValueDefinitionSeverity::Alert,
229
229
+
default_setting: Some(LabelValueDefinitionDefaultSetting::Warn),
227
230
adult_only: Some(false),
228
231
locales: vec![],
229
232
extra_data: None,
···
232
235
// Content blur
233
236
let content_def = LabelValueDefinition {
234
237
identifier: CowStr::from("content-label"),
235
235
-
blurs: CowStr::from("content"),
236
236
-
severity: CowStr::from("alert"),
237
237
-
default_setting: Some(CowStr::from("warn")),
238
238
+
blurs: LabelValueDefinitionBlurs::Content,
239
239
+
severity: LabelValueDefinitionSeverity::Alert,
240
240
+
default_setting: Some(LabelValueDefinitionDefaultSetting::Warn),
238
241
adult_only: Some(false),
239
242
locales: vec![],
240
243
extra_data: None,
···
301
304
302
305
let adult_def = LabelValueDefinition {
303
306
identifier: CowStr::from("adult-label"),
304
304
-
blurs: CowStr::from("content"),
305
305
-
severity: CowStr::from("alert"),
306
306
-
default_setting: Some(CowStr::from("warn")),
307
307
+
blurs: LabelValueDefinitionBlurs::Content,
308
308
+
severity: LabelValueDefinitionSeverity::Alert,
309
309
+
default_setting: Some(LabelValueDefinitionDefaultSetting::Warn),
307
310
adult_only: Some(true),
308
311
locales: vec![],
309
312
extra_data: None,
+14
-17
examples/subscribe_repos.rs
···
8
8
9
9
use clap::Parser;
10
10
use jacquard::api::com_atproto::sync::subscribe_repos::{SubscribeRepos, SubscribeReposMessage};
11
11
-
use jacquard_api::com_atproto::sync::subscribe_repos::RepoOp;
12
11
use jacquard_common::xrpc::{SubscriptionClient, TungsteniteSubscriptionClient};
13
12
use miette::IntoDiagnostic;
14
13
use n0_future::StreamExt;
···
45
44
fn print_message(msg: &SubscribeReposMessage) {
46
45
match msg {
47
46
SubscribeReposMessage::Commit(commit) => {
48
48
-
if commit.ops.iter().any(|op| op.action == "delete") {
49
49
-
println!(
50
50
-
"Commit | repo={} seq={} time={} rev={} commit={} ops={:?} prev={}",
51
51
-
commit.repo,
52
52
-
commit.seq,
53
53
-
commit.time,
54
54
-
commit.rev,
55
55
-
commit.commit,
56
56
-
commit.ops,
57
57
-
commit
58
58
-
.since
59
59
-
.as_ref()
60
60
-
.map(|ts| ts.to_smolstr())
61
61
-
.unwrap_or_default(),
62
62
-
);
63
63
-
}
47
47
+
println!(
48
48
+
"Commit | repo={} seq={} time={} rev={} commit={} prev={}\n | ops={:?} ",
49
49
+
commit.repo,
50
50
+
commit.seq,
51
51
+
commit.time,
52
52
+
commit.rev,
53
53
+
commit.commit,
54
54
+
commit
55
55
+
.since
56
56
+
.as_ref()
57
57
+
.map(|ts| ts.to_smolstr())
58
58
+
.unwrap_or_default(),
59
59
+
commit.ops,
60
60
+
);
64
61
}
65
62
SubscribeReposMessage::Identity(identity) => {
66
63
println!(