@atproto/ozone 0.1.90 → 0.1.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/moderation/getSubjects.d.ts +4 -0
- package/dist/api/moderation/getSubjects.d.ts.map +1 -0
- package/dist/api/moderation/getSubjects.js +81 -0
- package/dist/api/moderation/getSubjects.js.map +1 -0
- package/dist/api/util.js +1 -1
- package/dist/api/util.js.map +1 -1
- package/dist/lexicon/index.d.ts +6 -0
- package/dist/lexicon/index.d.ts.map +1 -1
- package/dist/lexicon/index.js +12 -0
- package/dist/lexicon/index.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +534 -4
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +287 -0
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/chat/bsky/convo/addReaction.d.ts +43 -0
- package/dist/lexicon/types/chat/bsky/convo/addReaction.d.ts.map +1 -0
- package/dist/lexicon/types/chat/bsky/convo/addReaction.js +7 -0
- package/dist/lexicon/types/chat/bsky/convo/addReaction.js.map +1 -0
- package/dist/lexicon/types/chat/bsky/convo/defs.d.ts +45 -1
- package/dist/lexicon/types/chat/bsky/convo/defs.d.ts.map +1 -1
- package/dist/lexicon/types/chat/bsky/convo/defs.js +45 -0
- package/dist/lexicon/types/chat/bsky/convo/defs.js.map +1 -1
- package/dist/lexicon/types/chat/bsky/convo/getLog.d.ts +1 -1
- package/dist/lexicon/types/chat/bsky/convo/getLog.d.ts.map +1 -1
- package/dist/lexicon/types/chat/bsky/convo/removeReaction.d.ts +43 -0
- package/dist/lexicon/types/chat/bsky/convo/removeReaction.d.ts.map +1 -0
- package/dist/lexicon/types/chat/bsky/convo/removeReaction.js +7 -0
- package/dist/lexicon/types/chat/bsky/convo/removeReaction.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts +14 -0
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/defs.js +9 -0
- package/dist/lexicon/types/tools/ozone/moderation/defs.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/getSubjects.d.ts +36 -0
- package/dist/lexicon/types/tools/ozone/moderation/getSubjects.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/moderation/getSubjects.js +7 -0
- package/dist/lexicon/types/tools/ozone/moderation/getSubjects.js.map +1 -0
- package/dist/mod-service/views.d.ts +2 -1
- package/dist/mod-service/views.d.ts.map +1 -1
- package/dist/mod-service/views.js +23 -4
- package/dist/mod-service/views.js.map +1 -1
- package/package.json +4 -4
- package/src/api/index.ts +2 -0
- package/src/api/moderation/getSubjects.ts +101 -0
- package/src/api/util.ts +1 -1
- package/src/lexicon/index.ts +36 -0
- package/src/lexicon/lexicons.ts +295 -0
- package/src/lexicon/types/chat/bsky/convo/addReaction.ts +63 -0
- package/src/lexicon/types/chat/bsky/convo/defs.ts +86 -0
- package/src/lexicon/types/chat/bsky/convo/getLog.ts +5 -0
- package/src/lexicon/types/chat/bsky/convo/removeReaction.ts +60 -0
- package/src/lexicon/types/tools/ozone/moderation/defs.ts +21 -0
- package/src/lexicon/types/tools/ozone/moderation/getSubjects.ts +54 -0
- package/src/mod-service/views.ts +31 -7
- package/tests/__snapshots__/get-subjects.test.ts.snap +439 -0
- package/tests/get-subjects.test.ts +81 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.tests.tsbuildinfo +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import express from 'express'
|
|
5
|
+
import { type ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
6
|
+
import { CID } from 'multiformats/cid'
|
|
7
|
+
import { validate as _validate } from '../../../../lexicons'
|
|
8
|
+
import {
|
|
9
|
+
type $Typed,
|
|
10
|
+
is$typed as _is$typed,
|
|
11
|
+
type OmitKey,
|
|
12
|
+
} from '../../../../util'
|
|
13
|
+
import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
|
|
14
|
+
import type * as ToolsOzoneModerationDefs from './defs.js'
|
|
15
|
+
|
|
16
|
+
const is$typed = _is$typed,
|
|
17
|
+
validate = _validate
|
|
18
|
+
const id = 'tools.ozone.moderation.getSubjects'
|
|
19
|
+
|
|
20
|
+
export interface QueryParams {
|
|
21
|
+
subjects: string[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type InputSchema = undefined
|
|
25
|
+
|
|
26
|
+
export interface OutputSchema {
|
|
27
|
+
subjects: ToolsOzoneModerationDefs.SubjectView[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type HandlerInput = undefined
|
|
31
|
+
|
|
32
|
+
export interface HandlerSuccess {
|
|
33
|
+
encoding: 'application/json'
|
|
34
|
+
body: OutputSchema
|
|
35
|
+
headers?: { [key: string]: string }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface HandlerError {
|
|
39
|
+
status: number
|
|
40
|
+
message?: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
|
|
44
|
+
export type HandlerReqCtx<HA extends HandlerAuth = never> = {
|
|
45
|
+
auth: HA
|
|
46
|
+
params: QueryParams
|
|
47
|
+
input: HandlerInput
|
|
48
|
+
req: express.Request
|
|
49
|
+
res: express.Response
|
|
50
|
+
resetRouteRateLimits: () => Promise<void>
|
|
51
|
+
}
|
|
52
|
+
export type Handler<HA extends HandlerAuth = never> = (
|
|
53
|
+
ctx: HandlerReqCtx<HA>,
|
|
54
|
+
) => Promise<HandlerOutput> | HandlerOutput
|
package/src/mod-service/views.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sql } from 'kysely'
|
|
2
|
-
import { AtpAgent } from '@atproto/api'
|
|
3
|
-
import { dedupeStrs } from '@atproto/common'
|
|
2
|
+
import { AppBskyActorDefs, AtpAgent } from '@atproto/api'
|
|
3
|
+
import { chunkArray, dedupeStrs } from '@atproto/common'
|
|
4
4
|
import { Keypair } from '@atproto/crypto'
|
|
5
5
|
import { BlobRef } from '@atproto/lexicon'
|
|
6
6
|
import { AtUri, INVALID_HANDLE, normalizeDatetimeAlways } from '@atproto/syntax'
|
|
@@ -79,7 +79,7 @@ export class ModerationViews {
|
|
|
79
79
|
const auth = await this.appviewAuth(ids.ComAtprotoAdminGetAccountInfos)
|
|
80
80
|
if (!auth) return new Map()
|
|
81
81
|
try {
|
|
82
|
-
const res = await this.appviewAgent.
|
|
82
|
+
const res = await this.appviewAgent.com.atproto.admin.getAccountInfos(
|
|
83
83
|
{
|
|
84
84
|
dids: dedupeStrs(dids),
|
|
85
85
|
},
|
|
@@ -266,6 +266,10 @@ export class ModerationViews {
|
|
|
266
266
|
labelers?: ParsedLabelers,
|
|
267
267
|
): Promise<Map<string, RepoView>> {
|
|
268
268
|
const results = new Map<string, RepoView>()
|
|
269
|
+
if (!dids.length) {
|
|
270
|
+
return results
|
|
271
|
+
}
|
|
272
|
+
|
|
269
273
|
const [repos, localLabels, externalLabels] = await Promise.all([
|
|
270
274
|
this.repos(dids),
|
|
271
275
|
this.labels(dids),
|
|
@@ -373,6 +377,11 @@ export class ModerationViews {
|
|
|
373
377
|
subjects: RecordSubject[],
|
|
374
378
|
labelers?: ParsedLabelers,
|
|
375
379
|
): Promise<Map<string, RecordViewDetail>> {
|
|
380
|
+
const results = new Map<string, RecordViewDetail>()
|
|
381
|
+
if (!subjects.length) {
|
|
382
|
+
return results
|
|
383
|
+
}
|
|
384
|
+
|
|
376
385
|
const subjectUris = subjects.map((s) => s.uri)
|
|
377
386
|
const [records, subjectStatusesResult, localLabels, externalLabels] =
|
|
378
387
|
await Promise.all([
|
|
@@ -382,8 +391,6 @@ export class ModerationViews {
|
|
|
382
391
|
this.getExternalLabels(subjectUris, labelers),
|
|
383
392
|
])
|
|
384
393
|
|
|
385
|
-
const results = new Map<string, RecordViewDetail>()
|
|
386
|
-
|
|
387
394
|
await Promise.all(
|
|
388
395
|
Array.from(records.entries()).map(async ([uri, record]) => {
|
|
389
396
|
const selfLabels = getSelfLabels({
|
|
@@ -425,7 +432,7 @@ export class ModerationViews {
|
|
|
425
432
|
try {
|
|
426
433
|
const {
|
|
427
434
|
data: { labels },
|
|
428
|
-
} = await this.appviewAgent.
|
|
435
|
+
} = await this.appviewAgent.com.atproto.label.queryLabels({
|
|
429
436
|
uriPatterns: subjects,
|
|
430
437
|
sources: labelers.dids,
|
|
431
438
|
})
|
|
@@ -695,10 +702,27 @@ export class ModerationViews {
|
|
|
695
702
|
if (!auth) return []
|
|
696
703
|
const {
|
|
697
704
|
data: { feed },
|
|
698
|
-
} = await this.appviewAgent.
|
|
705
|
+
} = await this.appviewAgent.app.bsky.feed.getAuthorFeed({ actor }, auth)
|
|
699
706
|
|
|
700
707
|
return feed
|
|
701
708
|
}
|
|
709
|
+
|
|
710
|
+
async getProfiles(dids: string[]) {
|
|
711
|
+
const profiles = new Map<string, AppBskyActorDefs.ProfileViewDetailed>()
|
|
712
|
+
|
|
713
|
+
const auth = await this.appviewAuth(ids.AppBskyActorGetProfiles)
|
|
714
|
+
if (!auth) return profiles
|
|
715
|
+
|
|
716
|
+
for (const actors of chunkArray(dids, 25)) {
|
|
717
|
+
const { data } = await this.appviewAgent.getProfiles({ actors })
|
|
718
|
+
|
|
719
|
+
data.profiles.forEach((profile) => {
|
|
720
|
+
profiles.set(profile.did, profile)
|
|
721
|
+
})
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
return profiles
|
|
725
|
+
}
|
|
702
726
|
}
|
|
703
727
|
|
|
704
728
|
type RecordSubject = { uri: string; cid?: string }
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`admin get multiple subjects with all relevant details gets multiple subjects with records 1`] = `
|
|
4
|
+
Array [
|
|
5
|
+
Object {
|
|
6
|
+
"repo": Object {
|
|
7
|
+
"did": "user(0)",
|
|
8
|
+
"email": "alice@test.com",
|
|
9
|
+
"handle": "alice.test",
|
|
10
|
+
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
11
|
+
"invites": Array [],
|
|
12
|
+
"invitesDisabled": false,
|
|
13
|
+
"labels": Array [
|
|
14
|
+
Object {
|
|
15
|
+
"cts": "1970-01-01T00:00:00.000Z",
|
|
16
|
+
"sig": Object {
|
|
17
|
+
"$bytes": "sig(0)",
|
|
18
|
+
},
|
|
19
|
+
"src": "user(2)",
|
|
20
|
+
"uri": "user(0)",
|
|
21
|
+
"val": "!takedown",
|
|
22
|
+
"ver": 1,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
"moderation": Object {
|
|
26
|
+
"subjectStatus": Object {
|
|
27
|
+
"accountStats": Object {
|
|
28
|
+
"$type": "tools.ozone.moderation.defs#accountStats",
|
|
29
|
+
"appealCount": 0,
|
|
30
|
+
"escalateCount": 0,
|
|
31
|
+
"reportCount": 1,
|
|
32
|
+
"suspendCount": 0,
|
|
33
|
+
"takedownCount": 1,
|
|
34
|
+
},
|
|
35
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
36
|
+
"hosting": Object {
|
|
37
|
+
"$type": "tools.ozone.moderation.defs#accountHosting",
|
|
38
|
+
"status": "unknown",
|
|
39
|
+
},
|
|
40
|
+
"id": 3,
|
|
41
|
+
"lastReportedAt": "1970-01-01T00:00:00.000Z",
|
|
42
|
+
"lastReviewedAt": "1970-01-01T00:00:00.000Z",
|
|
43
|
+
"lastReviewedBy": "user(1)",
|
|
44
|
+
"priorityScore": 0,
|
|
45
|
+
"recordsStats": Object {
|
|
46
|
+
"$type": "tools.ozone.moderation.defs#recordsStats",
|
|
47
|
+
"appealedCount": 0,
|
|
48
|
+
"escalatedCount": 0,
|
|
49
|
+
"pendingCount": 1,
|
|
50
|
+
"processedCount": 0,
|
|
51
|
+
"reportedCount": 1,
|
|
52
|
+
"subjectCount": 1,
|
|
53
|
+
"takendownCount": 0,
|
|
54
|
+
"totalReports": 1,
|
|
55
|
+
},
|
|
56
|
+
"reviewState": "tools.ozone.moderation.defs#reviewClosed",
|
|
57
|
+
"subject": Object {
|
|
58
|
+
"$type": "com.atproto.admin.defs#repoRef",
|
|
59
|
+
"did": "user(0)",
|
|
60
|
+
},
|
|
61
|
+
"subjectBlobCids": Array [],
|
|
62
|
+
"subjectRepoHandle": "alice.test",
|
|
63
|
+
"tags": Array [
|
|
64
|
+
"report:other",
|
|
65
|
+
"lang:und",
|
|
66
|
+
],
|
|
67
|
+
"takendown": true,
|
|
68
|
+
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
"relatedRecords": Array [
|
|
72
|
+
Object {
|
|
73
|
+
"$type": "app.bsky.actor.profile",
|
|
74
|
+
"avatar": Object {
|
|
75
|
+
"$type": "blob",
|
|
76
|
+
"mimeType": "image/jpeg",
|
|
77
|
+
"ref": Object {
|
|
78
|
+
"$link": "cids(0)",
|
|
79
|
+
},
|
|
80
|
+
"size": 3976,
|
|
81
|
+
},
|
|
82
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
83
|
+
"description": "its me!",
|
|
84
|
+
"displayName": "ali",
|
|
85
|
+
"labels": Object {
|
|
86
|
+
"$type": "com.atproto.label.defs#selfLabels",
|
|
87
|
+
"values": Array [
|
|
88
|
+
Object {
|
|
89
|
+
"val": "self-label-a",
|
|
90
|
+
},
|
|
91
|
+
Object {
|
|
92
|
+
"val": "self-label-b",
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
"status": Object {
|
|
100
|
+
"accountStats": Object {
|
|
101
|
+
"$type": "tools.ozone.moderation.defs#accountStats",
|
|
102
|
+
"appealCount": 0,
|
|
103
|
+
"escalateCount": 0,
|
|
104
|
+
"reportCount": 1,
|
|
105
|
+
"suspendCount": 0,
|
|
106
|
+
"takedownCount": 1,
|
|
107
|
+
},
|
|
108
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
109
|
+
"hosting": Object {
|
|
110
|
+
"$type": "tools.ozone.moderation.defs#accountHosting",
|
|
111
|
+
"status": "unknown",
|
|
112
|
+
},
|
|
113
|
+
"id": 3,
|
|
114
|
+
"lastReportedAt": "1970-01-01T00:00:00.000Z",
|
|
115
|
+
"lastReviewedAt": "1970-01-01T00:00:00.000Z",
|
|
116
|
+
"lastReviewedBy": "user(1)",
|
|
117
|
+
"priorityScore": 0,
|
|
118
|
+
"recordsStats": Object {
|
|
119
|
+
"$type": "tools.ozone.moderation.defs#recordsStats",
|
|
120
|
+
"appealedCount": 0,
|
|
121
|
+
"escalatedCount": 0,
|
|
122
|
+
"pendingCount": 1,
|
|
123
|
+
"processedCount": 0,
|
|
124
|
+
"reportedCount": 1,
|
|
125
|
+
"subjectCount": 1,
|
|
126
|
+
"takendownCount": 0,
|
|
127
|
+
"totalReports": 1,
|
|
128
|
+
},
|
|
129
|
+
"reviewState": "tools.ozone.moderation.defs#reviewClosed",
|
|
130
|
+
"subject": Object {
|
|
131
|
+
"$type": "com.atproto.admin.defs#repoRef",
|
|
132
|
+
"did": "user(0)",
|
|
133
|
+
},
|
|
134
|
+
"subjectBlobCids": Array [],
|
|
135
|
+
"subjectRepoHandle": "alice.test",
|
|
136
|
+
"tags": Array [
|
|
137
|
+
"report:other",
|
|
138
|
+
"lang:und",
|
|
139
|
+
],
|
|
140
|
+
"takendown": true,
|
|
141
|
+
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
142
|
+
},
|
|
143
|
+
"subject": "user(0)",
|
|
144
|
+
"type": "account",
|
|
145
|
+
},
|
|
146
|
+
Object {
|
|
147
|
+
"record": Object {
|
|
148
|
+
"blobCids": Array [],
|
|
149
|
+
"blobs": Array [],
|
|
150
|
+
"cid": "cids(1)",
|
|
151
|
+
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
152
|
+
"labels": Array [
|
|
153
|
+
Object {
|
|
154
|
+
"cid": "cids(1)",
|
|
155
|
+
"cts": "1970-01-01T00:00:00.000Z",
|
|
156
|
+
"src": "user(0)",
|
|
157
|
+
"uri": "record(0)",
|
|
158
|
+
"val": "self-label",
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
"moderation": Object {
|
|
162
|
+
"subjectStatus": Object {
|
|
163
|
+
"accountStats": Object {
|
|
164
|
+
"$type": "tools.ozone.moderation.defs#accountStats",
|
|
165
|
+
"appealCount": 0,
|
|
166
|
+
"escalateCount": 0,
|
|
167
|
+
"reportCount": 1,
|
|
168
|
+
"suspendCount": 0,
|
|
169
|
+
"takedownCount": 1,
|
|
170
|
+
},
|
|
171
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
172
|
+
"hosting": Object {
|
|
173
|
+
"$type": "tools.ozone.moderation.defs#recordHosting",
|
|
174
|
+
"status": "unknown",
|
|
175
|
+
},
|
|
176
|
+
"id": 1,
|
|
177
|
+
"lastReportedAt": "1970-01-01T00:00:00.000Z",
|
|
178
|
+
"priorityScore": 0,
|
|
179
|
+
"recordsStats": Object {
|
|
180
|
+
"$type": "tools.ozone.moderation.defs#recordsStats",
|
|
181
|
+
"appealedCount": 0,
|
|
182
|
+
"escalatedCount": 0,
|
|
183
|
+
"pendingCount": 1,
|
|
184
|
+
"processedCount": 0,
|
|
185
|
+
"reportedCount": 1,
|
|
186
|
+
"subjectCount": 1,
|
|
187
|
+
"takendownCount": 0,
|
|
188
|
+
"totalReports": 1,
|
|
189
|
+
},
|
|
190
|
+
"reviewState": "tools.ozone.moderation.defs#reviewOpen",
|
|
191
|
+
"subject": Object {
|
|
192
|
+
"$type": "com.atproto.repo.strongRef",
|
|
193
|
+
"cid": "cids(1)",
|
|
194
|
+
"uri": "record(0)",
|
|
195
|
+
},
|
|
196
|
+
"subjectBlobCids": Array [],
|
|
197
|
+
"subjectRepoHandle": "alice.test",
|
|
198
|
+
"tags": Array [
|
|
199
|
+
"report:spam",
|
|
200
|
+
"lang:en",
|
|
201
|
+
],
|
|
202
|
+
"takendown": false,
|
|
203
|
+
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
"repo": Object {
|
|
207
|
+
"did": "user(0)",
|
|
208
|
+
"handle": "alice.test",
|
|
209
|
+
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
210
|
+
"moderation": Object {
|
|
211
|
+
"subjectStatus": Object {
|
|
212
|
+
"accountStats": Object {
|
|
213
|
+
"$type": "tools.ozone.moderation.defs#accountStats",
|
|
214
|
+
"appealCount": 0,
|
|
215
|
+
"escalateCount": 0,
|
|
216
|
+
"reportCount": 1,
|
|
217
|
+
"suspendCount": 0,
|
|
218
|
+
"takedownCount": 1,
|
|
219
|
+
},
|
|
220
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
221
|
+
"hosting": Object {
|
|
222
|
+
"$type": "tools.ozone.moderation.defs#accountHosting",
|
|
223
|
+
"status": "unknown",
|
|
224
|
+
},
|
|
225
|
+
"id": 3,
|
|
226
|
+
"lastReportedAt": "1970-01-01T00:00:00.000Z",
|
|
227
|
+
"lastReviewedAt": "1970-01-01T00:00:00.000Z",
|
|
228
|
+
"lastReviewedBy": "user(1)",
|
|
229
|
+
"priorityScore": 0,
|
|
230
|
+
"recordsStats": Object {
|
|
231
|
+
"$type": "tools.ozone.moderation.defs#recordsStats",
|
|
232
|
+
"appealedCount": 0,
|
|
233
|
+
"escalatedCount": 0,
|
|
234
|
+
"pendingCount": 1,
|
|
235
|
+
"processedCount": 0,
|
|
236
|
+
"reportedCount": 1,
|
|
237
|
+
"subjectCount": 1,
|
|
238
|
+
"takendownCount": 0,
|
|
239
|
+
"totalReports": 1,
|
|
240
|
+
},
|
|
241
|
+
"reviewState": "tools.ozone.moderation.defs#reviewClosed",
|
|
242
|
+
"subject": Object {
|
|
243
|
+
"$type": "com.atproto.admin.defs#repoRef",
|
|
244
|
+
"did": "user(0)",
|
|
245
|
+
},
|
|
246
|
+
"subjectBlobCids": Array [],
|
|
247
|
+
"subjectRepoHandle": "alice.test",
|
|
248
|
+
"tags": Array [
|
|
249
|
+
"report:other",
|
|
250
|
+
"lang:und",
|
|
251
|
+
],
|
|
252
|
+
"takendown": true,
|
|
253
|
+
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
"relatedRecords": Array [
|
|
257
|
+
Object {
|
|
258
|
+
"$type": "app.bsky.actor.profile",
|
|
259
|
+
"avatar": Object {
|
|
260
|
+
"$type": "blob",
|
|
261
|
+
"mimeType": "image/jpeg",
|
|
262
|
+
"ref": Object {
|
|
263
|
+
"$link": "cids(0)",
|
|
264
|
+
},
|
|
265
|
+
"size": 3976,
|
|
266
|
+
},
|
|
267
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
268
|
+
"description": "its me!",
|
|
269
|
+
"displayName": "ali",
|
|
270
|
+
"labels": Object {
|
|
271
|
+
"$type": "com.atproto.label.defs#selfLabels",
|
|
272
|
+
"values": Array [
|
|
273
|
+
Object {
|
|
274
|
+
"val": "self-label-a",
|
|
275
|
+
},
|
|
276
|
+
Object {
|
|
277
|
+
"val": "self-label-b",
|
|
278
|
+
},
|
|
279
|
+
],
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
],
|
|
283
|
+
},
|
|
284
|
+
"uri": "record(0)",
|
|
285
|
+
"value": Object {
|
|
286
|
+
"$type": "app.bsky.feed.post",
|
|
287
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
288
|
+
"labels": Object {
|
|
289
|
+
"$type": "com.atproto.label.defs#selfLabels",
|
|
290
|
+
"values": Array [
|
|
291
|
+
Object {
|
|
292
|
+
"val": "self-label",
|
|
293
|
+
},
|
|
294
|
+
],
|
|
295
|
+
},
|
|
296
|
+
"text": "hey there",
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
"repo": Object {
|
|
300
|
+
"did": "user(0)",
|
|
301
|
+
"email": "alice@test.com",
|
|
302
|
+
"handle": "alice.test",
|
|
303
|
+
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
304
|
+
"invites": Array [],
|
|
305
|
+
"invitesDisabled": false,
|
|
306
|
+
"labels": Array [
|
|
307
|
+
Object {
|
|
308
|
+
"cts": "1970-01-01T00:00:00.000Z",
|
|
309
|
+
"sig": Object {
|
|
310
|
+
"$bytes": "sig(0)",
|
|
311
|
+
},
|
|
312
|
+
"src": "user(2)",
|
|
313
|
+
"uri": "user(0)",
|
|
314
|
+
"val": "!takedown",
|
|
315
|
+
"ver": 1,
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
"moderation": Object {
|
|
319
|
+
"subjectStatus": Object {
|
|
320
|
+
"accountStats": Object {
|
|
321
|
+
"$type": "tools.ozone.moderation.defs#accountStats",
|
|
322
|
+
"appealCount": 0,
|
|
323
|
+
"escalateCount": 0,
|
|
324
|
+
"reportCount": 1,
|
|
325
|
+
"suspendCount": 0,
|
|
326
|
+
"takedownCount": 1,
|
|
327
|
+
},
|
|
328
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
329
|
+
"hosting": Object {
|
|
330
|
+
"$type": "tools.ozone.moderation.defs#accountHosting",
|
|
331
|
+
"status": "unknown",
|
|
332
|
+
},
|
|
333
|
+
"id": 3,
|
|
334
|
+
"lastReportedAt": "1970-01-01T00:00:00.000Z",
|
|
335
|
+
"lastReviewedAt": "1970-01-01T00:00:00.000Z",
|
|
336
|
+
"lastReviewedBy": "user(1)",
|
|
337
|
+
"priorityScore": 0,
|
|
338
|
+
"recordsStats": Object {
|
|
339
|
+
"$type": "tools.ozone.moderation.defs#recordsStats",
|
|
340
|
+
"appealedCount": 0,
|
|
341
|
+
"escalatedCount": 0,
|
|
342
|
+
"pendingCount": 1,
|
|
343
|
+
"processedCount": 0,
|
|
344
|
+
"reportedCount": 1,
|
|
345
|
+
"subjectCount": 1,
|
|
346
|
+
"takendownCount": 0,
|
|
347
|
+
"totalReports": 1,
|
|
348
|
+
},
|
|
349
|
+
"reviewState": "tools.ozone.moderation.defs#reviewClosed",
|
|
350
|
+
"subject": Object {
|
|
351
|
+
"$type": "com.atproto.admin.defs#repoRef",
|
|
352
|
+
"did": "user(0)",
|
|
353
|
+
},
|
|
354
|
+
"subjectBlobCids": Array [],
|
|
355
|
+
"subjectRepoHandle": "alice.test",
|
|
356
|
+
"tags": Array [
|
|
357
|
+
"report:other",
|
|
358
|
+
"lang:und",
|
|
359
|
+
],
|
|
360
|
+
"takendown": true,
|
|
361
|
+
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
"relatedRecords": Array [
|
|
365
|
+
Object {
|
|
366
|
+
"$type": "app.bsky.actor.profile",
|
|
367
|
+
"avatar": Object {
|
|
368
|
+
"$type": "blob",
|
|
369
|
+
"mimeType": "image/jpeg",
|
|
370
|
+
"ref": Object {
|
|
371
|
+
"$link": "cids(0)",
|
|
372
|
+
},
|
|
373
|
+
"size": 3976,
|
|
374
|
+
},
|
|
375
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
376
|
+
"description": "its me!",
|
|
377
|
+
"displayName": "ali",
|
|
378
|
+
"labels": Object {
|
|
379
|
+
"$type": "com.atproto.label.defs#selfLabels",
|
|
380
|
+
"values": Array [
|
|
381
|
+
Object {
|
|
382
|
+
"val": "self-label-a",
|
|
383
|
+
},
|
|
384
|
+
Object {
|
|
385
|
+
"val": "self-label-b",
|
|
386
|
+
},
|
|
387
|
+
],
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
],
|
|
391
|
+
},
|
|
392
|
+
"status": Object {
|
|
393
|
+
"accountStats": Object {
|
|
394
|
+
"$type": "tools.ozone.moderation.defs#accountStats",
|
|
395
|
+
"appealCount": 0,
|
|
396
|
+
"escalateCount": 0,
|
|
397
|
+
"reportCount": 1,
|
|
398
|
+
"suspendCount": 0,
|
|
399
|
+
"takedownCount": 1,
|
|
400
|
+
},
|
|
401
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
402
|
+
"hosting": Object {
|
|
403
|
+
"$type": "tools.ozone.moderation.defs#recordHosting",
|
|
404
|
+
"status": "unknown",
|
|
405
|
+
},
|
|
406
|
+
"id": 1,
|
|
407
|
+
"lastReportedAt": "1970-01-01T00:00:00.000Z",
|
|
408
|
+
"priorityScore": 0,
|
|
409
|
+
"recordsStats": Object {
|
|
410
|
+
"$type": "tools.ozone.moderation.defs#recordsStats",
|
|
411
|
+
"appealedCount": 0,
|
|
412
|
+
"escalatedCount": 0,
|
|
413
|
+
"pendingCount": 1,
|
|
414
|
+
"processedCount": 0,
|
|
415
|
+
"reportedCount": 1,
|
|
416
|
+
"subjectCount": 1,
|
|
417
|
+
"takendownCount": 0,
|
|
418
|
+
"totalReports": 1,
|
|
419
|
+
},
|
|
420
|
+
"reviewState": "tools.ozone.moderation.defs#reviewOpen",
|
|
421
|
+
"subject": Object {
|
|
422
|
+
"$type": "com.atproto.repo.strongRef",
|
|
423
|
+
"cid": "cids(1)",
|
|
424
|
+
"uri": "record(0)",
|
|
425
|
+
},
|
|
426
|
+
"subjectBlobCids": Array [],
|
|
427
|
+
"subjectRepoHandle": "alice.test",
|
|
428
|
+
"tags": Array [
|
|
429
|
+
"report:spam",
|
|
430
|
+
"lang:en",
|
|
431
|
+
],
|
|
432
|
+
"takendown": false,
|
|
433
|
+
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
434
|
+
},
|
|
435
|
+
"subject": "record(0)",
|
|
436
|
+
"type": "record",
|
|
437
|
+
},
|
|
438
|
+
]
|
|
439
|
+
`;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AtpAgent } from '@atproto/api'
|
|
2
|
+
import {
|
|
3
|
+
ModeratorClient,
|
|
4
|
+
SeedClient,
|
|
5
|
+
TestNetwork,
|
|
6
|
+
TestOzone,
|
|
7
|
+
basicSeed,
|
|
8
|
+
} from '@atproto/dev-env'
|
|
9
|
+
import { ids } from '../src/lexicon/lexicons'
|
|
10
|
+
import {
|
|
11
|
+
REASONOTHER,
|
|
12
|
+
REASONSPAM,
|
|
13
|
+
} from '../src/lexicon/types/com/atproto/moderation/defs'
|
|
14
|
+
import { forSnapshot } from './_util'
|
|
15
|
+
|
|
16
|
+
describe('admin get multiple subjects with all relevant details', () => {
|
|
17
|
+
let network: TestNetwork
|
|
18
|
+
let ozone: TestOzone
|
|
19
|
+
let agent: AtpAgent
|
|
20
|
+
let sc: SeedClient
|
|
21
|
+
let modClient: ModeratorClient
|
|
22
|
+
|
|
23
|
+
beforeAll(async () => {
|
|
24
|
+
network = await TestNetwork.create({
|
|
25
|
+
dbPostgresSchema: 'ozone_admin_get_subjects',
|
|
26
|
+
})
|
|
27
|
+
ozone = network.ozone
|
|
28
|
+
agent = ozone.getClient()
|
|
29
|
+
sc = network.getSeedClient()
|
|
30
|
+
modClient = ozone.getModClient()
|
|
31
|
+
await basicSeed(sc)
|
|
32
|
+
await network.processAll()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
beforeEach(async () => {
|
|
36
|
+
await network.processAll()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
afterAll(async () => {
|
|
40
|
+
await network.close()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
beforeAll(async () => {
|
|
44
|
+
await sc.createReport({
|
|
45
|
+
reportedBy: sc.dids.bob,
|
|
46
|
+
reasonType: REASONSPAM,
|
|
47
|
+
subject: {
|
|
48
|
+
$type: 'com.atproto.repo.strongRef',
|
|
49
|
+
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
50
|
+
cid: sc.posts[sc.dids.alice][0].ref.cidStr,
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
await sc.createReport({
|
|
54
|
+
reportedBy: sc.dids.carol,
|
|
55
|
+
reasonType: REASONOTHER,
|
|
56
|
+
reason: 'defamation',
|
|
57
|
+
subject: {
|
|
58
|
+
$type: 'com.atproto.admin.defs#repoRef',
|
|
59
|
+
did: sc.dids.alice,
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
await modClient.emitEvent({
|
|
63
|
+
event: { $type: 'tools.ozone.moderation.defs#modEventTakedown' },
|
|
64
|
+
subject: {
|
|
65
|
+
$type: 'com.atproto.admin.defs#repoRef',
|
|
66
|
+
did: sc.dids.alice,
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('gets multiple subjects with records', async () => {
|
|
72
|
+
const {
|
|
73
|
+
data: { subjects },
|
|
74
|
+
} = await agent.tools.ozone.moderation.getSubjects(
|
|
75
|
+
{ subjects: [sc.dids.alice, sc.posts[sc.dids.alice][0].ref.uriStr] },
|
|
76
|
+
{ headers: await ozone.modHeaders(ids.ToolsOzoneModerationGetSubjects) },
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
expect(forSnapshot(subjects)).toMatchSnapshot()
|
|
80
|
+
})
|
|
81
|
+
})
|