+413
-103
api/atproto/admindefs.go
+413
-103
api/atproto/admindefs.go
···
24
24
InvitesDisabled *bool `json:"invitesDisabled,omitempty" cborgen:"invitesDisabled,omitempty"`
25
25
}
26
26
27
-
// AdminDefs_ActionReversal is a "actionReversal" in the com.atproto.admin.defs schema.
28
-
type AdminDefs_ActionReversal struct {
29
-
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
30
-
CreatedBy string `json:"createdBy" cborgen:"createdBy"`
31
-
Reason string `json:"reason" cborgen:"reason"`
27
+
// AdminDefs_BlobView is a "blobView" in the com.atproto.admin.defs schema.
28
+
type AdminDefs_BlobView struct {
29
+
Cid string `json:"cid" cborgen:"cid"`
30
+
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
31
+
Details *AdminDefs_BlobView_Details `json:"details,omitempty" cborgen:"details,omitempty"`
32
+
MimeType string `json:"mimeType" cborgen:"mimeType"`
33
+
Moderation *AdminDefs_Moderation `json:"moderation,omitempty" cborgen:"moderation,omitempty"`
34
+
Size int64 `json:"size" cborgen:"size"`
35
+
}
36
+
37
+
type AdminDefs_BlobView_Details struct {
38
+
AdminDefs_ImageDetails *AdminDefs_ImageDetails
39
+
AdminDefs_VideoDetails *AdminDefs_VideoDetails
40
+
}
41
+
42
+
func (t *AdminDefs_BlobView_Details) MarshalJSON() ([]byte, error) {
43
+
if t.AdminDefs_ImageDetails != nil {
44
+
t.AdminDefs_ImageDetails.LexiconTypeID = "com.atproto.admin.defs#imageDetails"
45
+
return json.Marshal(t.AdminDefs_ImageDetails)
46
+
}
47
+
if t.AdminDefs_VideoDetails != nil {
48
+
t.AdminDefs_VideoDetails.LexiconTypeID = "com.atproto.admin.defs#videoDetails"
49
+
return json.Marshal(t.AdminDefs_VideoDetails)
50
+
}
51
+
return nil, fmt.Errorf("cannot marshal empty enum")
52
+
}
53
+
func (t *AdminDefs_BlobView_Details) UnmarshalJSON(b []byte) error {
54
+
typ, err := util.TypeExtract(b)
55
+
if err != nil {
56
+
return err
57
+
}
58
+
59
+
switch typ {
60
+
case "com.atproto.admin.defs#imageDetails":
61
+
t.AdminDefs_ImageDetails = new(AdminDefs_ImageDetails)
62
+
return json.Unmarshal(b, t.AdminDefs_ImageDetails)
63
+
case "com.atproto.admin.defs#videoDetails":
64
+
t.AdminDefs_VideoDetails = new(AdminDefs_VideoDetails)
65
+
return json.Unmarshal(b, t.AdminDefs_VideoDetails)
66
+
67
+
default:
68
+
return nil
69
+
}
70
+
}
71
+
72
+
// AdminDefs_ImageDetails is a "imageDetails" in the com.atproto.admin.defs schema.
73
+
//
74
+
// RECORDTYPE: AdminDefs_ImageDetails
75
+
type AdminDefs_ImageDetails struct {
76
+
LexiconTypeID string `json:"$type,const=com.atproto.admin.defs#imageDetails" cborgen:"$type,const=com.atproto.admin.defs#imageDetails"`
77
+
Height int64 `json:"height" cborgen:"height"`
78
+
Width int64 `json:"width" cborgen:"width"`
79
+
}
80
+
81
+
// AdminDefs_ModEventAcknowledge is a "modEventAcknowledge" in the com.atproto.admin.defs schema.
82
+
//
83
+
// RECORDTYPE: AdminDefs_ModEventAcknowledge
84
+
type AdminDefs_ModEventAcknowledge struct {
85
+
LexiconTypeID string `json:"$type,const=com.atproto.admin.defs#modEventAcknowledge" cborgen:"$type,const=com.atproto.admin.defs#modEventAcknowledge"`
86
+
Comment *string `json:"comment,omitempty" cborgen:"comment,omitempty"`
87
+
}
88
+
89
+
// AdminDefs_ModEventComment is a "modEventComment" in the com.atproto.admin.defs schema.
90
+
//
91
+
// # Add a comment to a subject
92
+
//
93
+
// RECORDTYPE: AdminDefs_ModEventComment
94
+
type AdminDefs_ModEventComment struct {
95
+
LexiconTypeID string `json:"$type,const=com.atproto.admin.defs#modEventComment" cborgen:"$type,const=com.atproto.admin.defs#modEventComment"`
96
+
Comment string `json:"comment" cborgen:"comment"`
97
+
// sticky: Make the comment persistent on the subject
98
+
Sticky *bool `json:"sticky,omitempty" cborgen:"sticky,omitempty"`
32
99
}
33
100
34
-
// AdminDefs_ActionView is a "actionView" in the com.atproto.admin.defs schema.
35
-
type AdminDefs_ActionView struct {
36
-
Action *string `json:"action" cborgen:"action"`
37
-
CreateLabelVals []string `json:"createLabelVals,omitempty" cborgen:"createLabelVals,omitempty"`
38
-
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
39
-
CreatedBy string `json:"createdBy" cborgen:"createdBy"`
40
-
// durationInHours: Indicates how long this action is meant to be in effect before automatically expiring.
41
-
DurationInHours *int64 `json:"durationInHours,omitempty" cborgen:"durationInHours,omitempty"`
42
-
Id int64 `json:"id" cborgen:"id"`
43
-
NegateLabelVals []string `json:"negateLabelVals,omitempty" cborgen:"negateLabelVals,omitempty"`
44
-
Reason string `json:"reason" cborgen:"reason"`
45
-
ResolvedReportIds []int64 `json:"resolvedReportIds" cborgen:"resolvedReportIds"`
46
-
Reversal *AdminDefs_ActionReversal `json:"reversal,omitempty" cborgen:"reversal,omitempty"`
47
-
Subject *AdminDefs_ActionView_Subject `json:"subject" cborgen:"subject"`
48
-
SubjectBlobCids []string `json:"subjectBlobCids" cborgen:"subjectBlobCids"`
101
+
// AdminDefs_ModEventEmail is a "modEventEmail" in the com.atproto.admin.defs schema.
102
+
//
103
+
// # Keep a log of outgoing email to a user
104
+
//
105
+
// RECORDTYPE: AdminDefs_ModEventEmail
106
+
type AdminDefs_ModEventEmail struct {
107
+
LexiconTypeID string `json:"$type,const=com.atproto.admin.defs#modEventEmail" cborgen:"$type,const=com.atproto.admin.defs#modEventEmail"`
108
+
// subjectLine: The subject line of the email sent to the user.
109
+
SubjectLine string `json:"subjectLine" cborgen:"subjectLine"`
49
110
}
50
111
51
-
// AdminDefs_ActionViewCurrent is a "actionViewCurrent" in the com.atproto.admin.defs schema.
52
-
type AdminDefs_ActionViewCurrent struct {
53
-
Action *string `json:"action" cborgen:"action"`
54
-
// durationInHours: Indicates how long this action is meant to be in effect before automatically expiring.
112
+
// AdminDefs_ModEventEscalate is a "modEventEscalate" in the com.atproto.admin.defs schema.
113
+
//
114
+
// RECORDTYPE: AdminDefs_ModEventEscalate
115
+
type AdminDefs_ModEventEscalate struct {
116
+
LexiconTypeID string `json:"$type,const=com.atproto.admin.defs#modEventEscalate" cborgen:"$type,const=com.atproto.admin.defs#modEventEscalate"`
117
+
Comment *string `json:"comment,omitempty" cborgen:"comment,omitempty"`
118
+
}
119
+
120
+
// AdminDefs_ModEventLabel is a "modEventLabel" in the com.atproto.admin.defs schema.
121
+
//
122
+
// Apply/Negate labels on a subject
123
+
//
124
+
// RECORDTYPE: AdminDefs_ModEventLabel
125
+
type AdminDefs_ModEventLabel struct {
126
+
LexiconTypeID string `json:"$type,const=com.atproto.admin.defs#modEventLabel" cborgen:"$type,const=com.atproto.admin.defs#modEventLabel"`
127
+
Comment *string `json:"comment,omitempty" cborgen:"comment,omitempty"`
128
+
CreateLabelVals []string `json:"createLabelVals" cborgen:"createLabelVals"`
129
+
NegateLabelVals []string `json:"negateLabelVals" cborgen:"negateLabelVals"`
130
+
}
131
+
132
+
// AdminDefs_ModEventMute is a "modEventMute" in the com.atproto.admin.defs schema.
133
+
//
134
+
// # Mute incoming reports on a subject
135
+
//
136
+
// RECORDTYPE: AdminDefs_ModEventMute
137
+
type AdminDefs_ModEventMute struct {
138
+
LexiconTypeID string `json:"$type,const=com.atproto.admin.defs#modEventMute" cborgen:"$type,const=com.atproto.admin.defs#modEventMute"`
139
+
Comment *string `json:"comment,omitempty" cborgen:"comment,omitempty"`
140
+
// durationInHours: Indicates how long the subject should remain muted.
141
+
DurationInHours int64 `json:"durationInHours" cborgen:"durationInHours"`
142
+
}
143
+
144
+
// AdminDefs_ModEventReport is a "modEventReport" in the com.atproto.admin.defs schema.
145
+
//
146
+
// # Report a subject
147
+
//
148
+
// RECORDTYPE: AdminDefs_ModEventReport
149
+
type AdminDefs_ModEventReport struct {
150
+
LexiconTypeID string `json:"$type,const=com.atproto.admin.defs#modEventReport" cborgen:"$type,const=com.atproto.admin.defs#modEventReport"`
151
+
Comment *string `json:"comment,omitempty" cborgen:"comment,omitempty"`
152
+
ReportType *string `json:"reportType" cborgen:"reportType"`
153
+
}
154
+
155
+
// AdminDefs_ModEventReverseTakedown is a "modEventReverseTakedown" in the com.atproto.admin.defs schema.
156
+
//
157
+
// # Revert take down action on a subject
158
+
//
159
+
// RECORDTYPE: AdminDefs_ModEventReverseTakedown
160
+
type AdminDefs_ModEventReverseTakedown struct {
161
+
LexiconTypeID string `json:"$type,const=com.atproto.admin.defs#modEventReverseTakedown" cborgen:"$type,const=com.atproto.admin.defs#modEventReverseTakedown"`
162
+
// comment: Describe reasoning behind the reversal.
163
+
Comment *string `json:"comment,omitempty" cborgen:"comment,omitempty"`
164
+
}
165
+
166
+
// AdminDefs_ModEventTakedown is a "modEventTakedown" in the com.atproto.admin.defs schema.
167
+
//
168
+
// # Take down a subject permanently or temporarily
169
+
//
170
+
// RECORDTYPE: AdminDefs_ModEventTakedown
171
+
type AdminDefs_ModEventTakedown struct {
172
+
LexiconTypeID string `json:"$type,const=com.atproto.admin.defs#modEventTakedown" cborgen:"$type,const=com.atproto.admin.defs#modEventTakedown"`
173
+
Comment *string `json:"comment,omitempty" cborgen:"comment,omitempty"`
174
+
// durationInHours: Indicates how long the takedown should be in effect before automatically expiring.
55
175
DurationInHours *int64 `json:"durationInHours,omitempty" cborgen:"durationInHours,omitempty"`
56
-
Id int64 `json:"id" cborgen:"id"`
176
+
}
177
+
178
+
// AdminDefs_ModEventUnmute is a "modEventUnmute" in the com.atproto.admin.defs schema.
179
+
//
180
+
// # Unmute action on a subject
181
+
//
182
+
// RECORDTYPE: AdminDefs_ModEventUnmute
183
+
type AdminDefs_ModEventUnmute struct {
184
+
LexiconTypeID string `json:"$type,const=com.atproto.admin.defs#modEventUnmute" cborgen:"$type,const=com.atproto.admin.defs#modEventUnmute"`
185
+
// comment: Describe reasoning behind the reversal.
186
+
Comment *string `json:"comment,omitempty" cborgen:"comment,omitempty"`
187
+
}
188
+
189
+
// AdminDefs_ModEventView is a "modEventView" in the com.atproto.admin.defs schema.
190
+
type AdminDefs_ModEventView struct {
191
+
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
192
+
CreatedBy string `json:"createdBy" cborgen:"createdBy"`
193
+
CreatorHandle *string `json:"creatorHandle,omitempty" cborgen:"creatorHandle,omitempty"`
194
+
Event *AdminDefs_ModEventView_Event `json:"event" cborgen:"event"`
195
+
Id int64 `json:"id" cborgen:"id"`
196
+
Subject *AdminDefs_ModEventView_Subject `json:"subject" cborgen:"subject"`
197
+
SubjectBlobCids []string `json:"subjectBlobCids" cborgen:"subjectBlobCids"`
198
+
SubjectHandle *string `json:"subjectHandle,omitempty" cborgen:"subjectHandle,omitempty"`
199
+
}
200
+
201
+
// AdminDefs_ModEventViewDetail is a "modEventViewDetail" in the com.atproto.admin.defs schema.
202
+
type AdminDefs_ModEventViewDetail struct {
203
+
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
204
+
CreatedBy string `json:"createdBy" cborgen:"createdBy"`
205
+
Event *AdminDefs_ModEventViewDetail_Event `json:"event" cborgen:"event"`
206
+
Id int64 `json:"id" cborgen:"id"`
207
+
Subject *AdminDefs_ModEventViewDetail_Subject `json:"subject" cborgen:"subject"`
208
+
SubjectBlobs []*AdminDefs_BlobView `json:"subjectBlobs" cborgen:"subjectBlobs"`
57
209
}
58
210
59
-
// AdminDefs_ActionViewDetail is a "actionViewDetail" in the com.atproto.admin.defs schema.
60
-
type AdminDefs_ActionViewDetail struct {
61
-
Action *string `json:"action" cborgen:"action"`
62
-
CreateLabelVals []string `json:"createLabelVals,omitempty" cborgen:"createLabelVals,omitempty"`
63
-
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
64
-
CreatedBy string `json:"createdBy" cborgen:"createdBy"`
65
-
// durationInHours: Indicates how long this action is meant to be in effect before automatically expiring.
66
-
DurationInHours *int64 `json:"durationInHours,omitempty" cborgen:"durationInHours,omitempty"`
67
-
Id int64 `json:"id" cborgen:"id"`
68
-
NegateLabelVals []string `json:"negateLabelVals,omitempty" cborgen:"negateLabelVals,omitempty"`
69
-
Reason string `json:"reason" cborgen:"reason"`
70
-
ResolvedReports []*AdminDefs_ReportView `json:"resolvedReports" cborgen:"resolvedReports"`
71
-
Reversal *AdminDefs_ActionReversal `json:"reversal,omitempty" cborgen:"reversal,omitempty"`
72
-
Subject *AdminDefs_ActionViewDetail_Subject `json:"subject" cborgen:"subject"`
73
-
SubjectBlobs []*AdminDefs_BlobView `json:"subjectBlobs" cborgen:"subjectBlobs"`
211
+
type AdminDefs_ModEventViewDetail_Event struct {
212
+
AdminDefs_ModEventTakedown *AdminDefs_ModEventTakedown
213
+
AdminDefs_ModEventReverseTakedown *AdminDefs_ModEventReverseTakedown
214
+
AdminDefs_ModEventComment *AdminDefs_ModEventComment
215
+
AdminDefs_ModEventReport *AdminDefs_ModEventReport
216
+
AdminDefs_ModEventLabel *AdminDefs_ModEventLabel
217
+
AdminDefs_ModEventAcknowledge *AdminDefs_ModEventAcknowledge
218
+
AdminDefs_ModEventEscalate *AdminDefs_ModEventEscalate
219
+
AdminDefs_ModEventMute *AdminDefs_ModEventMute
74
220
}
75
221
76
-
type AdminDefs_ActionViewDetail_Subject struct {
222
+
func (t *AdminDefs_ModEventViewDetail_Event) MarshalJSON() ([]byte, error) {
223
+
if t.AdminDefs_ModEventTakedown != nil {
224
+
t.AdminDefs_ModEventTakedown.LexiconTypeID = "com.atproto.admin.defs#modEventTakedown"
225
+
return json.Marshal(t.AdminDefs_ModEventTakedown)
226
+
}
227
+
if t.AdminDefs_ModEventReverseTakedown != nil {
228
+
t.AdminDefs_ModEventReverseTakedown.LexiconTypeID = "com.atproto.admin.defs#modEventReverseTakedown"
229
+
return json.Marshal(t.AdminDefs_ModEventReverseTakedown)
230
+
}
231
+
if t.AdminDefs_ModEventComment != nil {
232
+
t.AdminDefs_ModEventComment.LexiconTypeID = "com.atproto.admin.defs#modEventComment"
233
+
return json.Marshal(t.AdminDefs_ModEventComment)
234
+
}
235
+
if t.AdminDefs_ModEventReport != nil {
236
+
t.AdminDefs_ModEventReport.LexiconTypeID = "com.atproto.admin.defs#modEventReport"
237
+
return json.Marshal(t.AdminDefs_ModEventReport)
238
+
}
239
+
if t.AdminDefs_ModEventLabel != nil {
240
+
t.AdminDefs_ModEventLabel.LexiconTypeID = "com.atproto.admin.defs#modEventLabel"
241
+
return json.Marshal(t.AdminDefs_ModEventLabel)
242
+
}
243
+
if t.AdminDefs_ModEventAcknowledge != nil {
244
+
t.AdminDefs_ModEventAcknowledge.LexiconTypeID = "com.atproto.admin.defs#modEventAcknowledge"
245
+
return json.Marshal(t.AdminDefs_ModEventAcknowledge)
246
+
}
247
+
if t.AdminDefs_ModEventEscalate != nil {
248
+
t.AdminDefs_ModEventEscalate.LexiconTypeID = "com.atproto.admin.defs#modEventEscalate"
249
+
return json.Marshal(t.AdminDefs_ModEventEscalate)
250
+
}
251
+
if t.AdminDefs_ModEventMute != nil {
252
+
t.AdminDefs_ModEventMute.LexiconTypeID = "com.atproto.admin.defs#modEventMute"
253
+
return json.Marshal(t.AdminDefs_ModEventMute)
254
+
}
255
+
return nil, fmt.Errorf("cannot marshal empty enum")
256
+
}
257
+
func (t *AdminDefs_ModEventViewDetail_Event) UnmarshalJSON(b []byte) error {
258
+
typ, err := util.TypeExtract(b)
259
+
if err != nil {
260
+
return err
261
+
}
262
+
263
+
switch typ {
264
+
case "com.atproto.admin.defs#modEventTakedown":
265
+
t.AdminDefs_ModEventTakedown = new(AdminDefs_ModEventTakedown)
266
+
return json.Unmarshal(b, t.AdminDefs_ModEventTakedown)
267
+
case "com.atproto.admin.defs#modEventReverseTakedown":
268
+
t.AdminDefs_ModEventReverseTakedown = new(AdminDefs_ModEventReverseTakedown)
269
+
return json.Unmarshal(b, t.AdminDefs_ModEventReverseTakedown)
270
+
case "com.atproto.admin.defs#modEventComment":
271
+
t.AdminDefs_ModEventComment = new(AdminDefs_ModEventComment)
272
+
return json.Unmarshal(b, t.AdminDefs_ModEventComment)
273
+
case "com.atproto.admin.defs#modEventReport":
274
+
t.AdminDefs_ModEventReport = new(AdminDefs_ModEventReport)
275
+
return json.Unmarshal(b, t.AdminDefs_ModEventReport)
276
+
case "com.atproto.admin.defs#modEventLabel":
277
+
t.AdminDefs_ModEventLabel = new(AdminDefs_ModEventLabel)
278
+
return json.Unmarshal(b, t.AdminDefs_ModEventLabel)
279
+
case "com.atproto.admin.defs#modEventAcknowledge":
280
+
t.AdminDefs_ModEventAcknowledge = new(AdminDefs_ModEventAcknowledge)
281
+
return json.Unmarshal(b, t.AdminDefs_ModEventAcknowledge)
282
+
case "com.atproto.admin.defs#modEventEscalate":
283
+
t.AdminDefs_ModEventEscalate = new(AdminDefs_ModEventEscalate)
284
+
return json.Unmarshal(b, t.AdminDefs_ModEventEscalate)
285
+
case "com.atproto.admin.defs#modEventMute":
286
+
t.AdminDefs_ModEventMute = new(AdminDefs_ModEventMute)
287
+
return json.Unmarshal(b, t.AdminDefs_ModEventMute)
288
+
289
+
default:
290
+
return nil
291
+
}
292
+
}
293
+
294
+
type AdminDefs_ModEventViewDetail_Subject struct {
77
295
AdminDefs_RepoView *AdminDefs_RepoView
78
296
AdminDefs_RepoViewNotFound *AdminDefs_RepoViewNotFound
79
297
AdminDefs_RecordView *AdminDefs_RecordView
80
298
AdminDefs_RecordViewNotFound *AdminDefs_RecordViewNotFound
81
299
}
82
300
83
-
func (t *AdminDefs_ActionViewDetail_Subject) MarshalJSON() ([]byte, error) {
301
+
func (t *AdminDefs_ModEventViewDetail_Subject) MarshalJSON() ([]byte, error) {
84
302
if t.AdminDefs_RepoView != nil {
85
303
t.AdminDefs_RepoView.LexiconTypeID = "com.atproto.admin.defs#repoView"
86
304
return json.Marshal(t.AdminDefs_RepoView)
···
99
317
}
100
318
return nil, fmt.Errorf("cannot marshal empty enum")
101
319
}
102
-
func (t *AdminDefs_ActionViewDetail_Subject) UnmarshalJSON(b []byte) error {
320
+
func (t *AdminDefs_ModEventViewDetail_Subject) UnmarshalJSON(b []byte) error {
103
321
typ, err := util.TypeExtract(b)
104
322
if err != nil {
105
323
return err
···
124
342
}
125
343
}
126
344
127
-
type AdminDefs_ActionView_Subject struct {
128
-
AdminDefs_RepoRef *AdminDefs_RepoRef
129
-
RepoStrongRef *RepoStrongRef
345
+
type AdminDefs_ModEventView_Event struct {
346
+
AdminDefs_ModEventTakedown *AdminDefs_ModEventTakedown
347
+
AdminDefs_ModEventReverseTakedown *AdminDefs_ModEventReverseTakedown
348
+
AdminDefs_ModEventComment *AdminDefs_ModEventComment
349
+
AdminDefs_ModEventReport *AdminDefs_ModEventReport
350
+
AdminDefs_ModEventLabel *AdminDefs_ModEventLabel
351
+
AdminDefs_ModEventAcknowledge *AdminDefs_ModEventAcknowledge
352
+
AdminDefs_ModEventEscalate *AdminDefs_ModEventEscalate
353
+
AdminDefs_ModEventMute *AdminDefs_ModEventMute
354
+
AdminDefs_ModEventEmail *AdminDefs_ModEventEmail
130
355
}
131
356
132
-
func (t *AdminDefs_ActionView_Subject) MarshalJSON() ([]byte, error) {
133
-
if t.AdminDefs_RepoRef != nil {
134
-
t.AdminDefs_RepoRef.LexiconTypeID = "com.atproto.admin.defs#repoRef"
135
-
return json.Marshal(t.AdminDefs_RepoRef)
357
+
func (t *AdminDefs_ModEventView_Event) MarshalJSON() ([]byte, error) {
358
+
if t.AdminDefs_ModEventTakedown != nil {
359
+
t.AdminDefs_ModEventTakedown.LexiconTypeID = "com.atproto.admin.defs#modEventTakedown"
360
+
return json.Marshal(t.AdminDefs_ModEventTakedown)
361
+
}
362
+
if t.AdminDefs_ModEventReverseTakedown != nil {
363
+
t.AdminDefs_ModEventReverseTakedown.LexiconTypeID = "com.atproto.admin.defs#modEventReverseTakedown"
364
+
return json.Marshal(t.AdminDefs_ModEventReverseTakedown)
136
365
}
137
-
if t.RepoStrongRef != nil {
138
-
t.RepoStrongRef.LexiconTypeID = "com.atproto.repo.strongRef"
139
-
return json.Marshal(t.RepoStrongRef)
366
+
if t.AdminDefs_ModEventComment != nil {
367
+
t.AdminDefs_ModEventComment.LexiconTypeID = "com.atproto.admin.defs#modEventComment"
368
+
return json.Marshal(t.AdminDefs_ModEventComment)
369
+
}
370
+
if t.AdminDefs_ModEventReport != nil {
371
+
t.AdminDefs_ModEventReport.LexiconTypeID = "com.atproto.admin.defs#modEventReport"
372
+
return json.Marshal(t.AdminDefs_ModEventReport)
373
+
}
374
+
if t.AdminDefs_ModEventLabel != nil {
375
+
t.AdminDefs_ModEventLabel.LexiconTypeID = "com.atproto.admin.defs#modEventLabel"
376
+
return json.Marshal(t.AdminDefs_ModEventLabel)
377
+
}
378
+
if t.AdminDefs_ModEventAcknowledge != nil {
379
+
t.AdminDefs_ModEventAcknowledge.LexiconTypeID = "com.atproto.admin.defs#modEventAcknowledge"
380
+
return json.Marshal(t.AdminDefs_ModEventAcknowledge)
381
+
}
382
+
if t.AdminDefs_ModEventEscalate != nil {
383
+
t.AdminDefs_ModEventEscalate.LexiconTypeID = "com.atproto.admin.defs#modEventEscalate"
384
+
return json.Marshal(t.AdminDefs_ModEventEscalate)
385
+
}
386
+
if t.AdminDefs_ModEventMute != nil {
387
+
t.AdminDefs_ModEventMute.LexiconTypeID = "com.atproto.admin.defs#modEventMute"
388
+
return json.Marshal(t.AdminDefs_ModEventMute)
389
+
}
390
+
if t.AdminDefs_ModEventEmail != nil {
391
+
t.AdminDefs_ModEventEmail.LexiconTypeID = "com.atproto.admin.defs#modEventEmail"
392
+
return json.Marshal(t.AdminDefs_ModEventEmail)
140
393
}
141
394
return nil, fmt.Errorf("cannot marshal empty enum")
142
395
}
143
-
func (t *AdminDefs_ActionView_Subject) UnmarshalJSON(b []byte) error {
396
+
func (t *AdminDefs_ModEventView_Event) UnmarshalJSON(b []byte) error {
144
397
typ, err := util.TypeExtract(b)
145
398
if err != nil {
146
399
return err
147
400
}
148
401
149
402
switch typ {
150
-
case "com.atproto.admin.defs#repoRef":
151
-
t.AdminDefs_RepoRef = new(AdminDefs_RepoRef)
152
-
return json.Unmarshal(b, t.AdminDefs_RepoRef)
153
-
case "com.atproto.repo.strongRef":
154
-
t.RepoStrongRef = new(RepoStrongRef)
155
-
return json.Unmarshal(b, t.RepoStrongRef)
403
+
case "com.atproto.admin.defs#modEventTakedown":
404
+
t.AdminDefs_ModEventTakedown = new(AdminDefs_ModEventTakedown)
405
+
return json.Unmarshal(b, t.AdminDefs_ModEventTakedown)
406
+
case "com.atproto.admin.defs#modEventReverseTakedown":
407
+
t.AdminDefs_ModEventReverseTakedown = new(AdminDefs_ModEventReverseTakedown)
408
+
return json.Unmarshal(b, t.AdminDefs_ModEventReverseTakedown)
409
+
case "com.atproto.admin.defs#modEventComment":
410
+
t.AdminDefs_ModEventComment = new(AdminDefs_ModEventComment)
411
+
return json.Unmarshal(b, t.AdminDefs_ModEventComment)
412
+
case "com.atproto.admin.defs#modEventReport":
413
+
t.AdminDefs_ModEventReport = new(AdminDefs_ModEventReport)
414
+
return json.Unmarshal(b, t.AdminDefs_ModEventReport)
415
+
case "com.atproto.admin.defs#modEventLabel":
416
+
t.AdminDefs_ModEventLabel = new(AdminDefs_ModEventLabel)
417
+
return json.Unmarshal(b, t.AdminDefs_ModEventLabel)
418
+
case "com.atproto.admin.defs#modEventAcknowledge":
419
+
t.AdminDefs_ModEventAcknowledge = new(AdminDefs_ModEventAcknowledge)
420
+
return json.Unmarshal(b, t.AdminDefs_ModEventAcknowledge)
421
+
case "com.atproto.admin.defs#modEventEscalate":
422
+
t.AdminDefs_ModEventEscalate = new(AdminDefs_ModEventEscalate)
423
+
return json.Unmarshal(b, t.AdminDefs_ModEventEscalate)
424
+
case "com.atproto.admin.defs#modEventMute":
425
+
t.AdminDefs_ModEventMute = new(AdminDefs_ModEventMute)
426
+
return json.Unmarshal(b, t.AdminDefs_ModEventMute)
427
+
case "com.atproto.admin.defs#modEventEmail":
428
+
t.AdminDefs_ModEventEmail = new(AdminDefs_ModEventEmail)
429
+
return json.Unmarshal(b, t.AdminDefs_ModEventEmail)
156
430
157
431
default:
158
432
return nil
159
433
}
160
434
}
161
435
162
-
// AdminDefs_BlobView is a "blobView" in the com.atproto.admin.defs schema.
163
-
type AdminDefs_BlobView struct {
164
-
Cid string `json:"cid" cborgen:"cid"`
165
-
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
166
-
Details *AdminDefs_BlobView_Details `json:"details,omitempty" cborgen:"details,omitempty"`
167
-
MimeType string `json:"mimeType" cborgen:"mimeType"`
168
-
Moderation *AdminDefs_Moderation `json:"moderation,omitempty" cborgen:"moderation,omitempty"`
169
-
Size int64 `json:"size" cborgen:"size"`
436
+
type AdminDefs_ModEventView_Subject struct {
437
+
AdminDefs_RepoRef *AdminDefs_RepoRef
438
+
RepoStrongRef *RepoStrongRef
170
439
}
171
440
172
-
type AdminDefs_BlobView_Details struct {
173
-
AdminDefs_ImageDetails *AdminDefs_ImageDetails
174
-
AdminDefs_VideoDetails *AdminDefs_VideoDetails
175
-
}
176
-
177
-
func (t *AdminDefs_BlobView_Details) MarshalJSON() ([]byte, error) {
178
-
if t.AdminDefs_ImageDetails != nil {
179
-
t.AdminDefs_ImageDetails.LexiconTypeID = "com.atproto.admin.defs#imageDetails"
180
-
return json.Marshal(t.AdminDefs_ImageDetails)
441
+
func (t *AdminDefs_ModEventView_Subject) MarshalJSON() ([]byte, error) {
442
+
if t.AdminDefs_RepoRef != nil {
443
+
t.AdminDefs_RepoRef.LexiconTypeID = "com.atproto.admin.defs#repoRef"
444
+
return json.Marshal(t.AdminDefs_RepoRef)
181
445
}
182
-
if t.AdminDefs_VideoDetails != nil {
183
-
t.AdminDefs_VideoDetails.LexiconTypeID = "com.atproto.admin.defs#videoDetails"
184
-
return json.Marshal(t.AdminDefs_VideoDetails)
446
+
if t.RepoStrongRef != nil {
447
+
t.RepoStrongRef.LexiconTypeID = "com.atproto.repo.strongRef"
448
+
return json.Marshal(t.RepoStrongRef)
185
449
}
186
450
return nil, fmt.Errorf("cannot marshal empty enum")
187
451
}
188
-
func (t *AdminDefs_BlobView_Details) UnmarshalJSON(b []byte) error {
452
+
func (t *AdminDefs_ModEventView_Subject) UnmarshalJSON(b []byte) error {
189
453
typ, err := util.TypeExtract(b)
190
454
if err != nil {
191
455
return err
192
456
}
193
457
194
458
switch typ {
195
-
case "com.atproto.admin.defs#imageDetails":
196
-
t.AdminDefs_ImageDetails = new(AdminDefs_ImageDetails)
197
-
return json.Unmarshal(b, t.AdminDefs_ImageDetails)
198
-
case "com.atproto.admin.defs#videoDetails":
199
-
t.AdminDefs_VideoDetails = new(AdminDefs_VideoDetails)
200
-
return json.Unmarshal(b, t.AdminDefs_VideoDetails)
459
+
case "com.atproto.admin.defs#repoRef":
460
+
t.AdminDefs_RepoRef = new(AdminDefs_RepoRef)
461
+
return json.Unmarshal(b, t.AdminDefs_RepoRef)
462
+
case "com.atproto.repo.strongRef":
463
+
t.RepoStrongRef = new(RepoStrongRef)
464
+
return json.Unmarshal(b, t.RepoStrongRef)
201
465
202
466
default:
203
467
return nil
204
468
}
205
469
}
206
470
207
-
// AdminDefs_ImageDetails is a "imageDetails" in the com.atproto.admin.defs schema.
208
-
//
209
-
// RECORDTYPE: AdminDefs_ImageDetails
210
-
type AdminDefs_ImageDetails struct {
211
-
LexiconTypeID string `json:"$type,const=com.atproto.admin.defs#imageDetails" cborgen:"$type,const=com.atproto.admin.defs#imageDetails"`
212
-
Height int64 `json:"height" cborgen:"height"`
213
-
Width int64 `json:"width" cborgen:"width"`
214
-
}
215
-
216
471
// AdminDefs_Moderation is a "moderation" in the com.atproto.admin.defs schema.
217
472
type AdminDefs_Moderation struct {
218
-
CurrentAction *AdminDefs_ActionViewCurrent `json:"currentAction,omitempty" cborgen:"currentAction,omitempty"`
473
+
SubjectStatus *AdminDefs_SubjectStatusView `json:"subjectStatus,omitempty" cborgen:"subjectStatus,omitempty"`
219
474
}
220
475
221
476
// AdminDefs_ModerationDetail is a "moderationDetail" in the com.atproto.admin.defs schema.
222
477
type AdminDefs_ModerationDetail struct {
223
-
Actions []*AdminDefs_ActionView `json:"actions" cborgen:"actions"`
224
-
CurrentAction *AdminDefs_ActionViewCurrent `json:"currentAction,omitempty" cborgen:"currentAction,omitempty"`
225
-
Reports []*AdminDefs_ReportView `json:"reports" cborgen:"reports"`
478
+
SubjectStatus *AdminDefs_SubjectStatusView `json:"subjectStatus,omitempty" cborgen:"subjectStatus,omitempty"`
226
479
}
227
480
228
481
// AdminDefs_RecordView is a "recordView" in the com.atproto.admin.defs schema.
···
319
572
320
573
// AdminDefs_ReportView is a "reportView" in the com.atproto.admin.defs schema.
321
574
type AdminDefs_ReportView struct {
575
+
Comment *string `json:"comment,omitempty" cborgen:"comment,omitempty"`
322
576
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
323
577
Id int64 `json:"id" cborgen:"id"`
324
-
Reason *string `json:"reason,omitempty" cborgen:"reason,omitempty"`
325
578
ReasonType *string `json:"reasonType" cborgen:"reasonType"`
326
579
ReportedBy string `json:"reportedBy" cborgen:"reportedBy"`
327
580
ResolvedByActionIds []int64 `json:"resolvedByActionIds" cborgen:"resolvedByActionIds"`
···
331
584
332
585
// AdminDefs_ReportViewDetail is a "reportViewDetail" in the com.atproto.admin.defs schema.
333
586
type AdminDefs_ReportViewDetail struct {
587
+
Comment *string `json:"comment,omitempty" cborgen:"comment,omitempty"`
334
588
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
335
589
Id int64 `json:"id" cborgen:"id"`
336
-
Reason *string `json:"reason,omitempty" cborgen:"reason,omitempty"`
337
590
ReasonType *string `json:"reasonType" cborgen:"reasonType"`
338
591
ReportedBy string `json:"reportedBy" cborgen:"reportedBy"`
339
-
ResolvedByActions []*AdminDefs_ActionView `json:"resolvedByActions" cborgen:"resolvedByActions"`
592
+
ResolvedByActions []*AdminDefs_ModEventView `json:"resolvedByActions" cborgen:"resolvedByActions"`
340
593
Subject *AdminDefs_ReportViewDetail_Subject `json:"subject" cborgen:"subject"`
594
+
SubjectStatus *AdminDefs_SubjectStatusView `json:"subjectStatus,omitempty" cborgen:"subjectStatus,omitempty"`
341
595
}
342
596
343
597
type AdminDefs_ReportViewDetail_Subject struct {
···
430
684
type AdminDefs_StatusAttr struct {
431
685
Applied bool `json:"applied" cborgen:"applied"`
432
686
Ref *string `json:"ref,omitempty" cborgen:"ref,omitempty"`
687
+
}
688
+
689
+
// AdminDefs_SubjectStatusView is a "subjectStatusView" in the com.atproto.admin.defs schema.
690
+
type AdminDefs_SubjectStatusView struct {
691
+
// comment: Sticky comment on the subject.
692
+
Comment *string `json:"comment,omitempty" cborgen:"comment,omitempty"`
693
+
// createdAt: Timestamp referencing the first moderation status impacting event was emitted on the subject
694
+
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
695
+
Id int64 `json:"id" cborgen:"id"`
696
+
LastReportedAt *string `json:"lastReportedAt,omitempty" cborgen:"lastReportedAt,omitempty"`
697
+
LastReviewedAt *string `json:"lastReviewedAt,omitempty" cborgen:"lastReviewedAt,omitempty"`
698
+
LastReviewedBy *string `json:"lastReviewedBy,omitempty" cborgen:"lastReviewedBy,omitempty"`
699
+
MuteUntil *string `json:"muteUntil,omitempty" cborgen:"muteUntil,omitempty"`
700
+
ReviewState *string `json:"reviewState" cborgen:"reviewState"`
701
+
Subject *AdminDefs_SubjectStatusView_Subject `json:"subject" cborgen:"subject"`
702
+
SubjectBlobCids []string `json:"subjectBlobCids,omitempty" cborgen:"subjectBlobCids,omitempty"`
703
+
SubjectRepoHandle *string `json:"subjectRepoHandle,omitempty" cborgen:"subjectRepoHandle,omitempty"`
704
+
SuspendUntil *string `json:"suspendUntil,omitempty" cborgen:"suspendUntil,omitempty"`
705
+
Takendown *bool `json:"takendown,omitempty" cborgen:"takendown,omitempty"`
706
+
// updatedAt: Timestamp referencing when the last update was made to the moderation status of the subject
707
+
UpdatedAt string `json:"updatedAt" cborgen:"updatedAt"`
708
+
}
709
+
710
+
type AdminDefs_SubjectStatusView_Subject struct {
711
+
AdminDefs_RepoRef *AdminDefs_RepoRef
712
+
RepoStrongRef *RepoStrongRef
713
+
}
714
+
715
+
func (t *AdminDefs_SubjectStatusView_Subject) MarshalJSON() ([]byte, error) {
716
+
if t.AdminDefs_RepoRef != nil {
717
+
t.AdminDefs_RepoRef.LexiconTypeID = "com.atproto.admin.defs#repoRef"
718
+
return json.Marshal(t.AdminDefs_RepoRef)
719
+
}
720
+
if t.RepoStrongRef != nil {
721
+
t.RepoStrongRef.LexiconTypeID = "com.atproto.repo.strongRef"
722
+
return json.Marshal(t.RepoStrongRef)
723
+
}
724
+
return nil, fmt.Errorf("cannot marshal empty enum")
725
+
}
726
+
func (t *AdminDefs_SubjectStatusView_Subject) UnmarshalJSON(b []byte) error {
727
+
typ, err := util.TypeExtract(b)
728
+
if err != nil {
729
+
return err
730
+
}
731
+
732
+
switch typ {
733
+
case "com.atproto.admin.defs#repoRef":
734
+
t.AdminDefs_RepoRef = new(AdminDefs_RepoRef)
735
+
return json.Unmarshal(b, t.AdminDefs_RepoRef)
736
+
case "com.atproto.repo.strongRef":
737
+
t.RepoStrongRef = new(RepoStrongRef)
738
+
return json.Unmarshal(b, t.RepoStrongRef)
739
+
740
+
default:
741
+
return nil
742
+
}
433
743
}
434
744
435
745
// AdminDefs_VideoDetails is a "videoDetails" in the com.atproto.admin.defs schema.
+166
api/atproto/adminemitModerationEvent.go
+166
api/atproto/adminemitModerationEvent.go
···
1
+
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
+
3
+
package atproto
4
+
5
+
// schema: com.atproto.admin.emitModerationEvent
6
+
7
+
import (
8
+
"context"
9
+
"encoding/json"
10
+
"fmt"
11
+
12
+
"github.com/bluesky-social/indigo/lex/util"
13
+
"github.com/bluesky-social/indigo/xrpc"
14
+
)
15
+
16
+
// AdminEmitModerationEvent_Input is the input argument to a com.atproto.admin.emitModerationEvent call.
17
+
type AdminEmitModerationEvent_Input struct {
18
+
CreatedBy string `json:"createdBy" cborgen:"createdBy"`
19
+
Event *AdminEmitModerationEvent_Input_Event `json:"event" cborgen:"event"`
20
+
Subject *AdminEmitModerationEvent_Input_Subject `json:"subject" cborgen:"subject"`
21
+
SubjectBlobCids []string `json:"subjectBlobCids,omitempty" cborgen:"subjectBlobCids,omitempty"`
22
+
}
23
+
24
+
type AdminEmitModerationEvent_Input_Event struct {
25
+
AdminDefs_ModEventTakedown *AdminDefs_ModEventTakedown
26
+
AdminDefs_ModEventAcknowledge *AdminDefs_ModEventAcknowledge
27
+
AdminDefs_ModEventEscalate *AdminDefs_ModEventEscalate
28
+
AdminDefs_ModEventComment *AdminDefs_ModEventComment
29
+
AdminDefs_ModEventLabel *AdminDefs_ModEventLabel
30
+
AdminDefs_ModEventReport *AdminDefs_ModEventReport
31
+
AdminDefs_ModEventMute *AdminDefs_ModEventMute
32
+
AdminDefs_ModEventReverseTakedown *AdminDefs_ModEventReverseTakedown
33
+
AdminDefs_ModEventUnmute *AdminDefs_ModEventUnmute
34
+
AdminDefs_ModEventEmail *AdminDefs_ModEventEmail
35
+
}
36
+
37
+
func (t *AdminEmitModerationEvent_Input_Event) MarshalJSON() ([]byte, error) {
38
+
if t.AdminDefs_ModEventTakedown != nil {
39
+
t.AdminDefs_ModEventTakedown.LexiconTypeID = "com.atproto.admin.defs#modEventTakedown"
40
+
return json.Marshal(t.AdminDefs_ModEventTakedown)
41
+
}
42
+
if t.AdminDefs_ModEventAcknowledge != nil {
43
+
t.AdminDefs_ModEventAcknowledge.LexiconTypeID = "com.atproto.admin.defs#modEventAcknowledge"
44
+
return json.Marshal(t.AdminDefs_ModEventAcknowledge)
45
+
}
46
+
if t.AdminDefs_ModEventEscalate != nil {
47
+
t.AdminDefs_ModEventEscalate.LexiconTypeID = "com.atproto.admin.defs#modEventEscalate"
48
+
return json.Marshal(t.AdminDefs_ModEventEscalate)
49
+
}
50
+
if t.AdminDefs_ModEventComment != nil {
51
+
t.AdminDefs_ModEventComment.LexiconTypeID = "com.atproto.admin.defs#modEventComment"
52
+
return json.Marshal(t.AdminDefs_ModEventComment)
53
+
}
54
+
if t.AdminDefs_ModEventLabel != nil {
55
+
t.AdminDefs_ModEventLabel.LexiconTypeID = "com.atproto.admin.defs#modEventLabel"
56
+
return json.Marshal(t.AdminDefs_ModEventLabel)
57
+
}
58
+
if t.AdminDefs_ModEventReport != nil {
59
+
t.AdminDefs_ModEventReport.LexiconTypeID = "com.atproto.admin.defs#modEventReport"
60
+
return json.Marshal(t.AdminDefs_ModEventReport)
61
+
}
62
+
if t.AdminDefs_ModEventMute != nil {
63
+
t.AdminDefs_ModEventMute.LexiconTypeID = "com.atproto.admin.defs#modEventMute"
64
+
return json.Marshal(t.AdminDefs_ModEventMute)
65
+
}
66
+
if t.AdminDefs_ModEventReverseTakedown != nil {
67
+
t.AdminDefs_ModEventReverseTakedown.LexiconTypeID = "com.atproto.admin.defs#modEventReverseTakedown"
68
+
return json.Marshal(t.AdminDefs_ModEventReverseTakedown)
69
+
}
70
+
if t.AdminDefs_ModEventUnmute != nil {
71
+
t.AdminDefs_ModEventUnmute.LexiconTypeID = "com.atproto.admin.defs#modEventUnmute"
72
+
return json.Marshal(t.AdminDefs_ModEventUnmute)
73
+
}
74
+
if t.AdminDefs_ModEventEmail != nil {
75
+
t.AdminDefs_ModEventEmail.LexiconTypeID = "com.atproto.admin.defs#modEventEmail"
76
+
return json.Marshal(t.AdminDefs_ModEventEmail)
77
+
}
78
+
return nil, fmt.Errorf("cannot marshal empty enum")
79
+
}
80
+
func (t *AdminEmitModerationEvent_Input_Event) UnmarshalJSON(b []byte) error {
81
+
typ, err := util.TypeExtract(b)
82
+
if err != nil {
83
+
return err
84
+
}
85
+
86
+
switch typ {
87
+
case "com.atproto.admin.defs#modEventTakedown":
88
+
t.AdminDefs_ModEventTakedown = new(AdminDefs_ModEventTakedown)
89
+
return json.Unmarshal(b, t.AdminDefs_ModEventTakedown)
90
+
case "com.atproto.admin.defs#modEventAcknowledge":
91
+
t.AdminDefs_ModEventAcknowledge = new(AdminDefs_ModEventAcknowledge)
92
+
return json.Unmarshal(b, t.AdminDefs_ModEventAcknowledge)
93
+
case "com.atproto.admin.defs#modEventEscalate":
94
+
t.AdminDefs_ModEventEscalate = new(AdminDefs_ModEventEscalate)
95
+
return json.Unmarshal(b, t.AdminDefs_ModEventEscalate)
96
+
case "com.atproto.admin.defs#modEventComment":
97
+
t.AdminDefs_ModEventComment = new(AdminDefs_ModEventComment)
98
+
return json.Unmarshal(b, t.AdminDefs_ModEventComment)
99
+
case "com.atproto.admin.defs#modEventLabel":
100
+
t.AdminDefs_ModEventLabel = new(AdminDefs_ModEventLabel)
101
+
return json.Unmarshal(b, t.AdminDefs_ModEventLabel)
102
+
case "com.atproto.admin.defs#modEventReport":
103
+
t.AdminDefs_ModEventReport = new(AdminDefs_ModEventReport)
104
+
return json.Unmarshal(b, t.AdminDefs_ModEventReport)
105
+
case "com.atproto.admin.defs#modEventMute":
106
+
t.AdminDefs_ModEventMute = new(AdminDefs_ModEventMute)
107
+
return json.Unmarshal(b, t.AdminDefs_ModEventMute)
108
+
case "com.atproto.admin.defs#modEventReverseTakedown":
109
+
t.AdminDefs_ModEventReverseTakedown = new(AdminDefs_ModEventReverseTakedown)
110
+
return json.Unmarshal(b, t.AdminDefs_ModEventReverseTakedown)
111
+
case "com.atproto.admin.defs#modEventUnmute":
112
+
t.AdminDefs_ModEventUnmute = new(AdminDefs_ModEventUnmute)
113
+
return json.Unmarshal(b, t.AdminDefs_ModEventUnmute)
114
+
case "com.atproto.admin.defs#modEventEmail":
115
+
t.AdminDefs_ModEventEmail = new(AdminDefs_ModEventEmail)
116
+
return json.Unmarshal(b, t.AdminDefs_ModEventEmail)
117
+
118
+
default:
119
+
return nil
120
+
}
121
+
}
122
+
123
+
type AdminEmitModerationEvent_Input_Subject struct {
124
+
AdminDefs_RepoRef *AdminDefs_RepoRef
125
+
RepoStrongRef *RepoStrongRef
126
+
}
127
+
128
+
func (t *AdminEmitModerationEvent_Input_Subject) MarshalJSON() ([]byte, error) {
129
+
if t.AdminDefs_RepoRef != nil {
130
+
t.AdminDefs_RepoRef.LexiconTypeID = "com.atproto.admin.defs#repoRef"
131
+
return json.Marshal(t.AdminDefs_RepoRef)
132
+
}
133
+
if t.RepoStrongRef != nil {
134
+
t.RepoStrongRef.LexiconTypeID = "com.atproto.repo.strongRef"
135
+
return json.Marshal(t.RepoStrongRef)
136
+
}
137
+
return nil, fmt.Errorf("cannot marshal empty enum")
138
+
}
139
+
func (t *AdminEmitModerationEvent_Input_Subject) UnmarshalJSON(b []byte) error {
140
+
typ, err := util.TypeExtract(b)
141
+
if err != nil {
142
+
return err
143
+
}
144
+
145
+
switch typ {
146
+
case "com.atproto.admin.defs#repoRef":
147
+
t.AdminDefs_RepoRef = new(AdminDefs_RepoRef)
148
+
return json.Unmarshal(b, t.AdminDefs_RepoRef)
149
+
case "com.atproto.repo.strongRef":
150
+
t.RepoStrongRef = new(RepoStrongRef)
151
+
return json.Unmarshal(b, t.RepoStrongRef)
152
+
153
+
default:
154
+
return nil
155
+
}
156
+
}
157
+
158
+
// AdminEmitModerationEvent calls the XRPC method "com.atproto.admin.emitModerationEvent".
159
+
func AdminEmitModerationEvent(ctx context.Context, c *xrpc.Client, input *AdminEmitModerationEvent_Input) (*AdminDefs_ModEventView, error) {
160
+
var out AdminDefs_ModEventView
161
+
if err := c.Do(ctx, xrpc.Procedure, "application/json", "com.atproto.admin.emitModerationEvent", nil, input, &out); err != nil {
162
+
return nil, err
163
+
}
164
+
165
+
return &out, nil
166
+
}
-25
api/atproto/admingetModerationAction.go
-25
api/atproto/admingetModerationAction.go
···
1
-
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
-
3
-
package atproto
4
-
5
-
// schema: com.atproto.admin.getModerationAction
6
-
7
-
import (
8
-
"context"
9
-
10
-
"github.com/bluesky-social/indigo/xrpc"
11
-
)
12
-
13
-
// AdminGetModerationAction calls the XRPC method "com.atproto.admin.getModerationAction".
14
-
func AdminGetModerationAction(ctx context.Context, c *xrpc.Client, id int64) (*AdminDefs_ActionViewDetail, error) {
15
-
var out AdminDefs_ActionViewDetail
16
-
17
-
params := map[string]interface{}{
18
-
"id": id,
19
-
}
20
-
if err := c.Do(ctx, xrpc.Query, "", "com.atproto.admin.getModerationAction", params, nil, &out); err != nil {
21
-
return nil, err
22
-
}
23
-
24
-
return &out, nil
25
-
}
-33
api/atproto/admingetModerationActions.go
-33
api/atproto/admingetModerationActions.go
···
1
-
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
-
3
-
package atproto
4
-
5
-
// schema: com.atproto.admin.getModerationActions
6
-
7
-
import (
8
-
"context"
9
-
10
-
"github.com/bluesky-social/indigo/xrpc"
11
-
)
12
-
13
-
// AdminGetModerationActions_Output is the output of a com.atproto.admin.getModerationActions call.
14
-
type AdminGetModerationActions_Output struct {
15
-
Actions []*AdminDefs_ActionView `json:"actions" cborgen:"actions"`
16
-
Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
17
-
}
18
-
19
-
// AdminGetModerationActions calls the XRPC method "com.atproto.admin.getModerationActions".
20
-
func AdminGetModerationActions(ctx context.Context, c *xrpc.Client, cursor string, limit int64, subject string) (*AdminGetModerationActions_Output, error) {
21
-
var out AdminGetModerationActions_Output
22
-
23
-
params := map[string]interface{}{
24
-
"cursor": cursor,
25
-
"limit": limit,
26
-
"subject": subject,
27
-
}
28
-
if err := c.Do(ctx, xrpc.Query, "", "com.atproto.admin.getModerationActions", params, nil, &out); err != nil {
29
-
return nil, err
30
-
}
31
-
32
-
return &out, nil
33
-
}
+25
api/atproto/admingetModerationEvent.go
+25
api/atproto/admingetModerationEvent.go
···
1
+
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
+
3
+
package atproto
4
+
5
+
// schema: com.atproto.admin.getModerationEvent
6
+
7
+
import (
8
+
"context"
9
+
10
+
"github.com/bluesky-social/indigo/xrpc"
11
+
)
12
+
13
+
// AdminGetModerationEvent calls the XRPC method "com.atproto.admin.getModerationEvent".
14
+
func AdminGetModerationEvent(ctx context.Context, c *xrpc.Client, id int64) (*AdminDefs_ModEventViewDetail, error) {
15
+
var out AdminDefs_ModEventViewDetail
16
+
17
+
params := map[string]interface{}{
18
+
"id": id,
19
+
}
20
+
if err := c.Do(ctx, xrpc.Query, "", "com.atproto.admin.getModerationEvent", params, nil, &out); err != nil {
21
+
return nil, err
22
+
}
23
+
24
+
return &out, nil
25
+
}
-25
api/atproto/admingetModerationReport.go
-25
api/atproto/admingetModerationReport.go
···
1
-
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
-
3
-
package atproto
4
-
5
-
// schema: com.atproto.admin.getModerationReport
6
-
7
-
import (
8
-
"context"
9
-
10
-
"github.com/bluesky-social/indigo/xrpc"
11
-
)
12
-
13
-
// AdminGetModerationReport calls the XRPC method "com.atproto.admin.getModerationReport".
14
-
func AdminGetModerationReport(ctx context.Context, c *xrpc.Client, id int64) (*AdminDefs_ReportViewDetail, error) {
15
-
var out AdminDefs_ReportViewDetail
16
-
17
-
params := map[string]interface{}{
18
-
"id": id,
19
-
}
20
-
if err := c.Do(ctx, xrpc.Query, "", "com.atproto.admin.getModerationReport", params, nil, &out); err != nil {
21
-
return nil, err
22
-
}
23
-
24
-
return &out, nil
25
-
}
-43
api/atproto/admingetModerationReports.go
-43
api/atproto/admingetModerationReports.go
···
1
-
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
-
3
-
package atproto
4
-
5
-
// schema: com.atproto.admin.getModerationReports
6
-
7
-
import (
8
-
"context"
9
-
10
-
"github.com/bluesky-social/indigo/xrpc"
11
-
)
12
-
13
-
// AdminGetModerationReports_Output is the output of a com.atproto.admin.getModerationReports call.
14
-
type AdminGetModerationReports_Output struct {
15
-
Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
16
-
Reports []*AdminDefs_ReportView `json:"reports" cborgen:"reports"`
17
-
}
18
-
19
-
// AdminGetModerationReports calls the XRPC method "com.atproto.admin.getModerationReports".
20
-
//
21
-
// actionedBy: Get all reports that were actioned by a specific moderator.
22
-
// reporters: Filter reports made by one or more DIDs.
23
-
// reverse: Reverse the order of the returned records. When true, returns reports in chronological order.
24
-
func AdminGetModerationReports(ctx context.Context, c *xrpc.Client, actionType string, actionedBy string, cursor string, ignoreSubjects []string, limit int64, reporters []string, resolved bool, reverse bool, subject string) (*AdminGetModerationReports_Output, error) {
25
-
var out AdminGetModerationReports_Output
26
-
27
-
params := map[string]interface{}{
28
-
"actionType": actionType,
29
-
"actionedBy": actionedBy,
30
-
"cursor": cursor,
31
-
"ignoreSubjects": ignoreSubjects,
32
-
"limit": limit,
33
-
"reporters": reporters,
34
-
"resolved": resolved,
35
-
"reverse": reverse,
36
-
"subject": subject,
37
-
}
38
-
if err := c.Do(ctx, xrpc.Query, "", "com.atproto.admin.getModerationReports", params, nil, &out); err != nil {
39
-
return nil, err
40
-
}
41
-
42
-
return &out, nil
43
-
}
+41
api/atproto/adminqueryModerationEvents.go
+41
api/atproto/adminqueryModerationEvents.go
···
1
+
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
+
3
+
package atproto
4
+
5
+
// schema: com.atproto.admin.queryModerationEvents
6
+
7
+
import (
8
+
"context"
9
+
10
+
"github.com/bluesky-social/indigo/xrpc"
11
+
)
12
+
13
+
// AdminQueryModerationEvents_Output is the output of a com.atproto.admin.queryModerationEvents call.
14
+
type AdminQueryModerationEvents_Output struct {
15
+
Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
16
+
Events []*AdminDefs_ModEventView `json:"events" cborgen:"events"`
17
+
}
18
+
19
+
// AdminQueryModerationEvents calls the XRPC method "com.atproto.admin.queryModerationEvents".
20
+
//
21
+
// includeAllUserRecords: If true, events on all record types (posts, lists, profile etc.) owned by the did are returned
22
+
// sortDirection: Sort direction for the events. Defaults to descending order of created at timestamp.
23
+
// types: The types of events (fully qualified string in the format of com.atproto.admin#modEvent<name>) to filter by. If not specified, all events are returned.
24
+
func AdminQueryModerationEvents(ctx context.Context, c *xrpc.Client, createdBy string, cursor string, includeAllUserRecords bool, limit int64, sortDirection string, subject string, types []string) (*AdminQueryModerationEvents_Output, error) {
25
+
var out AdminQueryModerationEvents_Output
26
+
27
+
params := map[string]interface{}{
28
+
"createdBy": createdBy,
29
+
"cursor": cursor,
30
+
"includeAllUserRecords": includeAllUserRecords,
31
+
"limit": limit,
32
+
"sortDirection": sortDirection,
33
+
"subject": subject,
34
+
"types": types,
35
+
}
36
+
if err := c.Do(ctx, xrpc.Query, "", "com.atproto.admin.queryModerationEvents", params, nil, &out); err != nil {
37
+
return nil, err
38
+
}
39
+
40
+
return &out, nil
41
+
}
+55
api/atproto/adminqueryModerationStatuses.go
+55
api/atproto/adminqueryModerationStatuses.go
···
1
+
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
+
3
+
package atproto
4
+
5
+
// schema: com.atproto.admin.queryModerationStatuses
6
+
7
+
import (
8
+
"context"
9
+
10
+
"github.com/bluesky-social/indigo/xrpc"
11
+
)
12
+
13
+
// AdminQueryModerationStatuses_Output is the output of a com.atproto.admin.queryModerationStatuses call.
14
+
type AdminQueryModerationStatuses_Output struct {
15
+
Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
16
+
SubjectStatuses []*AdminDefs_SubjectStatusView `json:"subjectStatuses" cborgen:"subjectStatuses"`
17
+
}
18
+
19
+
// AdminQueryModerationStatuses calls the XRPC method "com.atproto.admin.queryModerationStatuses".
20
+
//
21
+
// comment: Search subjects by keyword from comments
22
+
// includeMuted: By default, we don't include muted subjects in the results. Set this to true to include them.
23
+
// lastReviewedBy: Get all subject statuses that were reviewed by a specific moderator
24
+
// reportedAfter: Search subjects reported after a given timestamp
25
+
// reportedBefore: Search subjects reported before a given timestamp
26
+
// reviewState: Specify when fetching subjects in a certain state
27
+
// reviewedAfter: Search subjects reviewed after a given timestamp
28
+
// reviewedBefore: Search subjects reviewed before a given timestamp
29
+
// takendown: Get subjects that were taken down
30
+
func AdminQueryModerationStatuses(ctx context.Context, c *xrpc.Client, comment string, cursor string, ignoreSubjects []string, includeMuted bool, lastReviewedBy string, limit int64, reportedAfter string, reportedBefore string, reviewState string, reviewedAfter string, reviewedBefore string, sortDirection string, sortField string, subject string, takendown bool) (*AdminQueryModerationStatuses_Output, error) {
31
+
var out AdminQueryModerationStatuses_Output
32
+
33
+
params := map[string]interface{}{
34
+
"comment": comment,
35
+
"cursor": cursor,
36
+
"ignoreSubjects": ignoreSubjects,
37
+
"includeMuted": includeMuted,
38
+
"lastReviewedBy": lastReviewedBy,
39
+
"limit": limit,
40
+
"reportedAfter": reportedAfter,
41
+
"reportedBefore": reportedBefore,
42
+
"reviewState": reviewState,
43
+
"reviewedAfter": reviewedAfter,
44
+
"reviewedBefore": reviewedBefore,
45
+
"sortDirection": sortDirection,
46
+
"sortField": sortField,
47
+
"subject": subject,
48
+
"takendown": takendown,
49
+
}
50
+
if err := c.Do(ctx, xrpc.Query, "", "com.atproto.admin.queryModerationStatuses", params, nil, &out); err != nil {
51
+
return nil, err
52
+
}
53
+
54
+
return &out, nil
55
+
}
-28
api/atproto/adminrebaseRepo.go
-28
api/atproto/adminrebaseRepo.go
···
1
-
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
-
3
-
package atproto
4
-
5
-
// schema: com.atproto.admin.rebaseRepo
6
-
7
-
import (
8
-
"context"
9
-
10
-
"github.com/bluesky-social/indigo/xrpc"
11
-
)
12
-
13
-
// AdminRebaseRepo_Input is the input argument to a com.atproto.admin.rebaseRepo call.
14
-
type AdminRebaseRepo_Input struct {
15
-
// repo: The handle or DID of the repo.
16
-
Repo string `json:"repo" cborgen:"repo"`
17
-
// swapCommit: Compare and swap with the previous commit by cid.
18
-
SwapCommit *string `json:"swapCommit,omitempty" cborgen:"swapCommit,omitempty"`
19
-
}
20
-
21
-
// AdminRebaseRepo calls the XRPC method "com.atproto.admin.rebaseRepo".
22
-
func AdminRebaseRepo(ctx context.Context, c *xrpc.Client, input *AdminRebaseRepo_Input) error {
23
-
if err := c.Do(ctx, xrpc.Procedure, "application/json", "com.atproto.admin.rebaseRepo", nil, input, nil); err != nil {
24
-
return err
25
-
}
26
-
27
-
return nil
28
-
}
-28
api/atproto/adminresolveModerationReports.go
-28
api/atproto/adminresolveModerationReports.go
···
1
-
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
-
3
-
package atproto
4
-
5
-
// schema: com.atproto.admin.resolveModerationReports
6
-
7
-
import (
8
-
"context"
9
-
10
-
"github.com/bluesky-social/indigo/xrpc"
11
-
)
12
-
13
-
// AdminResolveModerationReports_Input is the input argument to a com.atproto.admin.resolveModerationReports call.
14
-
type AdminResolveModerationReports_Input struct {
15
-
ActionId int64 `json:"actionId" cborgen:"actionId"`
16
-
CreatedBy string `json:"createdBy" cborgen:"createdBy"`
17
-
ReportIds []int64 `json:"reportIds" cborgen:"reportIds"`
18
-
}
19
-
20
-
// AdminResolveModerationReports calls the XRPC method "com.atproto.admin.resolveModerationReports".
21
-
func AdminResolveModerationReports(ctx context.Context, c *xrpc.Client, input *AdminResolveModerationReports_Input) (*AdminDefs_ActionView, error) {
22
-
var out AdminDefs_ActionView
23
-
if err := c.Do(ctx, xrpc.Procedure, "application/json", "com.atproto.admin.resolveModerationReports", nil, input, &out); err != nil {
24
-
return nil, err
25
-
}
26
-
27
-
return &out, nil
28
-
}
-28
api/atproto/adminreverseModerationAction.go
-28
api/atproto/adminreverseModerationAction.go
···
1
-
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
-
3
-
package atproto
4
-
5
-
// schema: com.atproto.admin.reverseModerationAction
6
-
7
-
import (
8
-
"context"
9
-
10
-
"github.com/bluesky-social/indigo/xrpc"
11
-
)
12
-
13
-
// AdminReverseModerationAction_Input is the input argument to a com.atproto.admin.reverseModerationAction call.
14
-
type AdminReverseModerationAction_Input struct {
15
-
CreatedBy string `json:"createdBy" cborgen:"createdBy"`
16
-
Id int64 `json:"id" cborgen:"id"`
17
-
Reason string `json:"reason" cborgen:"reason"`
18
-
}
19
-
20
-
// AdminReverseModerationAction calls the XRPC method "com.atproto.admin.reverseModerationAction".
21
-
func AdminReverseModerationAction(ctx context.Context, c *xrpc.Client, input *AdminReverseModerationAction_Input) (*AdminDefs_ActionView, error) {
22
-
var out AdminDefs_ActionView
23
-
if err := c.Do(ctx, xrpc.Procedure, "application/json", "com.atproto.admin.reverseModerationAction", nil, input, &out); err != nil {
24
-
return nil, err
25
-
}
26
-
27
-
return &out, nil
28
-
}
+1
api/atproto/adminsendEmail.go
+1
api/atproto/adminsendEmail.go
···
14
14
type AdminSendEmail_Input struct {
15
15
Content string `json:"content" cborgen:"content"`
16
16
RecipientDid string `json:"recipientDid" cborgen:"recipientDid"`
17
+
SenderDid string `json:"senderDid" cborgen:"senderDid"`
17
18
Subject *string `json:"subject,omitempty" cborgen:"subject,omitempty"`
18
19
}
19
20
-72
api/atproto/admintakeModerationAction.go
-72
api/atproto/admintakeModerationAction.go
···
1
-
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
-
3
-
package atproto
4
-
5
-
// schema: com.atproto.admin.takeModerationAction
6
-
7
-
import (
8
-
"context"
9
-
"encoding/json"
10
-
"fmt"
11
-
12
-
"github.com/bluesky-social/indigo/lex/util"
13
-
"github.com/bluesky-social/indigo/xrpc"
14
-
)
15
-
16
-
// AdminTakeModerationAction_Input is the input argument to a com.atproto.admin.takeModerationAction call.
17
-
type AdminTakeModerationAction_Input struct {
18
-
Action string `json:"action" cborgen:"action"`
19
-
CreateLabelVals []string `json:"createLabelVals,omitempty" cborgen:"createLabelVals,omitempty"`
20
-
CreatedBy string `json:"createdBy" cborgen:"createdBy"`
21
-
// durationInHours: Indicates how long this action is meant to be in effect before automatically expiring.
22
-
DurationInHours *int64 `json:"durationInHours,omitempty" cborgen:"durationInHours,omitempty"`
23
-
NegateLabelVals []string `json:"negateLabelVals,omitempty" cborgen:"negateLabelVals,omitempty"`
24
-
Reason string `json:"reason" cborgen:"reason"`
25
-
Subject *AdminTakeModerationAction_Input_Subject `json:"subject" cborgen:"subject"`
26
-
SubjectBlobCids []string `json:"subjectBlobCids,omitempty" cborgen:"subjectBlobCids,omitempty"`
27
-
}
28
-
29
-
type AdminTakeModerationAction_Input_Subject struct {
30
-
AdminDefs_RepoRef *AdminDefs_RepoRef
31
-
RepoStrongRef *RepoStrongRef
32
-
}
33
-
34
-
func (t *AdminTakeModerationAction_Input_Subject) MarshalJSON() ([]byte, error) {
35
-
if t.AdminDefs_RepoRef != nil {
36
-
t.AdminDefs_RepoRef.LexiconTypeID = "com.atproto.admin.defs#repoRef"
37
-
return json.Marshal(t.AdminDefs_RepoRef)
38
-
}
39
-
if t.RepoStrongRef != nil {
40
-
t.RepoStrongRef.LexiconTypeID = "com.atproto.repo.strongRef"
41
-
return json.Marshal(t.RepoStrongRef)
42
-
}
43
-
return nil, fmt.Errorf("cannot marshal empty enum")
44
-
}
45
-
func (t *AdminTakeModerationAction_Input_Subject) UnmarshalJSON(b []byte) error {
46
-
typ, err := util.TypeExtract(b)
47
-
if err != nil {
48
-
return err
49
-
}
50
-
51
-
switch typ {
52
-
case "com.atproto.admin.defs#repoRef":
53
-
t.AdminDefs_RepoRef = new(AdminDefs_RepoRef)
54
-
return json.Unmarshal(b, t.AdminDefs_RepoRef)
55
-
case "com.atproto.repo.strongRef":
56
-
t.RepoStrongRef = new(RepoStrongRef)
57
-
return json.Unmarshal(b, t.RepoStrongRef)
58
-
59
-
default:
60
-
return nil
61
-
}
62
-
}
63
-
64
-
// AdminTakeModerationAction calls the XRPC method "com.atproto.admin.takeModerationAction".
65
-
func AdminTakeModerationAction(ctx context.Context, c *xrpc.Client, input *AdminTakeModerationAction_Input) (*AdminDefs_ActionView, error) {
66
-
var out AdminDefs_ActionView
67
-
if err := c.Do(ctx, xrpc.Procedure, "application/json", "com.atproto.admin.takeModerationAction", nil, input, &out); err != nil {
68
-
return nil, err
69
-
}
70
-
71
-
return &out, nil
72
-
}
+36
-21
automod/event.go
+36
-21
automod/event.go
···
78
78
}
79
79
xrpcc := e.Engine.AdminClient
80
80
if len(e.AccountLabels) > 0 {
81
-
_, err := comatproto.AdminTakeModerationAction(ctx, xrpcc, &comatproto.AdminTakeModerationAction_Input{
82
-
Action: "com.atproto.admin.defs#flag",
83
-
CreateLabelVals: dedupeStrings(e.AccountLabels),
84
-
Reason: "automod",
85
-
CreatedBy: xrpcc.Auth.Did,
86
-
Subject: &comatproto.AdminTakeModerationAction_Input_Subject{
81
+
comment := "automod"
82
+
_, err := comatproto.AdminEmitModerationEvent(ctx, xrpcc, &comatproto.AdminEmitModerationEvent_Input{
83
+
CreatedBy: xrpcc.Auth.Did,
84
+
Event: &comatproto.AdminEmitModerationEvent_Input_Event{
85
+
AdminDefs_ModEventLabel: &comatproto.AdminDefs_ModEventLabel{
86
+
CreateLabelVals: dedupeStrings(e.AccountLabels),
87
+
Comment: &comment,
88
+
},
89
+
},
90
+
Subject: &comatproto.AdminEmitModerationEvent_Input_Subject{
87
91
AdminDefs_RepoRef: &comatproto.AdminDefs_RepoRef{
88
92
Did: e.Account.Identity.DID.String(),
89
93
},
···
109
113
}
110
114
}
111
115
if e.AccountTakedown {
112
-
_, err := comatproto.AdminTakeModerationAction(ctx, xrpcc, &comatproto.AdminTakeModerationAction_Input{
113
-
Action: "com.atproto.admin.defs#takedown",
114
-
Reason: "automod",
116
+
comment := "automod"
117
+
_, err := comatproto.AdminEmitModerationEvent(ctx, xrpcc, &comatproto.AdminEmitModerationEvent_Input{
115
118
CreatedBy: xrpcc.Auth.Did,
116
-
Subject: &comatproto.AdminTakeModerationAction_Input_Subject{
119
+
Event: &comatproto.AdminEmitModerationEvent_Input_Event{
120
+
AdminDefs_ModEventTakedown: &comatproto.AdminDefs_ModEventTakedown{
121
+
Comment: &comment,
122
+
},
123
+
},
124
+
Subject: &comatproto.AdminEmitModerationEvent_Input_Subject{
117
125
AdminDefs_RepoRef: &comatproto.AdminDefs_RepoRef{
118
126
Did: e.Account.Identity.DID.String(),
119
127
},
···
194
202
}
195
203
xrpcc := e.Engine.AdminClient
196
204
if len(e.RecordLabels) > 0 {
197
-
// TODO: this does an action, not just create labels; will update after event refactor
198
-
_, err := comatproto.AdminTakeModerationAction(ctx, xrpcc, &comatproto.AdminTakeModerationAction_Input{
199
-
Action: "com.atproto.admin.defs#flag",
200
-
CreateLabelVals: dedupeStrings(e.RecordLabels),
201
-
Reason: "automod",
202
-
CreatedBy: xrpcc.Auth.Did,
203
-
Subject: &comatproto.AdminTakeModerationAction_Input_Subject{
205
+
comment := "automod"
206
+
_, err := comatproto.AdminEmitModerationEvent(ctx, xrpcc, &comatproto.AdminEmitModerationEvent_Input{
207
+
CreatedBy: xrpcc.Auth.Did,
208
+
Event: &comatproto.AdminEmitModerationEvent_Input_Event{
209
+
AdminDefs_ModEventLabel: &comatproto.AdminDefs_ModEventLabel{
210
+
CreateLabelVals: dedupeStrings(e.RecordLabels),
211
+
Comment: &comment,
212
+
},
213
+
},
214
+
Subject: &comatproto.AdminEmitModerationEvent_Input_Subject{
204
215
RepoStrongRef: &strongRef,
205
216
},
206
217
})
···
222
233
}
223
234
}
224
235
if e.RecordTakedown {
225
-
_, err := comatproto.AdminTakeModerationAction(ctx, xrpcc, &comatproto.AdminTakeModerationAction_Input{
226
-
Action: "com.atproto.admin.defs#takedown",
227
-
Reason: "automod",
236
+
comment := "automod"
237
+
_, err := comatproto.AdminEmitModerationEvent(ctx, xrpcc, &comatproto.AdminEmitModerationEvent_Input{
228
238
CreatedBy: xrpcc.Auth.Did,
229
-
Subject: &comatproto.AdminTakeModerationAction_Input_Subject{
239
+
Event: &comatproto.AdminEmitModerationEvent_Input_Event{
240
+
AdminDefs_ModEventTakedown: &comatproto.AdminDefs_ModEventTakedown{
241
+
Comment: &comment,
242
+
},
243
+
},
244
+
Subject: &comatproto.AdminEmitModerationEvent_Input_Subject{
230
245
RepoStrongRef: &strongRef,
231
246
},
232
247
})
+12
-14
cmd/beemo/main.go
+12
-14
cmd/beemo/main.go
···
144
144
xrpcc.Auth.AccessJwt = refresh.AccessJwt
145
145
xrpcc.Auth.RefreshJwt = refresh.RefreshJwt
146
146
147
-
// AdminGetModerationReports(ctx context.Context, c *xrpc.Client, actionType string, actionedBy string, cursor string, ignoreSubjects []string, limit int64, reporters []string, resolved bool, reverse bool, subject string) (*AdminGetModerationReports_Output, error)
148
-
resolved := false
147
+
// query just new reports (regardless of resolution state)
148
+
// AdminQueryModerationEvents(ctx context.Context, c *xrpc.Client, createdBy string, cursor string, includeAllUserRecords bool, limit int64, sortDirection string, subject string, types []string) (*AdminQueryModerationEvents_Output, error)
149
149
var limit int64 = 50
150
-
mrr, err := comatproto.AdminGetModerationReports(context.TODO(), xrpcc, "", "", "", nil, limit, nil, resolved, false, "")
150
+
me, err := comatproto.AdminQueryModerationEvents(context.TODO(), xrpcc, "", "", false, limit, "", "", []string{"com.atproto.admin.defs#modEventReport"})
151
151
if err != nil {
152
152
return err
153
153
}
154
154
// this works out to iterate from newest to oldest, which is the behavior we want (report only newest, then break)
155
-
for _, report := range mrr.Reports {
156
-
if len(report.ResolvedByActionIds) > 0 {
157
-
continue
158
-
}
159
-
createdAt, err := time.Parse(time.RFC3339, report.CreatedAt)
155
+
for _, evt := range me.Events {
156
+
report := evt.Event.AdminDefs_ModEventReport
157
+
// TODO: filter out based on subject state? similar to old "report.ResolvedByActionIds"
158
+
createdAt, err := time.Parse(time.RFC3339, evt.CreatedAt)
160
159
if err != nil {
161
160
return fmt.Errorf("invalid time format for 'createdAt': %w", err)
162
161
}
163
162
if createdAt.After(since) {
164
163
shortType := ""
165
-
if report.ReasonType != nil && strings.Contains(*report.ReasonType, "#") {
166
-
shortType = strings.SplitN(*report.ReasonType, "#", 2)[1]
164
+
if report.ReportType != nil && strings.Contains(*report.ReportType, "#") {
165
+
shortType = strings.SplitN(*report.ReportType, "#", 2)[1]
167
166
}
168
167
// ok, we found a "new" report, need to notify
169
-
msg := fmt.Sprintf("⚠️ New report at `%s` ⚠️\n", report.CreatedAt)
170
-
msg += fmt.Sprintf("report id: `%d`\t", report.Id)
171
-
msg += fmt.Sprintf("recent unresolved: `%d`\t", len(mrr.Reports))
168
+
msg := fmt.Sprintf("⚠️ New report at `%s` ⚠️\n", evt.CreatedAt)
169
+
msg += fmt.Sprintf("report id: `%d`\t", evt.Id)
172
170
msg += fmt.Sprintf("instance: `%s`\n", cctx.String("pds-host"))
173
171
msg += fmt.Sprintf("reasonType: `%s`\t", shortType)
174
-
msg += fmt.Sprintf("Admin: %s/reports/%d\n", cctx.String("admin-host"), report.Id)
172
+
msg += fmt.Sprintf("Admin: %s/reports/%d\n", cctx.String("admin-host"), evt.Id)
175
173
//msg += fmt.Sprintf("reportedByDid: `%s`\n", report.ReportedByDid)
176
174
log.Infof("found new report, notifying slack: %s", report)
177
175
err := sendSlackMsg(cctx, msg)
+15
-55
cmd/gosky/admin.go
+15
-55
cmd/gosky/admin.go
···
33
33
createInviteCmd,
34
34
disableInvitesCmd,
35
35
enableInvitesCmd,
36
-
getModerationActionsCmd,
36
+
queryModerationStatusesCmd,
37
37
listInviteTreeCmd,
38
38
reportsCmd,
39
39
takeDownAccountCmd,
···
379
379
adminKey := cctx.String("admin-password")
380
380
xrpcc.AdminToken = &adminKey
381
381
382
-
// AdminGetModerationReports(ctx context.Context, c *xrpc.Client, actionType string, actionedBy string, cursor string, ignoreSubjects []string, limit int64, reporters []string, resolved bool, reverse bool, subject string) (*AdminGetModerationReports_Output, error)
383
-
resp, err := atproto.AdminGetModerationReports(ctx, xrpcc, "", "", "", nil, 100, nil, cctx.Bool("resolved"), false, "")
382
+
// fetch recent moderation reports
383
+
// AdminQueryModerationEvents(ctx context.Context, c *xrpc.Client, createdBy string, cursor string, includeAllUserRecords bool, limit int64, sortDirection string, subject string, types []string) (*AdminQueryModerationEvents_Output, error)
384
+
resp, err := atproto.AdminQueryModerationEvents(ctx, xrpcc, "", "", false, 100, "", "", []string{"com.atproto.admin.defs#modEventReport"})
384
385
if err != nil {
385
386
return err
386
387
}
387
388
388
-
tojson := func(i any) string {
389
-
b, err := json.MarshalIndent(i, "", " ")
390
-
if err != nil {
391
-
panic(err)
392
-
}
393
-
394
-
return string(b)
395
-
}
396
-
397
-
for _, rep := range resp.Reports {
389
+
for _, rep := range resp.Events {
398
390
b, err := json.MarshalIndent(rep, "", " ")
399
391
if err != nil {
400
392
return err
401
393
}
402
394
fmt.Println(string(b))
403
-
for _, act := range rep.ResolvedByActionIds {
404
-
action, err := atproto.AdminGetModerationAction(ctx, xrpcc, act)
405
-
if err != nil {
406
-
return err
407
-
}
408
-
409
-
fmt.Println(tojson(action))
410
-
}
411
395
}
412
396
return nil
413
397
},
···
598
582
Usage: "account of person running this command, for recordkeeping",
599
583
Required: true,
600
584
},
601
-
&cli.BoolFlag{
602
-
Name: "revert-actions",
603
-
Usage: "revert existing moderation actions on this user before taking down",
604
-
},
605
585
},
606
586
Action: func(cctx *cli.Context) error {
607
587
···
638
618
adminUser = resp
639
619
}
640
620
641
-
if cctx.Bool("revert-actions") {
642
-
resp, err := atproto.AdminGetModerationActions(ctx, xrpcc, "", 100, did)
643
-
if err != nil {
644
-
return err
645
-
}
646
-
647
-
for _, act := range resp.Actions {
648
-
if act.Action == nil || *act.Action != "com.atproto.admin.defs#acknowledge" {
649
-
return fmt.Errorf("will only revert acknowledge actions")
650
-
}
651
-
652
-
_, err := atproto.AdminReverseModerationAction(ctx, xrpcc, &atproto.AdminReverseModerationAction_Input{
653
-
CreatedBy: adminUser,
654
-
Id: act.Id,
655
-
Reason: "reverting for takedown",
656
-
})
657
-
if err != nil {
658
-
return fmt.Errorf("failed to revert existing action: %w", err)
659
-
}
660
-
}
661
-
662
-
}
663
-
664
-
resp, err := atproto.AdminTakeModerationAction(ctx, xrpcc, &atproto.AdminTakeModerationAction_Input{
665
-
Action: "com.atproto.admin.defs#takedown",
666
-
Reason: reason,
621
+
resp, err := atproto.AdminEmitModerationEvent(ctx, xrpcc, &atproto.AdminEmitModerationEvent_Input{
667
622
CreatedBy: adminUser,
668
-
Subject: &atproto.AdminTakeModerationAction_Input_Subject{
623
+
Event: &atproto.AdminEmitModerationEvent_Input_Event{
624
+
AdminDefs_ModEventTakedown: &atproto.AdminDefs_ModEventTakedown{
625
+
Comment: &reason,
626
+
},
627
+
},
628
+
Subject: &atproto.AdminEmitModerationEvent_Input_Subject{
669
629
AdminDefs_RepoRef: &atproto.AdminDefs_RepoRef{
670
630
Did: did,
671
631
},
···
686
646
},
687
647
}
688
648
689
-
var getModerationActionsCmd = &cli.Command{
690
-
Name: "get-moderation-actions",
649
+
var queryModerationStatusesCmd = &cli.Command{
650
+
Name: "query-moderation-statuses",
691
651
Action: func(cctx *cli.Context) error {
692
652
693
653
xrpcc, err := cliutil.GetXrpcClient(cctx, false)
···
711
671
did = resp
712
672
}
713
673
714
-
resp, err := atproto.AdminGetModerationActions(ctx, xrpcc, "", 100, did)
674
+
resp, err := atproto.AdminQueryModerationStatuses(ctx, xrpcc, "", "", nil, true, "", 100, "", "", "", "", "", "", "", "", false)
715
675
if err != nil {
716
676
return err
717
677
}
+7
-155
labeler/admin.go
+7
-155
labeler/admin.go
···
45
45
return &recordView
46
46
}
47
47
48
-
func (s *Server) hydrateModerationActionViews(ctx context.Context, rows []models.ModerationAction) ([]*comatproto.AdminDefs_ActionView, error) {
49
-
50
-
var out []*comatproto.AdminDefs_ActionView
51
-
52
-
for _, row := range rows {
53
-
54
-
resolvedReportIds := []int64{}
55
-
var resolutionRows []models.ModerationReportResolution
56
-
result := s.db.Where("action_id = ?", row.ID).Find(&resolutionRows)
57
-
if result.Error != nil {
58
-
return nil, result.Error
59
-
}
60
-
for _, row := range resolutionRows {
61
-
resolvedReportIds = append(resolvedReportIds, int64(row.ReportId))
62
-
}
63
-
64
-
subjectBlobCIDs := []string{}
65
-
var cidRows []models.ModerationActionSubjectBlobCid
66
-
result = s.db.Where("action_id = ?", row.ID).Find(&cidRows)
67
-
if result.Error != nil {
68
-
return nil, result.Error
69
-
}
70
-
for _, row := range cidRows {
71
-
subjectBlobCIDs = append(subjectBlobCIDs, row.Cid)
72
-
}
73
-
74
-
var reversal *comatproto.AdminDefs_ActionReversal
75
-
if row.ReversedAt != nil {
76
-
reversal = &comatproto.AdminDefs_ActionReversal{
77
-
CreatedAt: row.ReversedAt.Format(time.RFC3339),
78
-
CreatedBy: *row.ReversedByDid,
79
-
Reason: *row.ReversedReason,
80
-
}
81
-
}
82
-
var subj *comatproto.AdminDefs_ActionView_Subject
83
-
switch row.SubjectType {
84
-
case "com.atproto.repo.repoRef":
85
-
subj = &comatproto.AdminDefs_ActionView_Subject{
86
-
AdminDefs_RepoRef: &comatproto.AdminDefs_RepoRef{
87
-
LexiconTypeID: "com.atproto.repo.repoRef",
88
-
Did: row.SubjectDid,
89
-
},
90
-
}
91
-
case "com.atproto.repo.recordRef":
92
-
subj = &comatproto.AdminDefs_ActionView_Subject{
93
-
RepoStrongRef: &comatproto.RepoStrongRef{
94
-
LexiconTypeID: "com.atproto.repo.strongRef",
95
-
Uri: *row.SubjectUri,
96
-
Cid: *row.SubjectCid,
97
-
},
98
-
}
99
-
default:
100
-
return nil, fmt.Errorf("unsupported moderation SubjectType: %v", row.SubjectType)
101
-
}
102
-
103
-
view := &comatproto.AdminDefs_ActionView{
104
-
Action: &row.Action,
105
-
CreatedAt: row.CreatedAt.Format(time.RFC3339),
106
-
CreatedBy: row.CreatedByDid,
107
-
Id: int64(row.ID),
108
-
Reason: row.Reason,
109
-
ResolvedReportIds: resolvedReportIds,
110
-
Reversal: reversal,
111
-
Subject: subj,
112
-
SubjectBlobCids: subjectBlobCIDs,
113
-
}
114
-
out = append(out, view)
115
-
}
116
-
return out, nil
117
-
}
118
-
119
-
func (s *Server) hydrateModerationActionDetails(ctx context.Context, rows []models.ModerationAction) ([]*comatproto.AdminDefs_ActionViewDetail, error) {
120
-
121
-
var out []*comatproto.AdminDefs_ActionViewDetail
122
-
for _, row := range rows {
123
-
124
-
var reportRows []models.ModerationReport
125
-
result := s.db.Joins("left join moderation_report_resolutions on moderation_report_resolutions.report_id = moderation_reports.id").Where("moderation_report_resolutions.action_id = ?", row.ID).Find(&reportRows)
126
-
if result.Error != nil {
127
-
return nil, result.Error
128
-
}
129
-
resolvedReports, err := s.hydrateModerationReportViews(ctx, reportRows)
130
-
if err != nil {
131
-
return nil, err
132
-
}
133
-
134
-
subjectBlobViews := []*comatproto.AdminDefs_BlobView{}
135
-
var cidRows []models.ModerationActionSubjectBlobCid
136
-
result = s.db.Where("action_id = ?", row.ID).Find(&cidRows)
137
-
if result.Error != nil {
138
-
return nil, result.Error
139
-
}
140
-
for _, row := range cidRows {
141
-
subjectBlobViews = append(subjectBlobViews, &comatproto.AdminDefs_BlobView{
142
-
Cid: row.Cid,
143
-
/* TODO(bnewbold): all these other blob fields (from another backed)
144
-
CreatedAt string
145
-
Details *AdminDefs_BlobView_Details
146
-
MimeType string
147
-
Moderation *AdminDefs_Moderation
148
-
Size int64
149
-
*/
150
-
})
151
-
}
152
-
153
-
var reversal *comatproto.AdminDefs_ActionReversal
154
-
if row.ReversedAt != nil {
155
-
reversal = &comatproto.AdminDefs_ActionReversal{
156
-
CreatedAt: row.ReversedAt.Format(time.RFC3339),
157
-
CreatedBy: *row.ReversedByDid,
158
-
Reason: *row.ReversedReason,
159
-
}
160
-
}
161
-
var subj *comatproto.AdminDefs_ActionViewDetail_Subject
162
-
switch row.SubjectType {
163
-
case "com.atproto.repo.repoRef":
164
-
subj = &comatproto.AdminDefs_ActionViewDetail_Subject{
165
-
AdminDefs_RepoView: s.hydrateRepoView(ctx, row.SubjectDid, row.CreatedAt.Format(time.RFC3339)),
166
-
}
167
-
case "com.atproto.repo.recordRef":
168
-
subj = &comatproto.AdminDefs_ActionViewDetail_Subject{
169
-
AdminDefs_RecordView: s.hydrateRecordView(ctx, row.SubjectDid, row.SubjectUri, row.SubjectCid, row.CreatedAt.Format(time.RFC3339)),
170
-
}
171
-
default:
172
-
return nil, fmt.Errorf("unsupported moderation SubjectType: %v", row.SubjectType)
173
-
}
174
-
175
-
viewDetail := &comatproto.AdminDefs_ActionViewDetail{
176
-
Action: &row.Action,
177
-
CreatedAt: row.CreatedAt.Format(time.RFC3339),
178
-
CreatedBy: row.CreatedByDid,
179
-
Id: int64(row.ID),
180
-
Reason: row.Reason,
181
-
ResolvedReports: resolvedReports,
182
-
Reversal: reversal,
183
-
Subject: subj,
184
-
SubjectBlobs: subjectBlobViews,
185
-
}
186
-
out = append(out, viewDetail)
187
-
}
188
-
return out, nil
189
-
}
190
-
191
48
func (s *Server) hydrateModerationReportViews(ctx context.Context, rows []models.ModerationReport) ([]*comatproto.AdminDefs_ReportView, error) {
192
49
193
50
var out []*comatproto.AdminDefs_ReportView
···
225
82
226
83
view := &comatproto.AdminDefs_ReportView{
227
84
Id: int64(row.ID),
228
-
Reason: row.Reason,
85
+
Comment: row.Reason,
229
86
ReasonType: &row.ReasonType,
230
87
Subject: subj,
231
88
ReportedBy: row.ReportedByDid,
···
246
103
if result.Error != nil {
247
104
return nil, result.Error
248
105
}
249
-
resolvedByActionViews, err := s.hydrateModerationActionViews(ctx, actionRows)
250
-
if err != nil {
251
-
return nil, err
252
-
}
253
106
254
107
var subj *comatproto.AdminDefs_ReportViewDetail_Subject
255
108
switch row.SubjectType {
···
266
119
}
267
120
268
121
viewDetail := &comatproto.AdminDefs_ReportViewDetail{
269
-
Id: int64(row.ID),
270
-
Reason: row.Reason,
271
-
ReasonType: &row.ReasonType,
272
-
Subject: subj,
273
-
ReportedBy: row.ReportedByDid,
274
-
CreatedAt: row.CreatedAt.Format(time.RFC3339),
275
-
ResolvedByActions: resolvedByActionViews,
122
+
Id: int64(row.ID),
123
+
Comment: row.Reason,
124
+
ReasonType: &row.ReasonType,
125
+
Subject: subj,
126
+
ReportedBy: row.ReportedByDid,
127
+
CreatedAt: row.CreatedAt.Format(time.RFC3339),
276
128
}
277
129
out = append(out, viewDetail)
278
130
}
+2
-159
labeler/helpers_test.go
+2
-159
labeler/helpers_test.go
···
16
16
label "github.com/bluesky-social/indigo/api/label"
17
17
)
18
18
19
-
// fetches report, both getModerationReport and getModerationReports, verifies match
19
+
// fetches report via getModerationReport, verifies match
20
20
func testGetReport(t *testing.T, e *echo.Echo, lm *Server, reportId int64) comatproto.AdminDefs_ReportViewDetail {
21
21
assert := assert.New(t)
22
22
···
33
33
}
34
34
assert.Equal(reportId, reportViewDetail.Id)
35
35
36
-
// read back (getModerationReports) and verify output
37
-
// TODO: include 'subject' param
38
-
req = httptest.NewRequest(http.MethodGet, "/xrpc/com.atproto.admin.getModerationReports", nil)
39
-
recorder = httptest.NewRecorder()
40
-
c = e.NewContext(req, recorder)
41
-
assert.NoError(lm.HandleComAtprotoAdminGetModerationReports(c))
42
-
assert.Equal(200, recorder.Code)
43
-
var reportsOut comatproto.AdminGetModerationReports_Output
44
-
if err := json.Unmarshal([]byte(recorder.Body.String()), &reportsOut); err != nil {
45
-
t.Fatal(err)
46
-
}
47
-
var reportView *comatproto.AdminDefs_ReportView
48
-
for _, rv := range reportsOut.Reports {
49
-
if rv.Id == reportId {
50
-
reportView = rv
51
-
break
52
-
}
53
-
}
54
-
if reportView == nil {
55
-
t.Fatal("expected to find report by subject")
56
-
}
57
-
58
-
assert.Equal(reportViewDetail.Id, reportView.Id)
59
-
assert.Equal(reportViewDetail.CreatedAt, reportView.CreatedAt)
60
-
assert.Equal(reportViewDetail.Reason, reportView.Reason)
61
-
assert.Equal(reportViewDetail.ReasonType, reportView.ReasonType)
62
-
assert.Equal(reportViewDetail.ReportedBy, reportView.ReportedBy)
63
-
assert.Equal(len(reportViewDetail.ResolvedByActions), len(reportView.ResolvedByActionIds))
64
-
for i, actionId := range reportView.ResolvedByActionIds {
65
-
assert.Equal(actionId, reportViewDetail.ResolvedByActions[i].Id)
66
-
}
67
-
if reportViewDetail.Subject.AdminDefs_RepoView != nil {
68
-
assert.Equal(reportViewDetail.Subject.AdminDefs_RepoView.Did, reportView.Subject.AdminDefs_RepoRef.Did)
69
-
} else if reportViewDetail.Subject.AdminDefs_RecordView != nil {
70
-
assert.Equal(reportViewDetail.Subject.AdminDefs_RecordView.Uri, reportView.Subject.RepoStrongRef.Uri)
71
-
assert.Equal(reportViewDetail.Subject.AdminDefs_RecordView.Cid, reportView.Subject.RepoStrongRef.Cid)
72
-
} else {
73
-
t.Fatal("expected non-empty reportviewdetail.subject enum")
74
-
}
75
-
76
36
return reportViewDetail
77
37
}
78
38
···
107
67
assert.Equal(out.Id, reportViewDetail.Id)
108
68
assert.Equal(out.CreatedAt, reportViewDetail.CreatedAt)
109
69
assert.Equal(out.ReportedBy, reportViewDetail.ReportedBy)
110
-
assert.Equal(out.Reason, reportViewDetail.Reason)
70
+
assert.Equal(out.Reason, reportViewDetail.Comment)
111
71
assert.Equal(out.ReasonType, reportViewDetail.ReasonType)
112
72
assert.Equal(0, len(reportViewDetail.ResolvedByActions))
113
73
if out.Subject.AdminDefs_RepoRef != nil {
···
118
78
} else {
119
79
t.Fatal("expected non-empty actionviewdetail.subject enum")
120
80
}
121
-
122
-
return out
123
-
}
124
-
125
-
// fetches action, both getModerationAction and getModerationActions; verifies match
126
-
func testGetAction(t *testing.T, e *echo.Echo, lm *Server, actionId int64) comatproto.AdminDefs_ActionViewDetail {
127
-
assert := assert.New(t)
128
-
129
-
params := make(url.Values)
130
-
params.Set("id", strconv.Itoa(int(actionId)))
131
-
req := httptest.NewRequest(http.MethodGet, "/xrpc/com.atproto.admin.getModerationAction?"+params.Encode(), nil)
132
-
recorder := httptest.NewRecorder()
133
-
c := e.NewContext(req, recorder)
134
-
assert.NoError(lm.HandleComAtprotoAdminGetModerationAction(c))
135
-
assert.Equal(200, recorder.Code)
136
-
var actionViewDetail comatproto.AdminDefs_ActionViewDetail
137
-
if err := json.Unmarshal([]byte(recorder.Body.String()), &actionViewDetail); err != nil {
138
-
t.Fatal(err)
139
-
}
140
-
assert.Equal(actionId, actionViewDetail.Id)
141
-
142
-
// read back (getModerationActions) and verify output
143
-
// TODO: include 'subject' param
144
-
req = httptest.NewRequest(http.MethodGet, "/xrpc/com.atproto.admin.getModerationActions", nil)
145
-
recorder = httptest.NewRecorder()
146
-
c = e.NewContext(req, recorder)
147
-
assert.NoError(lm.HandleComAtprotoAdminGetModerationActions(c))
148
-
assert.Equal(200, recorder.Code)
149
-
var actionsOut comatproto.AdminGetModerationActions_Output
150
-
if err := json.Unmarshal([]byte(recorder.Body.String()), &actionsOut); err != nil {
151
-
t.Fatal(err)
152
-
}
153
-
var actionView *comatproto.AdminDefs_ActionView
154
-
for _, rv := range actionsOut.Actions {
155
-
if rv.Id == actionId {
156
-
actionView = rv
157
-
break
158
-
}
159
-
}
160
-
if actionView == nil {
161
-
t.Fatal("expected to find action by subject")
162
-
}
163
-
164
-
assert.Equal(actionViewDetail.Id, actionView.Id)
165
-
assert.Equal(actionViewDetail.CreatedAt, actionView.CreatedAt)
166
-
assert.Equal(actionViewDetail.Action, actionView.Action)
167
-
assert.Equal(actionViewDetail.Reason, actionView.Reason)
168
-
assert.Equal(actionViewDetail.CreatedBy, actionView.CreatedBy)
169
-
assert.Equal(actionViewDetail.Reversal, actionView.Reversal)
170
-
assert.Equal(len(actionViewDetail.ResolvedReports), len(actionView.ResolvedReportIds))
171
-
for i, reportId := range actionView.ResolvedReportIds {
172
-
assert.Equal(reportId, actionViewDetail.ResolvedReports[i].Id)
173
-
}
174
-
for i, blobCid := range actionView.SubjectBlobCids {
175
-
assert.Equal(blobCid, actionViewDetail.SubjectBlobs[i].Cid)
176
-
}
177
-
if actionViewDetail.Subject.AdminDefs_RepoView != nil {
178
-
assert.Equal(actionViewDetail.Subject.AdminDefs_RepoView.Did, actionView.Subject.AdminDefs_RepoRef.Did)
179
-
} else if actionViewDetail.Subject.AdminDefs_RecordView != nil {
180
-
assert.Equal(actionViewDetail.Subject.AdminDefs_RecordView.Uri, actionView.Subject.RepoStrongRef.Uri)
181
-
assert.Equal(actionViewDetail.Subject.AdminDefs_RecordView.Cid, actionView.Subject.RepoStrongRef.Cid)
182
-
} else {
183
-
t.Fatal("expected non-empty actionviewdetail.subject enum")
184
-
}
185
-
186
-
return actionViewDetail
187
-
}
188
-
189
-
// "happy path" test helper. creates a action, reads it back 2x ways, verifies match, then returns the original output
190
-
func testCreateAction(t *testing.T, e *echo.Echo, lm *Server, input *comatproto.AdminTakeModerationAction_Input) comatproto.AdminDefs_ActionView {
191
-
assert := assert.New(t)
192
-
193
-
// create action and verify output
194
-
actionJSON, err := json.Marshal(input)
195
-
if err != nil {
196
-
t.Fatal(err)
197
-
}
198
-
req := httptest.NewRequest(http.MethodPost, "/xrpc/com.atproto.action.create", strings.NewReader(string(actionJSON)))
199
-
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
200
-
recorder := httptest.NewRecorder()
201
-
c := e.NewContext(req, recorder)
202
-
203
-
assert.NoError(lm.HandleComAtprotoAdminTakeModerationAction(c))
204
-
assert.Equal(200, recorder.Code)
205
-
206
-
var out comatproto.AdminDefs_ActionView
207
-
if err := json.Unmarshal([]byte(recorder.Body.String()), &out); err != nil {
208
-
t.Fatal(err)
209
-
}
210
-
assert.Equal(input.Action, *out.Action)
211
-
assert.Equal(input.CreatedBy, out.CreatedBy)
212
-
assert.Equal(input.Reason, out.Reason)
213
-
assert.Equal(input.Subject.RepoStrongRef, out.Subject.RepoStrongRef)
214
-
assert.Equal(input.Subject.AdminDefs_RepoRef, out.Subject.AdminDefs_RepoRef)
215
-
assert.Equal(input.SubjectBlobCids, out.SubjectBlobCids)
216
-
217
-
// read it back and verify output
218
-
actionViewDetail := testGetAction(t, e, lm, out.Id)
219
-
assert.Equal(out.Id, actionViewDetail.Id)
220
-
assert.Equal(out.CreatedAt, actionViewDetail.CreatedAt)
221
-
222
-
assert.Equal(out.Action, actionViewDetail.Action)
223
-
assert.Equal(out.CreatedBy, actionViewDetail.CreatedBy)
224
-
assert.Equal(out.Reason, actionViewDetail.Reason)
225
-
if out.Subject.AdminDefs_RepoRef != nil {
226
-
assert.Equal(out.Subject.AdminDefs_RepoRef.Did, actionViewDetail.Subject.AdminDefs_RepoView.Did)
227
-
} else if out.Subject.RepoStrongRef != nil {
228
-
assert.Equal(out.Subject.RepoStrongRef.Uri, actionViewDetail.Subject.AdminDefs_RecordView.Uri)
229
-
assert.Equal(out.Subject.RepoStrongRef.Cid, actionViewDetail.Subject.AdminDefs_RecordView.Cid)
230
-
} else {
231
-
t.Fatal("expected non-empty actionviewdetail.subject enum")
232
-
}
233
-
for i, blobCid := range out.SubjectBlobCids {
234
-
assert.Equal(blobCid, actionViewDetail.SubjectBlobs[i].Cid)
235
-
}
236
-
assert.Equal(0, len(actionViewDetail.ResolvedReports))
237
-
assert.Nil(actionViewDetail.Reversal)
238
81
239
82
return out
240
83
}
-140
labeler/xrpc_endpoints.go
-140
labeler/xrpc_endpoints.go
···
18
18
// TODO: session create/refresh/delete?
19
19
20
20
// minimal moderation reporting/actioning
21
-
e.GET("/xrpc/com.atproto.admin.getModerationAction", s.HandleComAtprotoAdminGetModerationAction)
22
-
e.GET("/xrpc/com.atproto.admin.getModerationActions", s.HandleComAtprotoAdminGetModerationActions)
23
-
e.GET("/xrpc/com.atproto.admin.getModerationReport", s.HandleComAtprotoAdminGetModerationReport)
24
-
e.GET("/xrpc/com.atproto.admin.getModerationReports", s.HandleComAtprotoAdminGetModerationReports)
25
-
e.POST("/xrpc/com.atproto.admin.resolveModerationReports", s.HandleComAtprotoAdminResolveModerationReports)
26
-
e.POST("/xrpc/com.atproto.admin.reverseModerationAction", s.HandleComAtprotoAdminReverseModerationAction)
27
-
e.POST("/xrpc/com.atproto.admin.takeModerationAction", s.HandleComAtprotoAdminTakeModerationAction)
28
21
e.POST("/xrpc/com.atproto.report.create", s.HandleComAtprotoReportCreate)
29
22
30
23
// label-specific
···
93
86
return c.JSON(200, out)
94
87
}
95
88
96
-
func (s *Server) HandleComAtprotoAdminGetModerationAction(c echo.Context) error {
97
-
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminGetModerationAction")
98
-
defer span.End()
99
-
100
-
id, err := strconv.Atoi(c.QueryParam("id"))
101
-
if err != nil {
102
-
return err
103
-
}
104
-
var out *atproto.AdminDefs_ActionViewDetail
105
-
var handleErr error
106
-
// func (s *Server) handleComAtprotoAdminGetModerationAction(ctx context.Context,id int) (*atproto.AdminDefs_ActionViewDetail, error)
107
-
out, handleErr = s.handleComAtprotoAdminGetModerationAction(ctx, id)
108
-
if handleErr != nil {
109
-
return handleErr
110
-
}
111
-
return c.JSON(200, out)
112
-
}
113
-
114
-
func (s *Server) HandleComAtprotoAdminGetModerationActions(c echo.Context) error {
115
-
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminGetModerationActions")
116
-
defer span.End()
117
-
before := c.QueryParam("before")
118
-
119
-
var limit int
120
-
if p := c.QueryParam("limit"); p != "" {
121
-
var err error
122
-
limit, err = strconv.Atoi(p)
123
-
if err != nil {
124
-
return err
125
-
}
126
-
} else {
127
-
limit = 50
128
-
}
129
-
subject := c.QueryParam("subject")
130
-
var out *atproto.AdminGetModerationActions_Output
131
-
var handleErr error
132
-
// func (s *Server) handleComAtprotoAdminGetModerationActions(ctx context.Context,before string,limit int,subject string) (*atproto.AdminGetModerationActions_Output, error)
133
-
out, handleErr = s.handleComAtprotoAdminGetModerationActions(ctx, before, limit, subject)
134
-
if handleErr != nil {
135
-
return handleErr
136
-
}
137
-
return c.JSON(200, out)
138
-
}
139
-
140
89
func (s *Server) HandleComAtprotoAdminGetModerationReport(c echo.Context) error {
141
90
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminGetModerationReport")
142
91
defer span.End()
···
149
98
var handleErr error
150
99
// func (s *Server) handleComAtprotoAdminGetModerationReport(ctx context.Context,id int) (*atproto.AdminDefs_ReportViewDetail, error)
151
100
out, handleErr = s.handleComAtprotoAdminGetModerationReport(ctx, id)
152
-
if handleErr != nil {
153
-
return handleErr
154
-
}
155
-
return c.JSON(200, out)
156
-
}
157
-
158
-
func (s *Server) HandleComAtprotoAdminGetModerationReports(c echo.Context) error {
159
-
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminGetModerationReports")
160
-
defer span.End()
161
-
before := c.QueryParam("before")
162
-
163
-
var limit int
164
-
if p := c.QueryParam("limit"); p != "" {
165
-
var err error
166
-
limit, err = strconv.Atoi(p)
167
-
if err != nil {
168
-
return err
169
-
}
170
-
} else {
171
-
limit = 50
172
-
}
173
-
174
-
var resolved *bool
175
-
if p := c.QueryParam("resolved"); p != "" {
176
-
resolved_val, err := strconv.ParseBool(p)
177
-
if err != nil {
178
-
return err
179
-
}
180
-
resolved = &resolved_val
181
-
}
182
-
subject := c.QueryParam("subject")
183
-
var out *atproto.AdminGetModerationReports_Output
184
-
var handleErr error
185
-
// func (s *Server) handleComAtprotoAdminGetModerationReports(ctx context.Context,before string,limit int,resolved *bool,subject string) (*atproto.AdminGetModerationReports_Output, error)
186
-
out, handleErr = s.handleComAtprotoAdminGetModerationReports(ctx, before, limit, resolved, subject)
187
-
if handleErr != nil {
188
-
return handleErr
189
-
}
190
-
return c.JSON(200, out)
191
-
}
192
-
193
-
func (s *Server) HandleComAtprotoAdminResolveModerationReports(c echo.Context) error {
194
-
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminResolveModerationReports")
195
-
defer span.End()
196
-
197
-
var body atproto.AdminResolveModerationReports_Input
198
-
if err := c.Bind(&body); err != nil {
199
-
return err
200
-
}
201
-
var out *atproto.AdminDefs_ActionView
202
-
var handleErr error
203
-
// func (s *Server) handleComAtprotoAdminResolveModerationReports(ctx context.Context,body *atproto.AdminResolveModerationReports_Input) (*atproto.AdminDefs_ActionView, error)
204
-
out, handleErr = s.handleComAtprotoAdminResolveModerationReports(ctx, &body)
205
-
if handleErr != nil {
206
-
return handleErr
207
-
}
208
-
return c.JSON(200, out)
209
-
}
210
-
211
-
func (s *Server) HandleComAtprotoAdminReverseModerationAction(c echo.Context) error {
212
-
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminReverseModerationAction")
213
-
defer span.End()
214
-
215
-
var body atproto.AdminReverseModerationAction_Input
216
-
if err := c.Bind(&body); err != nil {
217
-
return err
218
-
}
219
-
var out *atproto.AdminDefs_ActionView
220
-
var handleErr error
221
-
// func (s *Server) handleComAtprotoAdminReverseModerationAction(ctx context.Context,body *atproto.AdminReverseModerationAction_Input) (*atproto.AdminDefs_ActionView, error)
222
-
out, handleErr = s.handleComAtprotoAdminReverseModerationAction(ctx, &body)
223
-
if handleErr != nil {
224
-
return handleErr
225
-
}
226
-
return c.JSON(200, out)
227
-
}
228
-
229
-
func (s *Server) HandleComAtprotoAdminTakeModerationAction(c echo.Context) error {
230
-
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminTakeModerationAction")
231
-
defer span.End()
232
-
233
-
var body atproto.AdminTakeModerationAction_Input
234
-
if err := c.Bind(&body); err != nil {
235
-
return err
236
-
}
237
-
var out *atproto.AdminDefs_ActionView
238
-
var handleErr error
239
-
// func (s *Server) handleComAtprotoAdminTakeModerationAction(ctx context.Context,body *atproto.AdminTakeModerationAction_Input) (*atproto.AdminDefs_ActionView, error)
240
-
out, handleErr = s.handleComAtprotoAdminTakeModerationAction(ctx, &body)
241
101
if handleErr != nil {
242
102
return handleErr
243
103
}
-281
labeler/xrpc_handlers.go
-281
labeler/xrpc_handlers.go
···
2
2
3
3
import (
4
4
"context"
5
-
"errors"
6
5
"strconv"
7
6
"strings"
8
7
"time"
···
13
12
"github.com/bluesky-social/indigo/util"
14
13
15
14
"github.com/labstack/echo/v4"
16
-
"gorm.io/gorm"
17
15
)
18
16
19
17
func (s *Server) handleComAtprotoServerDescribeServer(ctx context.Context) (*atproto.ServerDescribeServer_Output, error) {
···
103
101
return &out, nil
104
102
}
105
103
106
-
func (s *Server) handleComAtprotoAdminGetModerationAction(ctx context.Context, id int) (*atproto.AdminDefs_ActionViewDetail, error) {
107
-
108
-
var row models.ModerationAction
109
-
result := s.db.First(&row, id)
110
-
if result.Error != nil {
111
-
return nil, result.Error
112
-
}
113
-
114
-
full, err := s.hydrateModerationActionDetails(ctx, []models.ModerationAction{row})
115
-
if err != nil {
116
-
return nil, err
117
-
}
118
-
return full[0], nil
119
-
}
120
-
121
-
func (s *Server) handleComAtprotoAdminGetModerationActions(ctx context.Context, before string, limit int, subject string) (*atproto.AdminGetModerationActions_Output, error) {
122
-
123
-
if limit <= 0 {
124
-
limit = 20
125
-
}
126
-
if limit > 100 {
127
-
limit = 100
128
-
}
129
-
130
-
q := s.db.Limit(limit).Order("id desc")
131
-
cursor := before
132
-
if cursor != "" {
133
-
cursorID, err := strconv.Atoi(cursor)
134
-
if err != nil {
135
-
return nil, echo.NewHTTPError(400, "invalid cursor param: %v", cursor)
136
-
}
137
-
q = q.Where("id < ?", cursorID)
138
-
}
139
-
140
-
if subject != "" {
141
-
q = q.Where("subject = ?", subject)
142
-
}
143
-
144
-
var actionRows []models.ModerationAction
145
-
result := q.Find(&actionRows)
146
-
if result.Error != nil {
147
-
return nil, result.Error
148
-
}
149
-
150
-
var nextCursor string
151
-
if len(actionRows) >= 1 && len(actionRows) == limit {
152
-
nextCursor = strconv.FormatUint(actionRows[len(actionRows)-1].ID, 10)
153
-
}
154
-
155
-
actionObjs, err := s.hydrateModerationActionViews(ctx, actionRows)
156
-
if err != nil {
157
-
return nil, err
158
-
}
159
-
out := atproto.AdminGetModerationActions_Output{
160
-
Actions: actionObjs,
161
-
}
162
-
if nextCursor != "" {
163
-
out.Cursor = &nextCursor
164
-
}
165
-
return &out, nil
166
-
}
167
-
168
104
func (s *Server) handleComAtprotoAdminGetModerationReport(ctx context.Context, id int) (*atproto.AdminDefs_ReportViewDetail, error) {
169
105
170
106
var row models.ModerationReport
···
180
116
return full[0], nil
181
117
}
182
118
183
-
func (s *Server) handleComAtprotoAdminGetModerationReports(ctx context.Context, before string, limit int, resolved *bool, subject string) (*atproto.AdminGetModerationReports_Output, error) {
184
-
185
-
if limit <= 0 {
186
-
limit = 20
187
-
}
188
-
if limit > 100 {
189
-
limit = 100
190
-
}
191
-
192
-
q := s.db.Limit(limit).Order("id desc")
193
-
cursor := before
194
-
if cursor != "" {
195
-
cursorID, err := strconv.Atoi(cursor)
196
-
if err != nil {
197
-
return nil, echo.NewHTTPError(400, "invalid cursor param: %v", cursor)
198
-
}
199
-
q = q.Where("id < ?", cursorID)
200
-
}
201
-
202
-
if subject != "" {
203
-
q = q.Where("subject = ?", subject)
204
-
}
205
-
206
-
var reportRows []models.ModerationReport
207
-
result := q.Find(&reportRows)
208
-
if result.Error != nil {
209
-
return nil, result.Error
210
-
}
211
-
212
-
var nextCursor string
213
-
if len(reportRows) >= 1 && len(reportRows) == limit {
214
-
nextCursor = strconv.FormatUint(reportRows[len(reportRows)-1].ID, 10)
215
-
}
216
-
217
-
reportObjs, err := s.hydrateModerationReportViews(ctx, reportRows)
218
-
if err != nil {
219
-
return nil, err
220
-
}
221
-
222
-
// TODO: a bit inefficient to do this filter after hydration. could do it
223
-
// in the SQL query instead, but this was faster to implement right now
224
-
if resolved != nil {
225
-
var filtered []*atproto.AdminDefs_ReportView
226
-
for _, obj := range reportObjs {
227
-
if *resolved == true && len(obj.ResolvedByActionIds) > 0 {
228
-
filtered = append(filtered, obj)
229
-
}
230
-
if *resolved == false && len(obj.ResolvedByActionIds) == 0 {
231
-
filtered = append(filtered, obj)
232
-
}
233
-
}
234
-
reportObjs = filtered
235
-
}
236
-
237
-
out := atproto.AdminGetModerationReports_Output{
238
-
Reports: reportObjs,
239
-
}
240
-
if nextCursor != "" {
241
-
out.Cursor = &nextCursor
242
-
}
243
-
return &out, nil
244
-
}
245
-
246
-
func (s *Server) handleComAtprotoAdminResolveModerationReports(ctx context.Context, body *atproto.AdminResolveModerationReports_Input) (*atproto.AdminDefs_ActionView, error) {
247
-
248
-
if body.CreatedBy == "" {
249
-
return nil, echo.NewHTTPError(400, "createdBy param must be non-empty")
250
-
}
251
-
if len(body.ReportIds) == 0 {
252
-
return nil, echo.NewHTTPError(400, "at least one reportId required")
253
-
}
254
-
255
-
var rows []models.ModerationReportResolution
256
-
for _, reportId := range body.ReportIds {
257
-
rows = append(rows, models.ModerationReportResolution{
258
-
ReportId: uint64(reportId),
259
-
ActionId: uint64(body.ActionId),
260
-
CreatedByDid: body.CreatedBy,
261
-
})
262
-
}
263
-
result := s.db.Create(&rows)
264
-
if result.Error != nil {
265
-
return nil, result.Error
266
-
}
267
-
268
-
return s.fetchSingleModerationAction(ctx, body.ActionId)
269
-
}
270
-
271
-
// helper for endpoints that return a partially hydrated moderation action
272
-
func (s *Server) fetchSingleModerationAction(ctx context.Context, actionId int64) (*atproto.AdminDefs_ActionView, error) {
273
-
var actionRow models.ModerationAction
274
-
result := s.db.First(&actionRow, actionId)
275
-
if result.Error != nil {
276
-
return nil, result.Error
277
-
}
278
-
279
-
actionObjs, err := s.hydrateModerationActionViews(ctx, []models.ModerationAction{actionRow})
280
-
if err != nil {
281
-
return nil, err
282
-
}
283
-
return actionObjs[0], nil
284
-
}
285
-
286
-
func (s *Server) handleComAtprotoAdminReverseModerationAction(ctx context.Context, body *atproto.AdminReverseModerationAction_Input) (*atproto.AdminDefs_ActionView, error) {
287
-
288
-
if body.CreatedBy == "" {
289
-
return nil, echo.NewHTTPError(400, "createBy param must be non-empty")
290
-
}
291
-
if body.Reason == "" {
292
-
return nil, echo.NewHTTPError(400, "reason param was provided, but empty string")
293
-
}
294
-
295
-
row := models.ModerationAction{ID: uint64(body.Id)}
296
-
result := s.db.First(&row)
297
-
if result.Error != nil {
298
-
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
299
-
return nil, echo.NewHTTPError(404, "moderation action not found: %d", body.Id)
300
-
} else {
301
-
return nil, result.Error
302
-
}
303
-
}
304
-
305
-
if row.ReversedAt != nil {
306
-
return nil, echo.NewHTTPError(400, "action has already been reversed actionId=%d", body.Id)
307
-
}
308
-
309
-
now := time.Now()
310
-
row.ReversedByDid = &body.CreatedBy
311
-
row.ReversedReason = &body.Reason
312
-
row.ReversedAt = &now
313
-
314
-
result = s.db.Save(&row)
315
-
if result.Error != nil {
316
-
return nil, result.Error
317
-
}
318
-
319
-
return s.fetchSingleModerationAction(ctx, body.Id)
320
-
}
321
-
322
119
func didFromURI(uri string) string {
323
120
parts := strings.SplitN(uri, "/", 4)
324
121
if len(parts) < 3 {
···
328
125
return parts[2]
329
126
}
330
127
return ""
331
-
}
332
-
333
-
func (s *Server) handleComAtprotoAdminTakeModerationAction(ctx context.Context, body *atproto.AdminTakeModerationAction_Input) (*atproto.AdminDefs_ActionView, error) {
334
-
335
-
if body.Action == "" {
336
-
return nil, echo.NewHTTPError(400, "action param must be non-empty")
337
-
}
338
-
if body.CreatedBy == "" {
339
-
return nil, echo.NewHTTPError(400, "createBy param must be non-empty")
340
-
}
341
-
if body.Reason == "" {
342
-
return nil, echo.NewHTTPError(400, "reason param was provided, but empty string")
343
-
}
344
-
345
-
row := models.ModerationAction{
346
-
Action: body.Action,
347
-
Reason: body.Reason,
348
-
CreatedByDid: body.CreatedBy,
349
-
}
350
-
351
-
var outSubj atproto.AdminDefs_ActionView_Subject
352
-
if body.Subject.AdminDefs_RepoRef != nil {
353
-
row.SubjectType = "com.atproto.repo.repoRef"
354
-
row.SubjectDid = body.Subject.AdminDefs_RepoRef.Did
355
-
outSubj.AdminDefs_RepoRef = &atproto.AdminDefs_RepoRef{
356
-
LexiconTypeID: "com.atproto.repo.repoRef",
357
-
Did: row.SubjectDid,
358
-
}
359
-
} else if body.Subject.RepoStrongRef != nil {
360
-
if body.Subject.RepoStrongRef.Cid == "" {
361
-
return nil, echo.NewHTTPError(400, "this implementation requires a strong record ref (aka, with CID) in reports")
362
-
}
363
-
row.SubjectType = "com.atproto.repo.recordRef"
364
-
row.SubjectUri = &body.Subject.RepoStrongRef.Uri
365
-
row.SubjectDid = didFromURI(body.Subject.RepoStrongRef.Uri)
366
-
if row.SubjectDid == "" {
367
-
return nil, echo.NewHTTPError(400, "expected URI with a DID: ", row.SubjectUri)
368
-
}
369
-
row.SubjectCid = &body.Subject.RepoStrongRef.Cid
370
-
outSubj.RepoStrongRef = &atproto.RepoStrongRef{
371
-
LexiconTypeID: "com.atproto.repo.strongRef",
372
-
Uri: *row.SubjectUri,
373
-
Cid: *row.SubjectCid,
374
-
}
375
-
} else {
376
-
return nil, echo.NewHTTPError(400, "report subject must be a repoRef or a recordRef")
377
-
}
378
-
379
-
result := s.db.Create(&row)
380
-
if result.Error != nil {
381
-
return nil, result.Error
382
-
}
383
-
384
-
var cidRows []models.ModerationActionSubjectBlobCid
385
-
for _, sbc := range body.SubjectBlobCids {
386
-
cidRows = append(cidRows, models.ModerationActionSubjectBlobCid{
387
-
ActionId: row.ID,
388
-
Cid: sbc,
389
-
})
390
-
}
391
-
392
-
if len(cidRows) > 0 {
393
-
result = s.db.Create(&cidRows)
394
-
if result.Error != nil {
395
-
return nil, result.Error
396
-
}
397
-
}
398
-
399
-
out := atproto.AdminDefs_ActionView{
400
-
Id: int64(row.ID),
401
-
Action: &row.Action,
402
-
Reason: row.Reason,
403
-
CreatedBy: row.CreatedByDid,
404
-
CreatedAt: row.CreatedAt.Format(time.RFC3339),
405
-
Subject: &outSubj,
406
-
SubjectBlobCids: body.SubjectBlobCids,
407
-
}
408
-
return &out, nil
409
128
}
410
129
411
130
func (s *Server) handleComAtprotoReportCreate(ctx context.Context, body *atproto.ModerationCreateReport_Input) (*atproto.ModerationCreateReport_Output, error) {
-124
labeler/xrpc_test.go
-124
labeler/xrpc_test.go
···
3
3
import (
4
4
"context"
5
5
"encoding/json"
6
-
"fmt"
7
6
"net/http"
8
7
"net/http/httptest"
9
8
"net/url"
···
161
160
assert.Equal(row.statusCode, recorder.Code)
162
161
}
163
162
}
164
-
}
165
-
166
-
func TestLabelMakerXRPCReportAction(t *testing.T) {
167
-
assert := assert.New(t)
168
-
e := echo.New()
169
-
lm := testLabelMaker(t)
170
-
171
-
// create report
172
-
reasonType := "spam"
173
-
reportReason := "I just don't like it!"
174
-
uri := "at://did:plc:123/com.example.record/bcd234"
175
-
cid := "bafyreie5cvv4h45feadgeuwhbcutmh6t2ceseocckahdoe6uat64zmz454"
176
-
report := comatproto.ModerationCreateReport_Input{
177
-
Reason: &reportReason,
178
-
ReasonType: &reasonType,
179
-
Subject: &comatproto.ModerationCreateReport_Input_Subject{
180
-
RepoStrongRef: &comatproto.RepoStrongRef{
181
-
//com.atproto.repo.strongRef
182
-
Uri: uri,
183
-
Cid: cid,
184
-
},
185
-
},
186
-
}
187
-
reportOut := testCreateReport(t, e, lm, &report)
188
-
reportId := reportOut.Id
189
-
190
-
// create action
191
-
actionVerb := "acknowledge"
192
-
actionDid := "did:plc:ADMIN"
193
-
actionReason := "chaos reigns"
194
-
action := comatproto.AdminTakeModerationAction_Input{
195
-
Action: actionVerb,
196
-
CreatedBy: actionDid,
197
-
Reason: actionReason,
198
-
Subject: &comatproto.AdminTakeModerationAction_Input_Subject{
199
-
RepoStrongRef: &comatproto.RepoStrongRef{
200
-
//com.atproto.repo.strongRef
201
-
Uri: uri,
202
-
Cid: cid,
203
-
},
204
-
},
205
-
SubjectBlobCids: []string{
206
-
"abc",
207
-
"onetwothree",
208
-
},
209
-
}
210
-
actionOut := testCreateAction(t, e, lm, &action)
211
-
actionId := actionOut.Id
212
-
213
-
// resolve report with action
214
-
resolution := comatproto.AdminResolveModerationReports_Input{
215
-
ActionId: actionId,
216
-
CreatedBy: actionDid,
217
-
ReportIds: []int64{reportId},
218
-
}
219
-
resolutionJSON, err := json.Marshal(resolution)
220
-
if err != nil {
221
-
t.Fatal(err)
222
-
}
223
-
req := httptest.NewRequest(http.MethodPost, "/xrpc/com.atproto.report.resolveModerationReports", strings.NewReader(string(resolutionJSON)))
224
-
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
225
-
recorder := httptest.NewRecorder()
226
-
c := e.NewContext(req, recorder)
227
-
assert.NoError(lm.HandleComAtprotoAdminResolveModerationReports(c))
228
-
var resolutionOut comatproto.AdminDefs_ActionView
229
-
if err := json.Unmarshal([]byte(recorder.Body.String()), &resolutionOut); err != nil {
230
-
t.Fatal(err)
231
-
}
232
-
fmt.Println(recorder.Body.String())
233
-
assert.Equal(actionId, resolutionOut.Id)
234
-
assert.Equal(1, len(resolutionOut.ResolvedReportIds))
235
-
assert.Equal(reportId, resolutionOut.ResolvedReportIds[0])
236
-
237
-
// get report (should have action included)
238
-
reportOutDetail := testGetReport(t, e, lm, reportId)
239
-
assert.Equal(reportId, reportOutDetail.Id)
240
-
assert.Equal(1, len(reportOutDetail.ResolvedByActions))
241
-
assert.Equal(actionId, reportOutDetail.ResolvedByActions[0].Id)
242
-
243
-
// get action (should have report included)
244
-
actionOutDetail := testGetAction(t, e, lm, actionId)
245
-
assert.Equal(actionId, actionOutDetail.Id)
246
-
assert.Equal(1, len(actionOutDetail.ResolvedReports))
247
-
assert.Equal(reportId, actionOutDetail.ResolvedReports[0].Id)
248
-
249
-
// reverse action
250
-
reversalReason := "changed my mind"
251
-
reversal := comatproto.AdminReverseModerationAction_Input{
252
-
Id: actionId,
253
-
CreatedBy: actionDid,
254
-
Reason: reversalReason,
255
-
}
256
-
reversalJSON, err := json.Marshal(reversal)
257
-
if err != nil {
258
-
t.Fatal(err)
259
-
}
260
-
req = httptest.NewRequest(http.MethodPost, "/xrpc/com.atproto.report.reverseModerationAction", strings.NewReader(string(reversalJSON)))
261
-
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
262
-
recorder = httptest.NewRecorder()
263
-
c = e.NewContext(req, recorder)
264
-
assert.NoError(lm.HandleComAtprotoAdminReverseModerationAction(c))
265
-
var reversalOut comatproto.AdminDefs_ActionView
266
-
if err := json.Unmarshal([]byte(recorder.Body.String()), &reversalOut); err != nil {
267
-
t.Fatal(err)
268
-
}
269
-
assert.Equal(actionId, reversalOut.Id)
270
-
assert.Equal(1, len(reversalOut.ResolvedReportIds))
271
-
assert.Equal(reportId, reversalOut.ResolvedReportIds[0])
272
-
assert.Equal(reversal.Reason, reversalOut.Reversal.Reason)
273
-
assert.Equal(reversal.CreatedBy, reversalOut.Reversal.CreatedBy)
274
-
assert.NotNil(reversalOut.Reversal.CreatedAt)
275
-
276
-
// get report (should *not* have action included)
277
-
reportOutDetail = testGetReport(t, e, lm, reportId)
278
-
assert.Equal(reportId, reportOutDetail.Id)
279
-
assert.Equal(0, len(reportOutDetail.ResolvedByActions))
280
-
281
-
// get action (should still have report included)
282
-
actionOutDetail = testGetAction(t, e, lm, actionId)
283
-
assert.Equal(actionId, actionOutDetail.Id)
284
-
assert.Equal(1, len(actionOutDetail.ResolvedReports))
285
-
assert.Equal(reportId, actionOutDetail.ResolvedReports[0].Id)
286
-
assert.Equal(reversalOut.Reversal, actionOutDetail.Reversal)
287
163
}
288
164
289
165
func TestLabelMakerXRPCLabelQuery(t *testing.T) {
+56
-24
lex/util/cbor_gen_test.go
+56
-24
lex/util/cbor_gen_test.go
···
328
328
}
329
329
330
330
for i := 0; i < int(extra); i++ {
331
-
332
331
{
333
-
sval, err := cbg.ReadString(cr)
334
-
if err != nil {
335
-
return err
336
-
}
332
+
var maj byte
333
+
var extra uint64
334
+
var err error
335
+
_ = maj
336
+
_ = extra
337
+
_ = err
337
338
338
-
t.Array[i] = string(sval)
339
+
{
340
+
sval, err := cbg.ReadString(cr)
341
+
if err != nil {
342
+
return err
343
+
}
344
+
345
+
t.Array[i] = string(sval)
346
+
}
339
347
}
340
348
}
341
349
···
593
601
}
594
602
595
603
for i := 0; i < int(extra); i++ {
596
-
597
604
{
598
-
sval, err := cbg.ReadString(cr)
599
-
if err != nil {
600
-
return err
601
-
}
605
+
var maj byte
606
+
var extra uint64
607
+
var err error
608
+
_ = maj
609
+
_ = extra
610
+
_ = err
602
611
603
-
t.Arr[i] = string(sval)
612
+
{
613
+
sval, err := cbg.ReadString(cr)
614
+
if err != nil {
615
+
return err
616
+
}
617
+
618
+
t.Arr[i] = string(sval)
619
+
}
604
620
}
605
621
}
606
622
···
1172
1188
}
1173
1189
1174
1190
for i := 0; i < int(extra); i++ {
1175
-
1176
1191
{
1177
-
sval, err := cbg.ReadString(cr)
1178
-
if err != nil {
1179
-
return err
1180
-
}
1192
+
var maj byte
1193
+
var extra uint64
1194
+
var err error
1195
+
_ = maj
1196
+
_ = extra
1197
+
_ = err
1181
1198
1182
-
t.F[i] = string(sval)
1199
+
{
1200
+
sval, err := cbg.ReadString(cr)
1201
+
if err != nil {
1202
+
return err
1203
+
}
1204
+
1205
+
t.F[i] = string(sval)
1206
+
}
1183
1207
}
1184
1208
}
1185
1209
···
1423
1447
}
1424
1448
1425
1449
for i := 0; i < int(extra); i++ {
1426
-
1427
1450
{
1428
-
sval, err := cbg.ReadString(cr)
1429
-
if err != nil {
1430
-
return err
1431
-
}
1451
+
var maj byte
1452
+
var extra uint64
1453
+
var err error
1454
+
_ = maj
1455
+
_ = extra
1456
+
_ = err
1432
1457
1433
-
t.K[i] = string(sval)
1458
+
{
1459
+
sval, err := cbg.ReadString(cr)
1460
+
if err != nil {
1461
+
return err
1462
+
}
1463
+
1464
+
t.K[i] = string(sval)
1465
+
}
1434
1466
}
1435
1467
}
1436
1468
-27
pds/handlers.go
-27
pds/handlers.go
···
619
619
panic("nyi")
620
620
}
621
621
622
-
func (s *Server) handleComAtprotoAdminGetModerationAction(ctx context.Context, id int) (*comatprototypes.AdminDefs_ActionViewDetail, error) {
623
-
panic("nyi")
624
-
}
625
-
func (s *Server) handleComAtprotoAdminGetModerationActions(ctx context.Context, before string, limit int, subject string) (*comatprototypes.AdminGetModerationActions_Output, error) {
626
-
panic("nyi")
627
-
}
628
-
func (s *Server) handleComAtprotoAdminGetModerationReport(ctx context.Context, id int) (*comatprototypes.AdminDefs_ReportViewDetail, error) {
629
-
panic("nyi")
630
-
}
631
-
632
-
func (s *Server) handleComAtprotoAdminGetModerationReports(ctx context.Context, actionType string, actionedBy string, cursor string, ignoreSubjects []string, limit int, reporters []string, resolved *bool, reverse *bool, subject string) (*comatprototypes.AdminGetModerationReports_Output, error) {
633
-
panic("nyi")
634
-
}
635
-
636
622
func (s *Server) handleComAtprotoAdminGetRecord(ctx context.Context, cid string, uri string) (*comatprototypes.AdminDefs_RecordViewDetail, error) {
637
623
panic("nyi")
638
624
}
···
640
626
func (s *Server) handleComAtprotoAdminGetRepo(ctx context.Context, did string) (*comatprototypes.AdminDefs_RepoViewDetail, error) {
641
627
panic("nyi")
642
628
}
643
-
func (s *Server) handleComAtprotoAdminResolveModerationReports(ctx context.Context, body *comatprototypes.AdminResolveModerationReports_Input) (*comatprototypes.AdminDefs_ActionView, error) {
644
-
panic("nyi")
645
-
}
646
-
func (s *Server) handleComAtprotoAdminReverseModerationAction(ctx context.Context, body *comatprototypes.AdminReverseModerationAction_Input) (*comatprototypes.AdminDefs_ActionView, error) {
647
-
panic("nyi")
648
-
}
649
629
func (s *Server) handleComAtprotoAdminSearchRepos(ctx context.Context, cursor string, limit int, q string, term string) (*comatprototypes.AdminSearchRepos_Output, error) {
650
-
panic("nyi")
651
-
}
652
-
func (s *Server) handleComAtprotoAdminTakeModerationAction(ctx context.Context, body *comatprototypes.AdminTakeModerationAction_Input) (*comatprototypes.AdminDefs_ActionView, error) {
653
630
panic("nyi")
654
631
}
655
632
···
812
789
panic("nyi")
813
790
}
814
791
func (s *Server) handleAppBskyUnspeccedGetTimelineSkeleton(ctx context.Context, cursor string, limit int) (*appbskytypes.UnspeccedGetTimelineSkeleton_Output, error) {
815
-
panic("nyi")
816
-
}
817
-
818
-
func (s *Server) handleComAtprotoAdminRebaseRepo(ctx context.Context, body *comatprototypes.AdminRebaseRepo_Input) error {
819
792
panic("nyi")
820
793
}
821
794
-173
pds/stubs.go
-173
pds/stubs.go
···
1091
1091
e.POST("/xrpc/com.atproto.admin.enableAccountInvites", s.HandleComAtprotoAdminEnableAccountInvites)
1092
1092
e.GET("/xrpc/com.atproto.admin.getAccountInfo", s.HandleComAtprotoAdminGetAccountInfo)
1093
1093
e.GET("/xrpc/com.atproto.admin.getInviteCodes", s.HandleComAtprotoAdminGetInviteCodes)
1094
-
e.GET("/xrpc/com.atproto.admin.getModerationAction", s.HandleComAtprotoAdminGetModerationAction)
1095
-
e.GET("/xrpc/com.atproto.admin.getModerationActions", s.HandleComAtprotoAdminGetModerationActions)
1096
-
e.GET("/xrpc/com.atproto.admin.getModerationReport", s.HandleComAtprotoAdminGetModerationReport)
1097
-
e.GET("/xrpc/com.atproto.admin.getModerationReports", s.HandleComAtprotoAdminGetModerationReports)
1098
1094
e.GET("/xrpc/com.atproto.admin.getRecord", s.HandleComAtprotoAdminGetRecord)
1099
1095
e.GET("/xrpc/com.atproto.admin.getRepo", s.HandleComAtprotoAdminGetRepo)
1100
1096
e.GET("/xrpc/com.atproto.admin.getSubjectStatus", s.HandleComAtprotoAdminGetSubjectStatus)
1101
-
e.POST("/xrpc/com.atproto.admin.resolveModerationReports", s.HandleComAtprotoAdminResolveModerationReports)
1102
-
e.POST("/xrpc/com.atproto.admin.reverseModerationAction", s.HandleComAtprotoAdminReverseModerationAction)
1103
1097
e.GET("/xrpc/com.atproto.admin.searchRepos", s.HandleComAtprotoAdminSearchRepos)
1104
1098
e.POST("/xrpc/com.atproto.admin.sendEmail", s.HandleComAtprotoAdminSendEmail)
1105
-
e.POST("/xrpc/com.atproto.admin.takeModerationAction", s.HandleComAtprotoAdminTakeModerationAction)
1106
1099
e.POST("/xrpc/com.atproto.admin.updateAccountEmail", s.HandleComAtprotoAdminUpdateAccountEmail)
1107
1100
e.POST("/xrpc/com.atproto.admin.updateAccountHandle", s.HandleComAtprotoAdminUpdateAccountHandle)
1108
1101
e.POST("/xrpc/com.atproto.admin.updateSubjectStatus", s.HandleComAtprotoAdminUpdateSubjectStatus)
···
1245
1238
return c.JSON(200, out)
1246
1239
}
1247
1240
1248
-
func (s *Server) HandleComAtprotoAdminGetModerationAction(c echo.Context) error {
1249
-
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminGetModerationAction")
1250
-
defer span.End()
1251
-
1252
-
id, err := strconv.Atoi(c.QueryParam("id"))
1253
-
if err != nil {
1254
-
return err
1255
-
}
1256
-
var out *comatprototypes.AdminDefs_ActionViewDetail
1257
-
var handleErr error
1258
-
// func (s *Server) handleComAtprotoAdminGetModerationAction(ctx context.Context,id int) (*comatprototypes.AdminDefs_ActionViewDetail, error)
1259
-
out, handleErr = s.handleComAtprotoAdminGetModerationAction(ctx, id)
1260
-
if handleErr != nil {
1261
-
return handleErr
1262
-
}
1263
-
return c.JSON(200, out)
1264
-
}
1265
-
1266
-
func (s *Server) HandleComAtprotoAdminGetModerationActions(c echo.Context) error {
1267
-
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminGetModerationActions")
1268
-
defer span.End()
1269
-
cursor := c.QueryParam("cursor")
1270
-
1271
-
var limit int
1272
-
if p := c.QueryParam("limit"); p != "" {
1273
-
var err error
1274
-
limit, err = strconv.Atoi(p)
1275
-
if err != nil {
1276
-
return err
1277
-
}
1278
-
} else {
1279
-
limit = 50
1280
-
}
1281
-
subject := c.QueryParam("subject")
1282
-
var out *comatprototypes.AdminGetModerationActions_Output
1283
-
var handleErr error
1284
-
// func (s *Server) handleComAtprotoAdminGetModerationActions(ctx context.Context,cursor string,limit int,subject string) (*comatprototypes.AdminGetModerationActions_Output, error)
1285
-
out, handleErr = s.handleComAtprotoAdminGetModerationActions(ctx, cursor, limit, subject)
1286
-
if handleErr != nil {
1287
-
return handleErr
1288
-
}
1289
-
return c.JSON(200, out)
1290
-
}
1291
-
1292
-
func (s *Server) HandleComAtprotoAdminGetModerationReport(c echo.Context) error {
1293
-
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminGetModerationReport")
1294
-
defer span.End()
1295
-
1296
-
id, err := strconv.Atoi(c.QueryParam("id"))
1297
-
if err != nil {
1298
-
return err
1299
-
}
1300
-
var out *comatprototypes.AdminDefs_ReportViewDetail
1301
-
var handleErr error
1302
-
// func (s *Server) handleComAtprotoAdminGetModerationReport(ctx context.Context,id int) (*comatprototypes.AdminDefs_ReportViewDetail, error)
1303
-
out, handleErr = s.handleComAtprotoAdminGetModerationReport(ctx, id)
1304
-
if handleErr != nil {
1305
-
return handleErr
1306
-
}
1307
-
return c.JSON(200, out)
1308
-
}
1309
-
1310
-
func (s *Server) HandleComAtprotoAdminGetModerationReports(c echo.Context) error {
1311
-
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminGetModerationReports")
1312
-
defer span.End()
1313
-
actionType := c.QueryParam("actionType")
1314
-
actionedBy := c.QueryParam("actionedBy")
1315
-
cursor := c.QueryParam("cursor")
1316
-
1317
-
ignoreSubjects := c.QueryParams()["ignoreSubjects"]
1318
-
1319
-
var limit int
1320
-
if p := c.QueryParam("limit"); p != "" {
1321
-
var err error
1322
-
limit, err = strconv.Atoi(p)
1323
-
if err != nil {
1324
-
return err
1325
-
}
1326
-
} else {
1327
-
limit = 50
1328
-
}
1329
-
1330
-
reporters := c.QueryParams()["reporters"]
1331
-
1332
-
var resolved *bool
1333
-
if p := c.QueryParam("resolved"); p != "" {
1334
-
resolved_val, err := strconv.ParseBool(p)
1335
-
if err != nil {
1336
-
return err
1337
-
}
1338
-
resolved = &resolved_val
1339
-
}
1340
-
1341
-
var reverse *bool
1342
-
if p := c.QueryParam("reverse"); p != "" {
1343
-
reverse_val, err := strconv.ParseBool(p)
1344
-
if err != nil {
1345
-
return err
1346
-
}
1347
-
reverse = &reverse_val
1348
-
}
1349
-
subject := c.QueryParam("subject")
1350
-
var out *comatprototypes.AdminGetModerationReports_Output
1351
-
var handleErr error
1352
-
// func (s *Server) handleComAtprotoAdminGetModerationReports(ctx context.Context,actionType string,actionedBy string,cursor string,ignoreSubjects []string,limit int,reporters []string,resolved *bool,reverse *bool,subject string) (*comatprototypes.AdminGetModerationReports_Output, error)
1353
-
out, handleErr = s.handleComAtprotoAdminGetModerationReports(ctx, actionType, actionedBy, cursor, ignoreSubjects, limit, reporters, resolved, reverse, subject)
1354
-
if handleErr != nil {
1355
-
return handleErr
1356
-
}
1357
-
return c.JSON(200, out)
1358
-
}
1359
-
1360
1241
func (s *Server) HandleComAtprotoAdminGetRecord(c echo.Context) error {
1361
1242
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminGetRecord")
1362
1243
defer span.End()
···
1402
1283
return c.JSON(200, out)
1403
1284
}
1404
1285
1405
-
func (s *Server) HandleComAtprotoAdminResolveModerationReports(c echo.Context) error {
1406
-
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminResolveModerationReports")
1407
-
defer span.End()
1408
-
1409
-
var body comatprototypes.AdminResolveModerationReports_Input
1410
-
if err := c.Bind(&body); err != nil {
1411
-
return err
1412
-
}
1413
-
var out *comatprototypes.AdminDefs_ActionView
1414
-
var handleErr error
1415
-
// func (s *Server) handleComAtprotoAdminResolveModerationReports(ctx context.Context,body *comatprototypes.AdminResolveModerationReports_Input) (*comatprototypes.AdminDefs_ActionView, error)
1416
-
out, handleErr = s.handleComAtprotoAdminResolveModerationReports(ctx, &body)
1417
-
if handleErr != nil {
1418
-
return handleErr
1419
-
}
1420
-
return c.JSON(200, out)
1421
-
}
1422
-
1423
-
func (s *Server) HandleComAtprotoAdminReverseModerationAction(c echo.Context) error {
1424
-
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminReverseModerationAction")
1425
-
defer span.End()
1426
-
1427
-
var body comatprototypes.AdminReverseModerationAction_Input
1428
-
if err := c.Bind(&body); err != nil {
1429
-
return err
1430
-
}
1431
-
var out *comatprototypes.AdminDefs_ActionView
1432
-
var handleErr error
1433
-
// func (s *Server) handleComAtprotoAdminReverseModerationAction(ctx context.Context,body *comatprototypes.AdminReverseModerationAction_Input) (*comatprototypes.AdminDefs_ActionView, error)
1434
-
out, handleErr = s.handleComAtprotoAdminReverseModerationAction(ctx, &body)
1435
-
if handleErr != nil {
1436
-
return handleErr
1437
-
}
1438
-
return c.JSON(200, out)
1439
-
}
1440
-
1441
1286
func (s *Server) HandleComAtprotoAdminSearchRepos(c echo.Context) error {
1442
1287
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminSearchRepos")
1443
1288
defer span.End()
···
1477
1322
var handleErr error
1478
1323
// func (s *Server) handleComAtprotoAdminSendEmail(ctx context.Context,body *comatprototypes.AdminSendEmail_Input) (*comatprototypes.AdminSendEmail_Output, error)
1479
1324
out, handleErr = s.handleComAtprotoAdminSendEmail(ctx, &body)
1480
-
if handleErr != nil {
1481
-
return handleErr
1482
-
}
1483
-
return c.JSON(200, out)
1484
-
}
1485
-
1486
-
func (s *Server) HandleComAtprotoAdminTakeModerationAction(c echo.Context) error {
1487
-
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAdminTakeModerationAction")
1488
-
defer span.End()
1489
-
1490
-
var body comatprototypes.AdminTakeModerationAction_Input
1491
-
if err := c.Bind(&body); err != nil {
1492
-
return err
1493
-
}
1494
-
var out *comatprototypes.AdminDefs_ActionView
1495
-
var handleErr error
1496
-
// func (s *Server) handleComAtprotoAdminTakeModerationAction(ctx context.Context,body *comatprototypes.AdminTakeModerationAction_Input) (*comatprototypes.AdminDefs_ActionView, error)
1497
-
out, handleErr = s.handleComAtprotoAdminTakeModerationAction(ctx, &body)
1498
1325
if handleErr != nil {
1499
1326
return handleErr
1500
1327
}
-10
testing/labelmaker_fakedata_test.go
-10
testing/labelmaker_fakedata_test.go
···
9
9
"testing"
10
10
"time"
11
11
12
-
comatproto "github.com/bluesky-social/indigo/api/atproto"
13
12
label "github.com/bluesky-social/indigo/api/label"
14
13
"github.com/bluesky-social/indigo/carstore"
15
14
"github.com/bluesky-social/indigo/events"
···
169
168
assert.NoError(err)
170
169
assert.Equal(0, len(queryOut.Labels))
171
170
assert.Nil(queryOut.Cursor)
172
-
173
-
// auth is required
174
-
_, err = comatproto.AdminGetModerationReports(ctx, &xrpcc, "", "", "", nil, 20, nil, false, false, "")
175
-
assert.Error(err)
176
-
177
-
adminPassword := "test-admin-pass"
178
-
xrpcc.AdminToken = &adminPassword
179
-
_, err = comatproto.AdminGetModerationReports(ctx, &xrpcc, "", "", "", nil, 20, nil, false, false, "")
180
-
assert.NoError(err)
181
171
182
172
// TODO: many more tests
183
173
}