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