@atproto/bsky 0.0.10 → 0.0.12
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 +26 -0
- package/dist/api/com/atproto/admin/util.d.ts +5 -0
- package/dist/config.d.ts +2 -0
- package/dist/context.d.ts +8 -0
- package/dist/db/index.js +51 -2
- package/dist/db/index.js.map +3 -3
- package/dist/db/migrations/20230929T192920807Z-record-cursor-indexes.d.ts +3 -0
- package/dist/db/migrations/index.d.ts +1 -0
- package/dist/did-cache.d.ts +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1818 -580
- package/dist/index.js.map +3 -3
- package/dist/lexicon/index.d.ts +16 -0
- package/dist/lexicon/lexicons.d.ts +330 -3
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/admin/defs.d.ts +28 -0
- package/dist/lexicon/types/com/atproto/admin/getAccountInfo.d.ts +29 -0
- package/dist/lexicon/types/com/atproto/admin/getSubjectStatus.d.ts +39 -0
- package/dist/lexicon/types/com/atproto/admin/searchRepos.d.ts +0 -1
- package/dist/lexicon/types/com/atproto/admin/updateSubjectStatus.d.ts +46 -0
- package/dist/lexicon/types/com/atproto/server/confirmEmail.d.ts +27 -0
- package/dist/lexicon/types/com/atproto/server/createAccount.d.ts +2 -0
- package/dist/lexicon/types/com/atproto/server/createSession.d.ts +2 -0
- package/dist/lexicon/types/com/atproto/server/getSession.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/server/refreshSession.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/server/requestEmailConfirmation.d.ts +19 -0
- package/dist/lexicon/types/com/atproto/server/requestEmailUpdate.d.ts +30 -0
- package/dist/lexicon/types/com/atproto/server/reserveSigningKey.d.ts +30 -0
- package/dist/lexicon/types/com/atproto/server/updateEmail.d.ts +27 -0
- package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts +1 -0
- package/dist/services/actor/index.d.ts +2 -2
- package/dist/services/actor/types.d.ts +1 -0
- package/dist/services/graph/index.d.ts +2 -0
- package/dist/services/moderation/index.d.ts +13 -3
- package/dist/services/util/search.d.ts +3 -3
- package/package.json +13 -14
- package/src/api/app/bsky/actor/searchActors.ts +36 -22
- package/src/api/app/bsky/actor/searchActorsTypeahead.ts +24 -17
- package/src/api/app/bsky/feed/getAuthorFeed.ts +2 -2
- package/src/api/app/bsky/feed/getPostThread.ts +2 -2
- package/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts +1 -0
- package/src/api/app/bsky/notification/listNotifications.ts +33 -22
- package/src/api/com/atproto/admin/getModerationAction.ts +28 -2
- package/src/api/com/atproto/admin/getModerationReport.ts +27 -2
- package/src/api/com/atproto/admin/getRecord.ts +14 -2
- package/src/api/com/atproto/admin/getRepo.ts +13 -2
- package/src/api/com/atproto/admin/reverseModerationAction.ts +31 -5
- package/src/api/com/atproto/admin/searchRepos.ts +6 -12
- package/src/api/com/atproto/admin/takeModerationAction.ts +41 -7
- package/src/api/com/atproto/admin/util.ts +50 -0
- package/src/api/well-known.ts +8 -0
- package/src/auth.ts +12 -5
- package/src/auto-moderator/index.ts +1 -0
- package/src/config.ts +7 -0
- package/src/context.ts +30 -0
- package/src/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +40 -0
- package/src/db/migrations/index.ts +1 -0
- package/src/did-cache.ts +29 -14
- package/src/feed-gen/with-friends.ts +2 -2
- package/src/index.ts +9 -1
- package/src/indexer/subscription.ts +1 -21
- package/src/lexicon/index.ts +96 -0
- package/src/lexicon/lexicons.ts +368 -4
- package/src/lexicon/types/app/bsky/actor/defs.ts +1 -0
- package/src/lexicon/types/com/atproto/admin/defs.ts +61 -0
- package/src/lexicon/types/com/atproto/admin/getAccountInfo.ts +41 -0
- package/src/lexicon/types/com/atproto/admin/getSubjectStatus.ts +54 -0
- package/src/lexicon/types/com/atproto/admin/searchRepos.ts +0 -1
- package/src/lexicon/types/com/atproto/admin/updateSubjectStatus.ts +61 -0
- package/src/lexicon/types/com/atproto/server/confirmEmail.ts +40 -0
- package/src/lexicon/types/com/atproto/server/createAccount.ts +2 -0
- package/src/lexicon/types/com/atproto/server/createSession.ts +2 -0
- package/src/lexicon/types/com/atproto/server/getSession.ts +1 -0
- package/src/lexicon/types/com/atproto/server/refreshSession.ts +1 -0
- package/src/lexicon/types/com/atproto/server/requestEmailConfirmation.ts +31 -0
- package/src/lexicon/types/com/atproto/server/requestEmailUpdate.ts +43 -0
- package/src/lexicon/types/com/atproto/server/reserveSigningKey.ts +44 -0
- package/src/lexicon/types/com/atproto/server/updateEmail.ts +41 -0
- package/src/lexicon/types/com/atproto/sync/listRepos.ts +1 -0
- package/src/logger.ts +8 -0
- package/src/services/actor/index.ts +16 -10
- package/src/services/actor/types.ts +1 -0
- package/src/services/actor/views.ts +26 -8
- package/src/services/graph/index.ts +26 -7
- package/src/services/indexing/index.ts +15 -17
- package/src/services/moderation/index.ts +94 -14
- package/src/services/moderation/views.ts +1 -0
- package/src/services/util/search.ts +24 -23
- package/tests/__snapshots__/feed-generation.test.ts.snap +12 -12
- package/tests/__snapshots__/indexing.test.ts.snap +4 -4
- package/tests/admin/__snapshots__/get-moderation-action.test.ts.snap +172 -0
- package/tests/admin/__snapshots__/get-moderation-actions.test.ts.snap +178 -0
- package/tests/admin/__snapshots__/get-moderation-report.test.ts.snap +177 -0
- package/tests/admin/__snapshots__/get-moderation-reports.test.ts.snap +307 -0
- package/tests/admin/__snapshots__/get-record.test.ts.snap +275 -0
- package/tests/admin/__snapshots__/get-repo.test.ts.snap +103 -0
- package/tests/admin/get-moderation-action.test.ts +100 -0
- package/tests/admin/get-moderation-actions.test.ts +164 -0
- package/tests/admin/get-moderation-report.test.ts +100 -0
- package/tests/admin/get-moderation-reports.test.ts +332 -0
- package/tests/admin/get-record.test.ts +115 -0
- package/tests/admin/get-repo.test.ts +101 -0
- package/tests/{moderation.test.ts → admin/moderation.test.ts} +107 -9
- package/tests/admin/repo-search.test.ts +124 -0
- package/tests/algos/hot-classic.test.ts +3 -5
- package/tests/algos/whats-hot.test.ts +3 -5
- package/tests/algos/with-friends.test.ts +2 -4
- package/tests/auth.test.ts +64 -0
- package/tests/auto-moderator/fuzzy-matcher.test.ts +2 -3
- package/tests/auto-moderator/labeler.test.ts +5 -7
- package/tests/auto-moderator/takedowns.test.ts +11 -12
- package/tests/blob-resolver.test.ts +1 -3
- package/tests/did-cache.test.ts +2 -5
- package/tests/feed-generation.test.ts +8 -6
- package/tests/handle-invalidation.test.ts +2 -3
- package/tests/image/server.test.ts +1 -4
- package/tests/image/sharp.test.ts +1 -1
- package/tests/indexing.test.ts +4 -4
- package/tests/notification-server.test.ts +2 -3
- package/tests/pipeline/backpressure.test.ts +2 -3
- package/tests/pipeline/reingest.test.ts +7 -4
- package/tests/pipeline/repartition.test.ts +2 -3
- package/tests/reprocessing.test.ts +2 -6
- package/tests/seeds/basic.ts +4 -4
- package/tests/seeds/follows.ts +1 -1
- package/tests/seeds/likes.ts +1 -1
- package/tests/seeds/reposts.ts +1 -1
- package/tests/seeds/users-bulk.ts +1 -1
- package/tests/seeds/users.ts +1 -1
- package/tests/server.test.ts +1 -3
- package/tests/subscription/repo.test.ts +2 -4
- package/tests/views/__snapshots__/author-feed.test.ts.snap +24 -24
- package/tests/views/__snapshots__/block-lists.test.ts.snap +42 -7
- package/tests/views/__snapshots__/blocks.test.ts.snap +2 -2
- package/tests/views/__snapshots__/list-feed.test.ts.snap +6 -6
- package/tests/views/__snapshots__/mute-lists.test.ts.snap +15 -4
- package/tests/views/__snapshots__/mutes.test.ts.snap +2 -2
- package/tests/views/__snapshots__/notifications.test.ts.snap +2 -2
- package/tests/views/__snapshots__/posts.test.ts.snap +8 -8
- package/tests/views/__snapshots__/thread.test.ts.snap +10 -10
- package/tests/views/__snapshots__/timeline.test.ts.snap +58 -58
- package/tests/views/actor-likes.test.ts +2 -3
- package/tests/views/actor-search.test.ts +5 -5
- package/tests/views/admin/repo-search.test.ts +2 -4
- package/tests/views/author-feed.test.ts +2 -4
- package/tests/views/block-lists.test.ts +34 -7
- package/tests/views/blocks.test.ts +6 -3
- package/tests/views/follows.test.ts +2 -4
- package/tests/views/likes.test.ts +2 -5
- package/tests/views/list-feed.test.ts +2 -4
- package/tests/views/mute-lists.test.ts +23 -5
- package/tests/views/mutes.test.ts +2 -5
- package/tests/views/notifications.test.ts +2 -4
- package/tests/views/posts.test.ts +2 -5
- package/tests/views/profile.test.ts +4 -5
- package/tests/views/reposts.test.ts +2 -4
- package/tests/views/suggested-follows.test.ts +2 -3
- package/tests/views/suggestions.test.ts +2 -4
- package/tests/views/thread.test.ts +2 -4
- package/tests/views/threadgating.test.ts +2 -3
- package/tests/views/timeline.test.ts +2 -4
- package/dist/env.d.ts +0 -1
- package/example.dev.env +0 -5
- package/src/env.ts +0 -9
- package/tests/seeds/client.ts +0 -466
- /package/tests/{__snapshots__ → admin/__snapshots__}/moderation.test.ts.snap +0 -0
- /package/tests/{image/fixtures → sample-img}/at.png +0 -0
- /package/tests/{image/fixtures → sample-img}/hd-key.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-alt.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-landscape-large.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-landscape-small.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-portrait-large.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-portrait-small.jpg +0 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`admin get record view gets a record by uri and cid. 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"blobCids": Array [],
|
|
6
|
+
"blobs": Array [],
|
|
7
|
+
"cid": "cids(0)",
|
|
8
|
+
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
9
|
+
"labels": Array [
|
|
10
|
+
Object {
|
|
11
|
+
"cid": "cids(0)",
|
|
12
|
+
"cts": "1970-01-01T00:00:00.000Z",
|
|
13
|
+
"neg": false,
|
|
14
|
+
"src": "user(0)",
|
|
15
|
+
"uri": "record(0)",
|
|
16
|
+
"val": "self-label",
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
"moderation": Object {
|
|
20
|
+
"actions": Array [
|
|
21
|
+
Object {
|
|
22
|
+
"action": "com.atproto.admin.defs#takedown",
|
|
23
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
24
|
+
"createdBy": "did:example:admin",
|
|
25
|
+
"id": 2,
|
|
26
|
+
"reason": "X",
|
|
27
|
+
"resolvedReportIds": Array [],
|
|
28
|
+
"subject": Object {
|
|
29
|
+
"$type": "com.atproto.repo.strongRef",
|
|
30
|
+
"cid": "cids(0)",
|
|
31
|
+
"uri": "record(0)",
|
|
32
|
+
},
|
|
33
|
+
"subjectBlobCids": Array [],
|
|
34
|
+
},
|
|
35
|
+
Object {
|
|
36
|
+
"action": "com.atproto.admin.defs#acknowledge",
|
|
37
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
38
|
+
"createdBy": "did:example:admin",
|
|
39
|
+
"id": 1,
|
|
40
|
+
"reason": "X",
|
|
41
|
+
"resolvedReportIds": Array [],
|
|
42
|
+
"reversal": Object {
|
|
43
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
44
|
+
"createdBy": "did:example:admin",
|
|
45
|
+
"reason": "X",
|
|
46
|
+
},
|
|
47
|
+
"subject": Object {
|
|
48
|
+
"$type": "com.atproto.repo.strongRef",
|
|
49
|
+
"cid": "cids(0)",
|
|
50
|
+
"uri": "record(0)",
|
|
51
|
+
},
|
|
52
|
+
"subjectBlobCids": Array [],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
"currentAction": Object {
|
|
56
|
+
"action": "com.atproto.admin.defs#takedown",
|
|
57
|
+
"id": 2,
|
|
58
|
+
},
|
|
59
|
+
"reports": Array [
|
|
60
|
+
Object {
|
|
61
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
62
|
+
"id": 2,
|
|
63
|
+
"reason": "defamation",
|
|
64
|
+
"reasonType": "com.atproto.moderation.defs#reasonOther",
|
|
65
|
+
"reportedBy": "user(1)",
|
|
66
|
+
"resolvedByActionIds": Array [],
|
|
67
|
+
"subject": Object {
|
|
68
|
+
"$type": "com.atproto.repo.strongRef",
|
|
69
|
+
"cid": "cids(0)",
|
|
70
|
+
"uri": "record(0)",
|
|
71
|
+
},
|
|
72
|
+
"subjectRepoHandle": "alice.test",
|
|
73
|
+
},
|
|
74
|
+
Object {
|
|
75
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
76
|
+
"id": 1,
|
|
77
|
+
"reasonType": "com.atproto.moderation.defs#reasonSpam",
|
|
78
|
+
"reportedBy": "user(2)",
|
|
79
|
+
"resolvedByActionIds": Array [],
|
|
80
|
+
"subject": Object {
|
|
81
|
+
"$type": "com.atproto.repo.strongRef",
|
|
82
|
+
"cid": "cids(0)",
|
|
83
|
+
"uri": "record(0)",
|
|
84
|
+
},
|
|
85
|
+
"subjectRepoHandle": "alice.test",
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
"repo": Object {
|
|
90
|
+
"did": "user(0)",
|
|
91
|
+
"email": "alice@test.com",
|
|
92
|
+
"handle": "alice.test",
|
|
93
|
+
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
94
|
+
"invitesDisabled": false,
|
|
95
|
+
"moderation": Object {},
|
|
96
|
+
"relatedRecords": Array [
|
|
97
|
+
Object {
|
|
98
|
+
"$type": "app.bsky.actor.profile",
|
|
99
|
+
"avatar": Object {
|
|
100
|
+
"$type": "blob",
|
|
101
|
+
"mimeType": "image/jpeg",
|
|
102
|
+
"ref": Object {
|
|
103
|
+
"$link": "cids(1)",
|
|
104
|
+
},
|
|
105
|
+
"size": 3976,
|
|
106
|
+
},
|
|
107
|
+
"description": "its me!",
|
|
108
|
+
"displayName": "ali",
|
|
109
|
+
"labels": Object {
|
|
110
|
+
"$type": "com.atproto.label.defs#selfLabels",
|
|
111
|
+
"values": Array [
|
|
112
|
+
Object {
|
|
113
|
+
"val": "self-label-a",
|
|
114
|
+
},
|
|
115
|
+
Object {
|
|
116
|
+
"val": "self-label-b",
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
"uri": "record(0)",
|
|
124
|
+
"value": Object {
|
|
125
|
+
"$type": "app.bsky.feed.post",
|
|
126
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
127
|
+
"labels": Object {
|
|
128
|
+
"$type": "com.atproto.label.defs#selfLabels",
|
|
129
|
+
"values": Array [
|
|
130
|
+
Object {
|
|
131
|
+
"val": "self-label",
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
"text": "hey there",
|
|
136
|
+
},
|
|
137
|
+
}
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
exports[`admin get record view gets a record by uri, even when taken down. 1`] = `
|
|
141
|
+
Object {
|
|
142
|
+
"blobCids": Array [],
|
|
143
|
+
"blobs": Array [],
|
|
144
|
+
"cid": "cids(0)",
|
|
145
|
+
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
146
|
+
"labels": Array [
|
|
147
|
+
Object {
|
|
148
|
+
"cid": "cids(0)",
|
|
149
|
+
"cts": "1970-01-01T00:00:00.000Z",
|
|
150
|
+
"neg": false,
|
|
151
|
+
"src": "user(0)",
|
|
152
|
+
"uri": "record(0)",
|
|
153
|
+
"val": "self-label",
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
"moderation": Object {
|
|
157
|
+
"actions": Array [
|
|
158
|
+
Object {
|
|
159
|
+
"action": "com.atproto.admin.defs#takedown",
|
|
160
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
161
|
+
"createdBy": "did:example:admin",
|
|
162
|
+
"id": 2,
|
|
163
|
+
"reason": "X",
|
|
164
|
+
"resolvedReportIds": Array [],
|
|
165
|
+
"subject": Object {
|
|
166
|
+
"$type": "com.atproto.repo.strongRef",
|
|
167
|
+
"cid": "cids(0)",
|
|
168
|
+
"uri": "record(0)",
|
|
169
|
+
},
|
|
170
|
+
"subjectBlobCids": Array [],
|
|
171
|
+
},
|
|
172
|
+
Object {
|
|
173
|
+
"action": "com.atproto.admin.defs#acknowledge",
|
|
174
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
175
|
+
"createdBy": "did:example:admin",
|
|
176
|
+
"id": 1,
|
|
177
|
+
"reason": "X",
|
|
178
|
+
"resolvedReportIds": Array [],
|
|
179
|
+
"reversal": Object {
|
|
180
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
181
|
+
"createdBy": "did:example:admin",
|
|
182
|
+
"reason": "X",
|
|
183
|
+
},
|
|
184
|
+
"subject": Object {
|
|
185
|
+
"$type": "com.atproto.repo.strongRef",
|
|
186
|
+
"cid": "cids(0)",
|
|
187
|
+
"uri": "record(0)",
|
|
188
|
+
},
|
|
189
|
+
"subjectBlobCids": Array [],
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
"currentAction": Object {
|
|
193
|
+
"action": "com.atproto.admin.defs#takedown",
|
|
194
|
+
"id": 2,
|
|
195
|
+
},
|
|
196
|
+
"reports": Array [
|
|
197
|
+
Object {
|
|
198
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
199
|
+
"id": 2,
|
|
200
|
+
"reason": "defamation",
|
|
201
|
+
"reasonType": "com.atproto.moderation.defs#reasonOther",
|
|
202
|
+
"reportedBy": "user(1)",
|
|
203
|
+
"resolvedByActionIds": Array [],
|
|
204
|
+
"subject": Object {
|
|
205
|
+
"$type": "com.atproto.repo.strongRef",
|
|
206
|
+
"cid": "cids(0)",
|
|
207
|
+
"uri": "record(0)",
|
|
208
|
+
},
|
|
209
|
+
"subjectRepoHandle": "alice.test",
|
|
210
|
+
},
|
|
211
|
+
Object {
|
|
212
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
213
|
+
"id": 1,
|
|
214
|
+
"reasonType": "com.atproto.moderation.defs#reasonSpam",
|
|
215
|
+
"reportedBy": "user(2)",
|
|
216
|
+
"resolvedByActionIds": Array [],
|
|
217
|
+
"subject": Object {
|
|
218
|
+
"$type": "com.atproto.repo.strongRef",
|
|
219
|
+
"cid": "cids(0)",
|
|
220
|
+
"uri": "record(0)",
|
|
221
|
+
},
|
|
222
|
+
"subjectRepoHandle": "alice.test",
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
"repo": Object {
|
|
227
|
+
"did": "user(0)",
|
|
228
|
+
"email": "alice@test.com",
|
|
229
|
+
"handle": "alice.test",
|
|
230
|
+
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
231
|
+
"invitesDisabled": false,
|
|
232
|
+
"moderation": Object {},
|
|
233
|
+
"relatedRecords": Array [
|
|
234
|
+
Object {
|
|
235
|
+
"$type": "app.bsky.actor.profile",
|
|
236
|
+
"avatar": Object {
|
|
237
|
+
"$type": "blob",
|
|
238
|
+
"mimeType": "image/jpeg",
|
|
239
|
+
"ref": Object {
|
|
240
|
+
"$link": "cids(1)",
|
|
241
|
+
},
|
|
242
|
+
"size": 3976,
|
|
243
|
+
},
|
|
244
|
+
"description": "its me!",
|
|
245
|
+
"displayName": "ali",
|
|
246
|
+
"labels": Object {
|
|
247
|
+
"$type": "com.atproto.label.defs#selfLabels",
|
|
248
|
+
"values": Array [
|
|
249
|
+
Object {
|
|
250
|
+
"val": "self-label-a",
|
|
251
|
+
},
|
|
252
|
+
Object {
|
|
253
|
+
"val": "self-label-b",
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
},
|
|
260
|
+
"uri": "record(0)",
|
|
261
|
+
"value": Object {
|
|
262
|
+
"$type": "app.bsky.feed.post",
|
|
263
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
264
|
+
"labels": Object {
|
|
265
|
+
"$type": "com.atproto.label.defs#selfLabels",
|
|
266
|
+
"values": Array [
|
|
267
|
+
Object {
|
|
268
|
+
"val": "self-label",
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
"text": "hey there",
|
|
273
|
+
},
|
|
274
|
+
}
|
|
275
|
+
`;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`admin get repo view gets a repo by did, even when taken down. 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"did": "user(0)",
|
|
6
|
+
"email": "alice@test.com",
|
|
7
|
+
"handle": "alice.test",
|
|
8
|
+
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
9
|
+
"invites": Array [],
|
|
10
|
+
"invitesDisabled": false,
|
|
11
|
+
"labels": Array [],
|
|
12
|
+
"moderation": Object {
|
|
13
|
+
"actions": Array [
|
|
14
|
+
Object {
|
|
15
|
+
"action": "com.atproto.admin.defs#takedown",
|
|
16
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
17
|
+
"createdBy": "did:example:admin",
|
|
18
|
+
"id": 2,
|
|
19
|
+
"reason": "X",
|
|
20
|
+
"resolvedReportIds": Array [],
|
|
21
|
+
"subject": Object {
|
|
22
|
+
"$type": "com.atproto.admin.defs#repoRef",
|
|
23
|
+
"did": "user(0)",
|
|
24
|
+
},
|
|
25
|
+
"subjectBlobCids": Array [],
|
|
26
|
+
},
|
|
27
|
+
Object {
|
|
28
|
+
"action": "com.atproto.admin.defs#acknowledge",
|
|
29
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
30
|
+
"createdBy": "did:example:admin",
|
|
31
|
+
"id": 1,
|
|
32
|
+
"reason": "X",
|
|
33
|
+
"resolvedReportIds": Array [],
|
|
34
|
+
"reversal": Object {
|
|
35
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
36
|
+
"createdBy": "did:example:admin",
|
|
37
|
+
"reason": "X",
|
|
38
|
+
},
|
|
39
|
+
"subject": Object {
|
|
40
|
+
"$type": "com.atproto.admin.defs#repoRef",
|
|
41
|
+
"did": "user(0)",
|
|
42
|
+
},
|
|
43
|
+
"subjectBlobCids": Array [],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
"currentAction": Object {
|
|
47
|
+
"action": "com.atproto.admin.defs#takedown",
|
|
48
|
+
"id": 2,
|
|
49
|
+
},
|
|
50
|
+
"reports": Array [
|
|
51
|
+
Object {
|
|
52
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
53
|
+
"id": 2,
|
|
54
|
+
"reason": "defamation",
|
|
55
|
+
"reasonType": "com.atproto.moderation.defs#reasonOther",
|
|
56
|
+
"reportedBy": "user(1)",
|
|
57
|
+
"resolvedByActionIds": Array [],
|
|
58
|
+
"subject": Object {
|
|
59
|
+
"$type": "com.atproto.admin.defs#repoRef",
|
|
60
|
+
"did": "user(0)",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
Object {
|
|
64
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
65
|
+
"id": 1,
|
|
66
|
+
"reasonType": "com.atproto.moderation.defs#reasonSpam",
|
|
67
|
+
"reportedBy": "user(2)",
|
|
68
|
+
"resolvedByActionIds": Array [],
|
|
69
|
+
"subject": Object {
|
|
70
|
+
"$type": "com.atproto.admin.defs#repoRef",
|
|
71
|
+
"did": "user(0)",
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
"relatedRecords": Array [
|
|
77
|
+
Object {
|
|
78
|
+
"$type": "app.bsky.actor.profile",
|
|
79
|
+
"avatar": Object {
|
|
80
|
+
"$type": "blob",
|
|
81
|
+
"mimeType": "image/jpeg",
|
|
82
|
+
"ref": Object {
|
|
83
|
+
"$link": "cids(0)",
|
|
84
|
+
},
|
|
85
|
+
"size": 3976,
|
|
86
|
+
},
|
|
87
|
+
"description": "its me!",
|
|
88
|
+
"displayName": "ali",
|
|
89
|
+
"labels": Object {
|
|
90
|
+
"$type": "com.atproto.label.defs#selfLabels",
|
|
91
|
+
"values": Array [
|
|
92
|
+
Object {
|
|
93
|
+
"val": "self-label-a",
|
|
94
|
+
},
|
|
95
|
+
Object {
|
|
96
|
+
"val": "self-label-b",
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { TestNetwork, SeedClient } from '@atproto/dev-env'
|
|
2
|
+
import AtpAgent from '@atproto/api'
|
|
3
|
+
import {
|
|
4
|
+
FLAG,
|
|
5
|
+
TAKEDOWN,
|
|
6
|
+
} from '@atproto/api/src/client/types/com/atproto/admin/defs'
|
|
7
|
+
import {
|
|
8
|
+
REASONOTHER,
|
|
9
|
+
REASONSPAM,
|
|
10
|
+
} from '../../src/lexicon/types/com/atproto/moderation/defs'
|
|
11
|
+
import { forSnapshot } from '../_util'
|
|
12
|
+
import basicSeed from '../seeds/basic'
|
|
13
|
+
|
|
14
|
+
describe('admin get moderation action view', () => {
|
|
15
|
+
let network: TestNetwork
|
|
16
|
+
let agent: AtpAgent
|
|
17
|
+
let sc: SeedClient
|
|
18
|
+
|
|
19
|
+
beforeAll(async () => {
|
|
20
|
+
network = await TestNetwork.create({
|
|
21
|
+
dbPostgresSchema: 'views_admin_get_moderation_action',
|
|
22
|
+
})
|
|
23
|
+
agent = network.pds.getClient()
|
|
24
|
+
sc = network.getSeedClient()
|
|
25
|
+
await basicSeed(sc)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
afterAll(async () => {
|
|
29
|
+
await network.close()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
beforeAll(async () => {
|
|
33
|
+
const reportRepo = await sc.createReport({
|
|
34
|
+
reportedBy: sc.dids.bob,
|
|
35
|
+
reasonType: REASONSPAM,
|
|
36
|
+
subject: {
|
|
37
|
+
$type: 'com.atproto.admin.defs#repoRef',
|
|
38
|
+
did: sc.dids.alice,
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
const reportRecord = await sc.createReport({
|
|
42
|
+
reportedBy: sc.dids.carol,
|
|
43
|
+
reasonType: REASONOTHER,
|
|
44
|
+
reason: 'defamation',
|
|
45
|
+
subject: {
|
|
46
|
+
$type: 'com.atproto.repo.strongRef',
|
|
47
|
+
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
48
|
+
cid: sc.posts[sc.dids.alice][0].ref.cidStr,
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
const flagRepo = await sc.takeModerationAction({
|
|
52
|
+
action: FLAG,
|
|
53
|
+
subject: {
|
|
54
|
+
$type: 'com.atproto.admin.defs#repoRef',
|
|
55
|
+
did: sc.dids.alice,
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
const takedownRecord = await sc.takeModerationAction({
|
|
59
|
+
action: TAKEDOWN,
|
|
60
|
+
subject: {
|
|
61
|
+
$type: 'com.atproto.repo.strongRef',
|
|
62
|
+
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
63
|
+
cid: sc.posts[sc.dids.alice][0].ref.cidStr,
|
|
64
|
+
},
|
|
65
|
+
})
|
|
66
|
+
await sc.resolveReports({
|
|
67
|
+
actionId: flagRepo.id,
|
|
68
|
+
reportIds: [reportRepo.id, reportRecord.id],
|
|
69
|
+
})
|
|
70
|
+
await sc.resolveReports({
|
|
71
|
+
actionId: takedownRecord.id,
|
|
72
|
+
reportIds: [reportRecord.id],
|
|
73
|
+
})
|
|
74
|
+
await sc.reverseModerationAction({ id: flagRepo.id })
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('gets moderation action for a repo.', async () => {
|
|
78
|
+
const result = await agent.api.com.atproto.admin.getModerationAction(
|
|
79
|
+
{ id: 1 },
|
|
80
|
+
{ headers: { authorization: network.pds.adminAuth() } },
|
|
81
|
+
)
|
|
82
|
+
expect(forSnapshot(result.data)).toMatchSnapshot()
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('gets moderation action for a record.', async () => {
|
|
86
|
+
const result = await agent.api.com.atproto.admin.getModerationAction(
|
|
87
|
+
{ id: 2 },
|
|
88
|
+
{ headers: { authorization: network.pds.adminAuth() } },
|
|
89
|
+
)
|
|
90
|
+
expect(forSnapshot(result.data)).toMatchSnapshot()
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('fails when moderation action does not exist.', async () => {
|
|
94
|
+
const promise = agent.api.com.atproto.admin.getModerationAction(
|
|
95
|
+
{ id: 100 },
|
|
96
|
+
{ headers: { authorization: network.pds.adminAuth() } },
|
|
97
|
+
)
|
|
98
|
+
await expect(promise).rejects.toThrow('Action not found')
|
|
99
|
+
})
|
|
100
|
+
})
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { SeedClient, TestNetwork } from '@atproto/dev-env'
|
|
2
|
+
import AtpAgent from '@atproto/api'
|
|
3
|
+
import {
|
|
4
|
+
ACKNOWLEDGE,
|
|
5
|
+
FLAG,
|
|
6
|
+
TAKEDOWN,
|
|
7
|
+
} from '@atproto/api/src/client/types/com/atproto/admin/defs'
|
|
8
|
+
import {
|
|
9
|
+
REASONOTHER,
|
|
10
|
+
REASONSPAM,
|
|
11
|
+
} from '../../src/lexicon/types/com/atproto/moderation/defs'
|
|
12
|
+
import { forSnapshot, paginateAll } from '../_util'
|
|
13
|
+
import basicSeed from '../seeds/basic'
|
|
14
|
+
|
|
15
|
+
describe('admin get moderation actions view', () => {
|
|
16
|
+
let network: TestNetwork
|
|
17
|
+
let agent: AtpAgent
|
|
18
|
+
let sc: SeedClient
|
|
19
|
+
|
|
20
|
+
beforeAll(async () => {
|
|
21
|
+
network = await TestNetwork.create({
|
|
22
|
+
dbPostgresSchema: 'views_admin_get_moderation_actions',
|
|
23
|
+
})
|
|
24
|
+
agent = network.pds.getClient()
|
|
25
|
+
sc = network.getSeedClient()
|
|
26
|
+
await basicSeed(sc)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
afterAll(async () => {
|
|
30
|
+
await network.close()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
beforeAll(async () => {
|
|
34
|
+
const oneIn = (n) => (_, i) => i % n === 0
|
|
35
|
+
const getAction = (i) => [FLAG, ACKNOWLEDGE, TAKEDOWN][i % 3]
|
|
36
|
+
const posts = Object.values(sc.posts)
|
|
37
|
+
.flatMap((x) => x)
|
|
38
|
+
.filter(oneIn(2))
|
|
39
|
+
const dids = Object.values(sc.dids).filter(oneIn(2))
|
|
40
|
+
// Take actions on records
|
|
41
|
+
const recordActions: Awaited<ReturnType<typeof sc.takeModerationAction>>[] =
|
|
42
|
+
[]
|
|
43
|
+
for (let i = 0; i < posts.length; ++i) {
|
|
44
|
+
const post = posts[i]
|
|
45
|
+
recordActions.push(
|
|
46
|
+
await sc.takeModerationAction({
|
|
47
|
+
action: getAction(i),
|
|
48
|
+
subject: {
|
|
49
|
+
$type: 'com.atproto.repo.strongRef',
|
|
50
|
+
uri: post.ref.uriStr,
|
|
51
|
+
cid: post.ref.cidStr,
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
// Reverse an action
|
|
57
|
+
await sc.reverseModerationAction({
|
|
58
|
+
id: recordActions[0].id,
|
|
59
|
+
})
|
|
60
|
+
// Take actions on repos
|
|
61
|
+
const repoActions: Awaited<ReturnType<typeof sc.takeModerationAction>>[] =
|
|
62
|
+
[]
|
|
63
|
+
for (let i = 0; i < dids.length; ++i) {
|
|
64
|
+
const did = dids[i]
|
|
65
|
+
repoActions.push(
|
|
66
|
+
await sc.takeModerationAction({
|
|
67
|
+
action: getAction(i),
|
|
68
|
+
subject: {
|
|
69
|
+
$type: 'com.atproto.admin.defs#repoRef',
|
|
70
|
+
did,
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
// Back some of the actions with a report, possibly resolved
|
|
76
|
+
const someRecordActions = recordActions.filter(oneIn(2))
|
|
77
|
+
for (let i = 0; i < someRecordActions.length; ++i) {
|
|
78
|
+
const action = someRecordActions[i]
|
|
79
|
+
const ab = oneIn(2)(action, i)
|
|
80
|
+
const report = await sc.createReport({
|
|
81
|
+
reportedBy: ab ? sc.dids.carol : sc.dids.alice,
|
|
82
|
+
reasonType: ab ? REASONSPAM : REASONOTHER,
|
|
83
|
+
subject: {
|
|
84
|
+
$type: 'com.atproto.repo.strongRef',
|
|
85
|
+
uri: action.subject.uri,
|
|
86
|
+
cid: action.subject.cid,
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
if (ab) {
|
|
90
|
+
await sc.resolveReports({
|
|
91
|
+
actionId: action.id,
|
|
92
|
+
reportIds: [report.id],
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const someRepoActions = repoActions.filter(oneIn(2))
|
|
97
|
+
for (let i = 0; i < someRepoActions.length; ++i) {
|
|
98
|
+
const action = someRepoActions[i]
|
|
99
|
+
const ab = oneIn(2)(action, i)
|
|
100
|
+
const report = await sc.createReport({
|
|
101
|
+
reportedBy: ab ? sc.dids.carol : sc.dids.alice,
|
|
102
|
+
reasonType: ab ? REASONSPAM : REASONOTHER,
|
|
103
|
+
subject: {
|
|
104
|
+
$type: 'com.atproto.admin.defs#repoRef',
|
|
105
|
+
did: action.subject.did,
|
|
106
|
+
},
|
|
107
|
+
})
|
|
108
|
+
if (ab) {
|
|
109
|
+
await sc.resolveReports({
|
|
110
|
+
actionId: action.id,
|
|
111
|
+
reportIds: [report.id],
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('gets all moderation actions.', async () => {
|
|
118
|
+
const result = await agent.api.com.atproto.admin.getModerationActions(
|
|
119
|
+
{},
|
|
120
|
+
{ headers: network.pds.adminAuthHeaders() },
|
|
121
|
+
)
|
|
122
|
+
expect(forSnapshot(result.data.actions)).toMatchSnapshot()
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('gets all moderation actions for a repo.', async () => {
|
|
126
|
+
const result = await agent.api.com.atproto.admin.getModerationActions(
|
|
127
|
+
{ subject: Object.values(sc.dids)[0] },
|
|
128
|
+
{ headers: network.pds.adminAuthHeaders() },
|
|
129
|
+
)
|
|
130
|
+
expect(forSnapshot(result.data.actions)).toMatchSnapshot()
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
it('gets all moderation actions for a record.', async () => {
|
|
134
|
+
const result = await agent.api.com.atproto.admin.getModerationActions(
|
|
135
|
+
{ subject: Object.values(sc.posts)[0][0].ref.uriStr },
|
|
136
|
+
{ headers: network.pds.adminAuthHeaders() },
|
|
137
|
+
)
|
|
138
|
+
expect(forSnapshot(result.data.actions)).toMatchSnapshot()
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
it('paginates.', async () => {
|
|
142
|
+
const results = (results) => results.flatMap((res) => res.actions)
|
|
143
|
+
const paginator = async (cursor?: string) => {
|
|
144
|
+
const res = await agent.api.com.atproto.admin.getModerationActions(
|
|
145
|
+
{ cursor, limit: 3 },
|
|
146
|
+
{ headers: network.pds.adminAuthHeaders() },
|
|
147
|
+
)
|
|
148
|
+
return res.data
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const paginatedAll = await paginateAll(paginator)
|
|
152
|
+
paginatedAll.forEach((res) =>
|
|
153
|
+
expect(res.actions.length).toBeLessThanOrEqual(3),
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
const full = await agent.api.com.atproto.admin.getModerationActions(
|
|
157
|
+
{},
|
|
158
|
+
{ headers: network.pds.adminAuthHeaders() },
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
expect(full.data.actions.length).toEqual(6)
|
|
162
|
+
expect(results(paginatedAll)).toEqual(results([full.data]))
|
|
163
|
+
})
|
|
164
|
+
})
|