1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::deps::smol_str::SmolStr;
18use jacquard_common::types::string::{Did, Datetime};
19use jacquard_common::types::value::Data;
20use jacquard_derive::{IntoStatic, open_union};
21use jacquard_lexicon::lexicon::LexiconDoc;
22use jacquard_lexicon::schema::LexiconSchema;
23
24#[allow(unused_imports)]
25use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
26use serde::{Serialize, Deserialize};
27use crate::com_atproto::admin::RepoRef;
28use crate::com_atproto::moderation::ReasonType;
29use crate::com_atproto::repo::strong_ref::StrongRef;
30use crate::com_atproto::moderation::create_report;
31
32#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
33#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
34pub struct CreateReport<S: BosStr = DefaultStr> {
35 #[serde(skip_serializing_if = "Option::is_none")]
36 pub mod_tool: Option<create_report::ModTool<S>>,
37 #[serde(skip_serializing_if = "Option::is_none")]
39 pub reason: Option<S>,
40 pub reason_type: ReasonType<S>,
42 pub subject: CreateReportSubject<S>,
43 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
44 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
45}
46
47
48#[open_union]
49#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
50#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
51pub enum CreateReportSubject<S: BosStr = DefaultStr> {
52 #[serde(rename = "com.atproto.admin.defs#repoRef")]
53 RepoRef(Box<RepoRef<S>>),
54 #[serde(rename = "com.atproto.repo.strongRef")]
55 StrongRef(Box<StrongRef<S>>),
56}
57
58
59#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
60#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
61pub struct CreateReportOutput<S: BosStr = DefaultStr> {
62 pub created_at: Datetime,
63 pub id: i64,
64 #[serde(skip_serializing_if = "Option::is_none")]
65 pub reason: Option<S>,
66 pub reason_type: ReasonType<S>,
67 pub reported_by: Did<S>,
68 pub subject: CreateReportOutputSubject<S>,
69 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
70 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
71}
72
73
74#[open_union]
75#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
76#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
77pub enum CreateReportOutputSubject<S: BosStr = DefaultStr> {
78 #[serde(rename = "com.atproto.admin.defs#repoRef")]
79 RepoRef(Box<RepoRef<S>>),
80 #[serde(rename = "com.atproto.repo.strongRef")]
81 StrongRef(Box<StrongRef<S>>),
82}
83
84#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
87#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
88pub struct ModTool<S: BosStr = DefaultStr> {
89 #[serde(skip_serializing_if = "Option::is_none")]
91 pub meta: Option<Data<S>>,
92 pub name: S,
94 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
95 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
96}
97
98pub struct CreateReportResponse;
102impl jacquard_common::xrpc::XrpcResp for CreateReportResponse {
103 const NSID: &'static str = "com.atproto.moderation.createReport";
104 const ENCODING: &'static str = "application/json";
105 type Output<S: BosStr> = CreateReportOutput<S>;
106 type Err = jacquard_common::xrpc::GenericError;
107}
108
109impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for CreateReport<S> {
110 const NSID: &'static str = "com.atproto.moderation.createReport";
111 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
112 "application/json",
113 );
114 type Response = CreateReportResponse;
115}
116
117pub struct CreateReportRequest;
121impl jacquard_common::xrpc::XrpcEndpoint for CreateReportRequest {
122 const PATH: &'static str = "/xrpc/com.atproto.moderation.createReport";
123 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
124 "application/json",
125 );
126 type Request<S: BosStr> = CreateReport<S>;
127 type Response = CreateReportResponse;
128}
129
130impl<S: BosStr> LexiconSchema for ModTool<S> {
131 fn nsid() -> &'static str {
132 "com.atproto.moderation.createReport"
133 }
134 fn def_name() -> &'static str {
135 "modTool"
136 }
137 fn lexicon_doc() -> LexiconDoc<'static> {
138 lexicon_doc_com_atproto_moderation_createReport()
139 }
140 fn validate(&self) -> Result<(), ConstraintError> {
141 Ok(())
142 }
143}
144
145pub mod create_report_state {
146
147 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
148 #[allow(unused)]
149 use ::core::marker::PhantomData;
150 mod sealed {
151 pub trait Sealed {}
152 }
153 pub trait State: sealed::Sealed {
155 type ReasonType;
156 type Subject;
157 }
158 pub struct Empty(());
160 impl sealed::Sealed for Empty {}
161 impl State for Empty {
162 type ReasonType = Unset;
163 type Subject = Unset;
164 }
165 pub struct SetReasonType<St: State = Empty>(PhantomData<fn() -> St>);
167 impl<St: State> sealed::Sealed for SetReasonType<St> {}
168 impl<St: State> State for SetReasonType<St> {
169 type ReasonType = Set<members::reason_type>;
170 type Subject = St::Subject;
171 }
172 pub struct SetSubject<St: State = Empty>(PhantomData<fn() -> St>);
174 impl<St: State> sealed::Sealed for SetSubject<St> {}
175 impl<St: State> State for SetSubject<St> {
176 type ReasonType = St::ReasonType;
177 type Subject = Set<members::subject>;
178 }
179 #[allow(non_camel_case_types)]
181 pub mod members {
182 pub struct reason_type(());
184 pub struct subject(());
186 }
187}
188
189pub struct CreateReportBuilder<St: create_report_state::State, S: BosStr = DefaultStr> {
191 _state: PhantomData<fn() -> St>,
192 _fields: (
193 Option<create_report::ModTool<S>>,
194 Option<S>,
195 Option<ReasonType<S>>,
196 Option<CreateReportSubject<S>>,
197 ),
198 _type: PhantomData<fn() -> S>,
199}
200
201impl CreateReport<DefaultStr> {
202 pub fn new() -> CreateReportBuilder<create_report_state::Empty, DefaultStr> {
204 CreateReportBuilder::new()
205 }
206}
207
208impl<S: BosStr> CreateReport<S> {
209 pub fn builder() -> CreateReportBuilder<create_report_state::Empty, S> {
211 CreateReportBuilder::builder()
212 }
213}
214
215impl CreateReportBuilder<create_report_state::Empty, DefaultStr> {
216 pub fn new() -> Self {
218 CreateReportBuilder {
219 _state: PhantomData,
220 _fields: (None, None, None, None),
221 _type: PhantomData,
222 }
223 }
224}
225
226impl<S: BosStr> CreateReportBuilder<create_report_state::Empty, S> {
227 pub fn builder() -> Self {
229 CreateReportBuilder {
230 _state: PhantomData,
231 _fields: (None, None, None, None),
232 _type: PhantomData,
233 }
234 }
235}
236
237impl<St: create_report_state::State, S: BosStr> CreateReportBuilder<St, S> {
238 pub fn mod_tool(
240 mut self,
241 value: impl Into<Option<create_report::ModTool<S>>>,
242 ) -> Self {
243 self._fields.0 = value.into();
244 self
245 }
246 pub fn maybe_mod_tool(mut self, value: Option<create_report::ModTool<S>>) -> Self {
248 self._fields.0 = value;
249 self
250 }
251}
252
253impl<St: create_report_state::State, S: BosStr> CreateReportBuilder<St, S> {
254 pub fn reason(mut self, value: impl Into<Option<S>>) -> Self {
256 self._fields.1 = value.into();
257 self
258 }
259 pub fn maybe_reason(mut self, value: Option<S>) -> Self {
261 self._fields.1 = value;
262 self
263 }
264}
265
266impl<St, S: BosStr> CreateReportBuilder<St, S>
267where
268 St: create_report_state::State,
269 St::ReasonType: create_report_state::IsUnset,
270{
271 pub fn reason_type(
273 mut self,
274 value: impl Into<ReasonType<S>>,
275 ) -> CreateReportBuilder<create_report_state::SetReasonType<St>, S> {
276 self._fields.2 = Option::Some(value.into());
277 CreateReportBuilder {
278 _state: PhantomData,
279 _fields: self._fields,
280 _type: PhantomData,
281 }
282 }
283}
284
285impl<St, S: BosStr> CreateReportBuilder<St, S>
286where
287 St: create_report_state::State,
288 St::Subject: create_report_state::IsUnset,
289{
290 pub fn subject(
292 mut self,
293 value: impl Into<CreateReportSubject<S>>,
294 ) -> CreateReportBuilder<create_report_state::SetSubject<St>, S> {
295 self._fields.3 = Option::Some(value.into());
296 CreateReportBuilder {
297 _state: PhantomData,
298 _fields: self._fields,
299 _type: PhantomData,
300 }
301 }
302}
303
304impl<St, S: BosStr> CreateReportBuilder<St, S>
305where
306 St: create_report_state::State,
307 St::ReasonType: create_report_state::IsSet,
308 St::Subject: create_report_state::IsSet,
309{
310 pub fn build(self) -> CreateReport<S> {
312 CreateReport {
313 mod_tool: self._fields.0,
314 reason: self._fields.1,
315 reason_type: self._fields.2.unwrap(),
316 subject: self._fields.3.unwrap(),
317 extra_data: Default::default(),
318 }
319 }
320 pub fn build_with_data(
322 self,
323 extra_data: BTreeMap<SmolStr, Data<S>>,
324 ) -> CreateReport<S> {
325 CreateReport {
326 mod_tool: self._fields.0,
327 reason: self._fields.1,
328 reason_type: self._fields.2.unwrap(),
329 subject: self._fields.3.unwrap(),
330 extra_data: Some(extra_data),
331 }
332 }
333}
334
335fn lexicon_doc_com_atproto_moderation_createReport() -> LexiconDoc<'static> {
336 #[allow(unused_imports)]
337 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
338 use jacquard_lexicon::lexicon::*;
339 use alloc::collections::BTreeMap;
340 LexiconDoc {
341 lexicon: Lexicon::Lexicon1,
342 id: CowStr::new_static("com.atproto.moderation.createReport"),
343 defs: {
344 let mut map = BTreeMap::new();
345 map.insert(
346 SmolStr::new_static("main"),
347 LexUserType::XrpcProcedure(LexXrpcProcedure {
348 input: Some(LexXrpcBody {
349 encoding: CowStr::new_static("application/json"),
350 schema: Some(
351 LexXrpcBodySchema::Object(LexObject {
352 required: Some(
353 vec![
354 SmolStr::new_static("reasonType"),
355 SmolStr::new_static("subject")
356 ],
357 ),
358 properties: {
359 #[allow(unused_mut)]
360 let mut map = BTreeMap::new();
361 map.insert(
362 SmolStr::new_static("modTool"),
363 LexObjectProperty::Ref(LexRef {
364 r#ref: CowStr::new_static("#modTool"),
365 ..Default::default()
366 }),
367 );
368 map.insert(
369 SmolStr::new_static("reason"),
370 LexObjectProperty::String(LexString {
371 description: Some(
372 CowStr::new_static(
373 "Additional context about the content and violation.",
374 ),
375 ),
376 max_length: Some(20000usize),
377 max_graphemes: Some(2000usize),
378 ..Default::default()
379 }),
380 );
381 map.insert(
382 SmolStr::new_static("reasonType"),
383 LexObjectProperty::Ref(LexRef {
384 r#ref: CowStr::new_static(
385 "com.atproto.moderation.defs#reasonType",
386 ),
387 ..Default::default()
388 }),
389 );
390 map.insert(
391 SmolStr::new_static("subject"),
392 LexObjectProperty::Union(LexRefUnion {
393 refs: vec![
394 CowStr::new_static("com.atproto.admin.defs#repoRef"),
395 CowStr::new_static("com.atproto.repo.strongRef")
396 ],
397 ..Default::default()
398 }),
399 );
400 map
401 },
402 ..Default::default()
403 }),
404 ),
405 ..Default::default()
406 }),
407 ..Default::default()
408 }),
409 );
410 map.insert(
411 SmolStr::new_static("modTool"),
412 LexUserType::Object(LexObject {
413 description: Some(
414 CowStr::new_static(
415 "Moderation tool information for tracing the source of the action",
416 ),
417 ),
418 required: Some(vec![SmolStr::new_static("name")]),
419 properties: {
420 #[allow(unused_mut)]
421 let mut map = BTreeMap::new();
422 map.insert(
423 SmolStr::new_static("meta"),
424 LexObjectProperty::Unknown(LexUnknown {
425 ..Default::default()
426 }),
427 );
428 map.insert(
429 SmolStr::new_static("name"),
430 LexObjectProperty::String(LexString {
431 description: Some(
432 CowStr::new_static(
433 "Name/identifier of the source (e.g., 'bsky-app/android', 'bsky-web/chrome')",
434 ),
435 ),
436 ..Default::default()
437 }),
438 );
439 map
440 },
441 ..Default::default()
442 }),
443 );
444 map
445 },
446 ..Default::default()
447 }
448}