@atproto/bsky 0.0.15 → 0.0.16
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 +11 -0
- package/dist/api/com/atproto/moderation/util.d.ts +4 -3
- package/dist/context.d.ts +15 -0
- package/dist/db/index.js +26 -1
- package/dist/db/index.js.map +3 -3
- package/dist/db/migrations/20231003T202833377Z-create-moderation-subject-status.d.ts +3 -0
- package/dist/db/migrations/index.d.ts +1 -0
- package/dist/db/pagination.d.ts +2 -1
- package/dist/db/{periodic-moderation-action-reversal.d.ts → periodic-moderation-event-reversal.d.ts} +3 -5
- package/dist/db/tables/moderation.d.ts +24 -34
- package/dist/feed-gen/types.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2750 -2121
- package/dist/index.js.map +3 -3
- package/dist/lexicon/index.d.ts +11 -18
- package/dist/lexicon/lexicons.d.ts +414 -399
- package/dist/lexicon/types/app/bsky/feed/defs.d.ts +1 -7
- package/dist/lexicon/types/app/bsky/graph/defs.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/admin/defs.d.ts +114 -48
- package/dist/lexicon/types/com/atproto/admin/{takeModerationAction.d.ts → emitModerationEvent.d.ts} +5 -6
- package/dist/lexicon/types/com/atproto/admin/{getModerationAction.d.ts → getModerationEvent.d.ts} +1 -1
- package/dist/lexicon/types/com/atproto/admin/{getModerationActions.d.ts → queryModerationEvents.d.ts} +5 -1
- package/dist/lexicon/types/com/atproto/admin/{getModerationReports.d.ts → queryModerationStatuses.d.ts} +12 -6
- package/dist/lexicon/types/com/atproto/admin/sendEmail.d.ts +1 -0
- package/dist/migrate-moderation-data.d.ts +1 -0
- package/dist/services/actor/views.d.ts +2 -5
- package/dist/services/feed/index.d.ts +1 -0
- package/dist/services/feed/util.d.ts +9 -1
- package/dist/services/feed/views.d.ts +6 -17
- package/dist/services/graph/index.d.ts +5 -29
- package/dist/services/graph/types.d.ts +1 -0
- package/dist/services/moderation/index.d.ts +135 -72
- package/dist/services/moderation/pagination.d.ts +36 -0
- package/dist/services/moderation/status.d.ts +13 -0
- package/dist/services/moderation/types.d.ts +35 -0
- package/dist/services/moderation/views.d.ts +18 -14
- package/dist/util/debug.d.ts +1 -1
- package/package.json +11 -11
- package/src/api/app/bsky/feed/getActorFeeds.ts +2 -1
- package/src/api/app/bsky/feed/getActorLikes.ts +1 -3
- package/src/api/app/bsky/feed/getAuthorFeed.ts +1 -3
- package/src/api/app/bsky/feed/getFeed.ts +9 -9
- package/src/api/app/bsky/feed/getFeedGenerator.ts +3 -0
- package/src/api/app/bsky/feed/getFeedGenerators.ts +2 -1
- package/src/api/app/bsky/feed/getListFeed.ts +1 -3
- package/src/api/app/bsky/feed/getPostThread.ts +15 -54
- package/src/api/app/bsky/feed/getPosts.ts +21 -18
- package/src/api/app/bsky/feed/getSuggestedFeeds.ts +2 -1
- package/src/api/app/bsky/feed/getTimeline.ts +1 -3
- package/src/api/app/bsky/feed/searchPosts.ts +20 -17
- package/src/api/app/bsky/graph/getList.ts +6 -3
- package/src/api/app/bsky/graph/getListBlocks.ts +3 -2
- package/src/api/app/bsky/graph/getListMutes.ts +2 -1
- package/src/api/app/bsky/graph/getLists.ts +2 -1
- package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +3 -1
- package/src/api/blob-resolver.ts +6 -11
- package/src/api/com/atproto/admin/emitModerationEvent.ts +220 -0
- package/src/api/com/atproto/admin/{getModerationActions.ts → getModerationEvent.ts} +5 -11
- package/src/api/com/atproto/admin/getRecord.ts +1 -0
- package/src/api/com/atproto/admin/{getModerationReports.ts → queryModerationEvents.ts} +13 -16
- package/src/api/com/atproto/admin/queryModerationStatuses.ts +55 -0
- package/src/api/com/atproto/moderation/createReport.ts +9 -7
- package/src/api/com/atproto/moderation/util.ts +38 -20
- package/src/api/index.ts +8 -14
- package/src/auth.ts +29 -21
- package/src/auto-moderator/index.ts +26 -19
- package/src/context.ts +4 -0
- package/src/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts +123 -0
- package/src/db/migrations/index.ts +1 -0
- package/src/db/pagination.ts +26 -3
- package/src/db/{periodic-moderation-action-reversal.ts → periodic-moderation-event-reversal.ts} +50 -46
- package/src/db/tables/moderation.ts +35 -52
- package/src/feed-gen/best-of-follows.ts +6 -3
- package/src/feed-gen/bsky-team.ts +1 -1
- package/src/feed-gen/hot-classic.ts +1 -1
- package/src/feed-gen/mutuals.ts +6 -2
- package/src/feed-gen/types.ts +1 -1
- package/src/feed-gen/whats-hot.ts +1 -1
- package/src/feed-gen/with-friends.ts +7 -3
- package/src/index.ts +2 -1
- package/src/lexicon/index.ts +30 -67
- package/src/lexicon/lexicons.ts +526 -491
- package/src/lexicon/types/app/bsky/feed/defs.ts +1 -18
- package/src/lexicon/types/app/bsky/graph/defs.ts +1 -0
- package/src/lexicon/types/com/atproto/admin/defs.ts +276 -84
- package/src/lexicon/types/com/atproto/admin/{takeModerationAction.ts → emitModerationEvent.ts} +13 -11
- package/src/lexicon/types/com/atproto/admin/{getModerationReport.ts → getModerationEvent.ts} +1 -1
- package/src/lexicon/types/com/atproto/admin/{getModerationActions.ts → queryModerationEvents.ts} +8 -1
- package/src/lexicon/types/com/atproto/admin/{getModerationReports.ts → queryModerationStatuses.ts} +21 -14
- package/src/lexicon/types/com/atproto/admin/sendEmail.ts +1 -0
- package/src/migrate-moderation-data.ts +414 -0
- package/src/services/actor/views.ts +5 -14
- package/src/services/feed/index.ts +26 -7
- package/src/services/feed/util.ts +47 -19
- package/src/services/feed/views.ts +68 -4
- package/src/services/graph/index.ts +21 -3
- package/src/services/graph/types.ts +1 -0
- package/src/services/indexing/plugins/block.ts +2 -3
- package/src/services/indexing/plugins/feed-generator.ts +2 -3
- package/src/services/indexing/plugins/follow.ts +2 -3
- package/src/services/indexing/plugins/like.ts +2 -3
- package/src/services/indexing/plugins/list-block.ts +2 -3
- package/src/services/indexing/plugins/list-item.ts +2 -3
- package/src/services/indexing/plugins/list.ts +2 -3
- package/src/services/indexing/plugins/post.ts +3 -4
- package/src/services/indexing/plugins/repost.ts +2 -3
- package/src/services/indexing/plugins/thread-gate.ts +2 -3
- package/src/services/label/index.ts +2 -3
- package/src/services/moderation/index.ts +380 -395
- package/src/services/moderation/pagination.ts +96 -0
- package/src/services/moderation/status.ts +244 -0
- package/src/services/moderation/types.ts +49 -0
- package/src/services/moderation/views.ts +278 -329
- package/src/util/debug.ts +2 -2
- package/tests/__snapshots__/feed-generation.test.ts.snap +322 -6
- package/tests/__snapshots__/indexing.test.ts.snap +0 -6
- package/tests/admin/__snapshots__/get-record.test.ts.snap +30 -132
- package/tests/admin/__snapshots__/get-repo.test.ts.snap +14 -60
- package/tests/admin/__snapshots__/moderation-events.test.ts.snap +146 -0
- package/tests/admin/__snapshots__/moderation-statuses.test.ts.snap +64 -0
- package/tests/admin/__snapshots__/moderation.test.ts.snap +0 -125
- package/tests/admin/get-record.test.ts +5 -9
- package/tests/admin/get-repo.test.ts +5 -9
- package/tests/admin/moderation-events.test.ts +221 -0
- package/tests/admin/moderation-statuses.test.ts +145 -0
- package/tests/admin/moderation.test.ts +512 -860
- package/tests/admin/repo-search.test.ts +2 -3
- package/tests/auto-moderator/fuzzy-matcher.test.ts +2 -1
- package/tests/auto-moderator/takedowns.test.ts +45 -18
- package/tests/feed-generation.test.ts +57 -9
- package/tests/views/__snapshots__/block-lists.test.ts.snap +3 -9
- package/tests/views/__snapshots__/blocks.test.ts.snap +0 -9
- package/tests/views/__snapshots__/mute-lists.test.ts.snap +5 -5
- package/tests/views/__snapshots__/mutes.test.ts.snap +0 -3
- package/tests/views/__snapshots__/thread.test.ts.snap +0 -30
- package/tests/views/actor-search.test.ts +2 -3
- package/tests/views/author-feed.test.ts +42 -36
- package/tests/views/follows.test.ts +40 -35
- package/tests/views/list-feed.test.ts +17 -9
- package/tests/views/notifications.test.ts +13 -9
- package/tests/views/profile.test.ts +20 -18
- package/tests/views/thread.test.ts +54 -26
- package/tests/views/threadgating.test.ts +51 -19
- package/tests/views/timeline.test.ts +21 -13
- package/dist/api/com/atproto/admin/resolveModerationReports.d.ts +0 -3
- package/dist/api/com/atproto/admin/reverseModerationAction.d.ts +0 -3
- package/dist/api/com/atproto/admin/takeModerationAction.d.ts +0 -3
- package/dist/lexicon/types/com/atproto/admin/getModerationReport.d.ts +0 -29
- package/dist/lexicon/types/com/atproto/admin/resolveModerationReports.d.ts +0 -36
- package/dist/lexicon/types/com/atproto/admin/reverseModerationAction.d.ts +0 -36
- package/src/api/com/atproto/admin/getModerationAction.ts +0 -44
- package/src/api/com/atproto/admin/getModerationReport.ts +0 -43
- package/src/api/com/atproto/admin/resolveModerationReports.ts +0 -24
- package/src/api/com/atproto/admin/reverseModerationAction.ts +0 -115
- package/src/api/com/atproto/admin/takeModerationAction.ts +0 -156
- package/src/lexicon/types/com/atproto/admin/getModerationAction.ts +0 -41
- package/src/lexicon/types/com/atproto/admin/resolveModerationReports.ts +0 -49
- package/src/lexicon/types/com/atproto/admin/reverseModerationAction.ts +0 -49
- package/tests/admin/__snapshots__/get-moderation-action.test.ts.snap +0 -172
- package/tests/admin/__snapshots__/get-moderation-actions.test.ts.snap +0 -178
- package/tests/admin/__snapshots__/get-moderation-report.test.ts.snap +0 -177
- package/tests/admin/__snapshots__/get-moderation-reports.test.ts.snap +0 -307
- package/tests/admin/get-moderation-action.test.ts +0 -100
- package/tests/admin/get-moderation-actions.test.ts +0 -164
- package/tests/admin/get-moderation-report.test.ts +0 -100
- package/tests/admin/get-moderation-reports.test.ts +0 -332
- /package/dist/api/com/atproto/admin/{getModerationAction.d.ts → emitModerationEvent.d.ts} +0 -0
- /package/dist/api/com/atproto/admin/{getModerationActions.d.ts → getModerationEvent.d.ts} +0 -0
- /package/dist/api/com/atproto/admin/{getModerationReport.d.ts → queryModerationEvents.d.ts} +0 -0
- /package/dist/api/com/atproto/admin/{getModerationReports.d.ts → queryModerationStatuses.d.ts} +0 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`moderation-events get event gets an event by specific id 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
6
|
+
"createdBy": "user(2)",
|
|
7
|
+
"event": Object {
|
|
8
|
+
"$type": "com.atproto.admin.defs#modEventReport",
|
|
9
|
+
"comment": "X",
|
|
10
|
+
"reportType": "com.atproto.moderation.defs#reasonMisleading",
|
|
11
|
+
},
|
|
12
|
+
"id": 1,
|
|
13
|
+
"subject": Object {
|
|
14
|
+
"$type": "com.atproto.admin.defs#repoView",
|
|
15
|
+
"did": "user(0)",
|
|
16
|
+
"handle": "alice.test",
|
|
17
|
+
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
18
|
+
"moderation": Object {
|
|
19
|
+
"subjectStatus": Object {
|
|
20
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
21
|
+
"id": 1,
|
|
22
|
+
"lastReportedAt": "1970-01-01T00:00:00.000Z",
|
|
23
|
+
"lastReviewedAt": "1970-01-01T00:00:00.000Z",
|
|
24
|
+
"lastReviewedBy": "user(1)",
|
|
25
|
+
"reviewState": "com.atproto.admin.defs#reviewEscalated",
|
|
26
|
+
"subject": Object {
|
|
27
|
+
"$type": "com.atproto.admin.defs#repoRef",
|
|
28
|
+
"did": "user(0)",
|
|
29
|
+
},
|
|
30
|
+
"subjectBlobCids": Array [],
|
|
31
|
+
"subjectRepoHandle": "alice.test",
|
|
32
|
+
"takendown": false,
|
|
33
|
+
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
"relatedRecords": Array [
|
|
37
|
+
Object {
|
|
38
|
+
"$type": "app.bsky.actor.profile",
|
|
39
|
+
"avatar": Object {
|
|
40
|
+
"$type": "blob",
|
|
41
|
+
"mimeType": "image/jpeg",
|
|
42
|
+
"ref": Object {
|
|
43
|
+
"$link": "cids(0)",
|
|
44
|
+
},
|
|
45
|
+
"size": 3976,
|
|
46
|
+
},
|
|
47
|
+
"description": "its me!",
|
|
48
|
+
"displayName": "ali",
|
|
49
|
+
"labels": Object {
|
|
50
|
+
"$type": "com.atproto.label.defs#selfLabels",
|
|
51
|
+
"values": Array [
|
|
52
|
+
Object {
|
|
53
|
+
"val": "self-label-a",
|
|
54
|
+
},
|
|
55
|
+
Object {
|
|
56
|
+
"val": "self-label-b",
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
"subjectBlobCids": Array [],
|
|
64
|
+
"subjectBlobs": Array [],
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
exports[`moderation-events query events returns all events for record or repo 1`] = `
|
|
69
|
+
Array [
|
|
70
|
+
Object {
|
|
71
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
72
|
+
"createdBy": "user(1)",
|
|
73
|
+
"creatorHandle": "alice.test",
|
|
74
|
+
"event": Object {
|
|
75
|
+
"$type": "com.atproto.admin.defs#modEventReport",
|
|
76
|
+
"comment": "X",
|
|
77
|
+
"reportType": "com.atproto.moderation.defs#reasonSpam",
|
|
78
|
+
},
|
|
79
|
+
"id": 7,
|
|
80
|
+
"subject": Object {
|
|
81
|
+
"$type": "com.atproto.admin.defs#repoRef",
|
|
82
|
+
"did": "user(0)",
|
|
83
|
+
},
|
|
84
|
+
"subjectBlobCids": Array [],
|
|
85
|
+
"subjectHandle": "bob.test",
|
|
86
|
+
},
|
|
87
|
+
Object {
|
|
88
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
89
|
+
"createdBy": "user(1)",
|
|
90
|
+
"creatorHandle": "alice.test",
|
|
91
|
+
"event": Object {
|
|
92
|
+
"$type": "com.atproto.admin.defs#modEventReport",
|
|
93
|
+
"comment": "X",
|
|
94
|
+
"reportType": "com.atproto.moderation.defs#reasonSpam",
|
|
95
|
+
},
|
|
96
|
+
"id": 3,
|
|
97
|
+
"subject": Object {
|
|
98
|
+
"$type": "com.atproto.admin.defs#repoRef",
|
|
99
|
+
"did": "user(0)",
|
|
100
|
+
},
|
|
101
|
+
"subjectBlobCids": Array [],
|
|
102
|
+
"subjectHandle": "bob.test",
|
|
103
|
+
},
|
|
104
|
+
]
|
|
105
|
+
`;
|
|
106
|
+
|
|
107
|
+
exports[`moderation-events query events returns all events for record or repo 2`] = `
|
|
108
|
+
Array [
|
|
109
|
+
Object {
|
|
110
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
111
|
+
"createdBy": "user(0)",
|
|
112
|
+
"creatorHandle": "bob.test",
|
|
113
|
+
"event": Object {
|
|
114
|
+
"$type": "com.atproto.admin.defs#modEventReport",
|
|
115
|
+
"comment": "X",
|
|
116
|
+
"reportType": "com.atproto.moderation.defs#reasonSpam",
|
|
117
|
+
},
|
|
118
|
+
"id": 6,
|
|
119
|
+
"subject": Object {
|
|
120
|
+
"$type": "com.atproto.repo.strongRef",
|
|
121
|
+
"cid": "cids(0)",
|
|
122
|
+
"uri": "record(0)",
|
|
123
|
+
},
|
|
124
|
+
"subjectBlobCids": Array [],
|
|
125
|
+
"subjectHandle": "alice.test",
|
|
126
|
+
},
|
|
127
|
+
Object {
|
|
128
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
129
|
+
"createdBy": "user(0)",
|
|
130
|
+
"creatorHandle": "bob.test",
|
|
131
|
+
"event": Object {
|
|
132
|
+
"$type": "com.atproto.admin.defs#modEventReport",
|
|
133
|
+
"comment": "X",
|
|
134
|
+
"reportType": "com.atproto.moderation.defs#reasonSpam",
|
|
135
|
+
},
|
|
136
|
+
"id": 2,
|
|
137
|
+
"subject": Object {
|
|
138
|
+
"$type": "com.atproto.repo.strongRef",
|
|
139
|
+
"cid": "cids(0)",
|
|
140
|
+
"uri": "record(0)",
|
|
141
|
+
},
|
|
142
|
+
"subjectBlobCids": Array [],
|
|
143
|
+
"subjectHandle": "alice.test",
|
|
144
|
+
},
|
|
145
|
+
]
|
|
146
|
+
`;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`moderation-statuses query statuses returns statuses for subjects that received moderation events 1`] = `
|
|
4
|
+
Array [
|
|
5
|
+
Object {
|
|
6
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
7
|
+
"id": 4,
|
|
8
|
+
"lastReportedAt": "1970-01-01T00:00:00.000Z",
|
|
9
|
+
"reviewState": "com.atproto.admin.defs#reviewOpen",
|
|
10
|
+
"subject": Object {
|
|
11
|
+
"$type": "com.atproto.repo.strongRef",
|
|
12
|
+
"cid": "cids(0)",
|
|
13
|
+
"uri": "record(0)",
|
|
14
|
+
},
|
|
15
|
+
"subjectBlobCids": Array [],
|
|
16
|
+
"subjectRepoHandle": "bob.test",
|
|
17
|
+
"takendown": false,
|
|
18
|
+
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
19
|
+
},
|
|
20
|
+
Object {
|
|
21
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
22
|
+
"id": 3,
|
|
23
|
+
"lastReportedAt": "1970-01-01T00:00:00.000Z",
|
|
24
|
+
"reviewState": "com.atproto.admin.defs#reviewOpen",
|
|
25
|
+
"subject": Object {
|
|
26
|
+
"$type": "com.atproto.admin.defs#repoRef",
|
|
27
|
+
"did": "user(0)",
|
|
28
|
+
},
|
|
29
|
+
"subjectBlobCids": Array [],
|
|
30
|
+
"subjectRepoHandle": "bob.test",
|
|
31
|
+
"takendown": false,
|
|
32
|
+
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
33
|
+
},
|
|
34
|
+
Object {
|
|
35
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
36
|
+
"id": 2,
|
|
37
|
+
"lastReportedAt": "1970-01-01T00:00:00.000Z",
|
|
38
|
+
"reviewState": "com.atproto.admin.defs#reviewOpen",
|
|
39
|
+
"subject": Object {
|
|
40
|
+
"$type": "com.atproto.repo.strongRef",
|
|
41
|
+
"cid": "cids(1)",
|
|
42
|
+
"uri": "record(1)",
|
|
43
|
+
},
|
|
44
|
+
"subjectBlobCids": Array [],
|
|
45
|
+
"subjectRepoHandle": "alice.test",
|
|
46
|
+
"takendown": false,
|
|
47
|
+
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
48
|
+
},
|
|
49
|
+
Object {
|
|
50
|
+
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
51
|
+
"id": 1,
|
|
52
|
+
"lastReportedAt": "1970-01-01T00:00:00.000Z",
|
|
53
|
+
"reviewState": "com.atproto.admin.defs#reviewOpen",
|
|
54
|
+
"subject": Object {
|
|
55
|
+
"$type": "com.atproto.admin.defs#repoRef",
|
|
56
|
+
"did": "user(1)",
|
|
57
|
+
},
|
|
58
|
+
"subjectBlobCids": Array [],
|
|
59
|
+
"subjectRepoHandle": "alice.test",
|
|
60
|
+
"takendown": false,
|
|
61
|
+
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
62
|
+
},
|
|
63
|
+
]
|
|
64
|
+
`;
|
|
@@ -1,130 +1,5 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`moderation actioning resolves reports on missing repos and records. 1`] = `
|
|
4
|
-
Object {
|
|
5
|
-
"recordActionDetail": Object {
|
|
6
|
-
"action": "com.atproto.admin.defs#flag",
|
|
7
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
8
|
-
"createdBy": "did:example:admin",
|
|
9
|
-
"id": 2,
|
|
10
|
-
"reason": "Y",
|
|
11
|
-
"resolvedReports": Array [
|
|
12
|
-
Object {
|
|
13
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
14
|
-
"id": 11,
|
|
15
|
-
"reason": "defamation",
|
|
16
|
-
"reasonType": "com.atproto.moderation.defs#reasonOther",
|
|
17
|
-
"reportedBy": "user(0)",
|
|
18
|
-
"resolvedByActionIds": Array [
|
|
19
|
-
2,
|
|
20
|
-
],
|
|
21
|
-
"subject": Object {
|
|
22
|
-
"$type": "com.atproto.repo.strongRef",
|
|
23
|
-
"cid": "cids(0)",
|
|
24
|
-
"uri": "record(0)",
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
Object {
|
|
28
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
29
|
-
"id": 10,
|
|
30
|
-
"reasonType": "com.atproto.moderation.defs#reasonSpam",
|
|
31
|
-
"reportedBy": "user(1)",
|
|
32
|
-
"resolvedByActionIds": Array [
|
|
33
|
-
2,
|
|
34
|
-
],
|
|
35
|
-
"subject": Object {
|
|
36
|
-
"$type": "com.atproto.admin.defs#repoRef",
|
|
37
|
-
"did": "user(2)",
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
"subject": Object {
|
|
42
|
-
"$type": "com.atproto.admin.defs#recordViewNotFound",
|
|
43
|
-
"uri": "record(0)",
|
|
44
|
-
},
|
|
45
|
-
"subjectBlobs": Array [],
|
|
46
|
-
},
|
|
47
|
-
"reportADetail": Object {
|
|
48
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
49
|
-
"id": 10,
|
|
50
|
-
"reasonType": "com.atproto.moderation.defs#reasonSpam",
|
|
51
|
-
"reportedBy": "user(1)",
|
|
52
|
-
"resolvedByActions": Array [
|
|
53
|
-
Object {
|
|
54
|
-
"action": "com.atproto.admin.defs#flag",
|
|
55
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
56
|
-
"createdBy": "did:example:admin",
|
|
57
|
-
"id": 2,
|
|
58
|
-
"reason": "Y",
|
|
59
|
-
"resolvedReportIds": Array [
|
|
60
|
-
11,
|
|
61
|
-
10,
|
|
62
|
-
],
|
|
63
|
-
"subject": Object {
|
|
64
|
-
"$type": "com.atproto.repo.strongRef",
|
|
65
|
-
"cid": "cids(0)",
|
|
66
|
-
"uri": "record(0)",
|
|
67
|
-
},
|
|
68
|
-
"subjectBlobCids": Array [],
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
"subject": Object {
|
|
72
|
-
"$type": "com.atproto.admin.defs#repoViewNotFound",
|
|
73
|
-
"did": "user(2)",
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
"reportBDetail": Object {
|
|
77
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
78
|
-
"id": 11,
|
|
79
|
-
"reason": "defamation",
|
|
80
|
-
"reasonType": "com.atproto.moderation.defs#reasonOther",
|
|
81
|
-
"reportedBy": "user(0)",
|
|
82
|
-
"resolvedByActions": Array [
|
|
83
|
-
Object {
|
|
84
|
-
"action": "com.atproto.admin.defs#flag",
|
|
85
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
86
|
-
"createdBy": "did:example:admin",
|
|
87
|
-
"id": 2,
|
|
88
|
-
"reason": "Y",
|
|
89
|
-
"resolvedReportIds": Array [
|
|
90
|
-
11,
|
|
91
|
-
10,
|
|
92
|
-
],
|
|
93
|
-
"subject": Object {
|
|
94
|
-
"$type": "com.atproto.repo.strongRef",
|
|
95
|
-
"cid": "cids(0)",
|
|
96
|
-
"uri": "record(0)",
|
|
97
|
-
},
|
|
98
|
-
"subjectBlobCids": Array [],
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
"subject": Object {
|
|
102
|
-
"$type": "com.atproto.admin.defs#recordViewNotFound",
|
|
103
|
-
"uri": "record(0)",
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
}
|
|
107
|
-
`;
|
|
108
|
-
|
|
109
|
-
exports[`moderation actioning resolves reports on repos and records. 1`] = `
|
|
110
|
-
Object {
|
|
111
|
-
"action": "com.atproto.admin.defs#takedown",
|
|
112
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
113
|
-
"createdBy": "did:example:admin",
|
|
114
|
-
"id": 1,
|
|
115
|
-
"reason": "Y",
|
|
116
|
-
"resolvedReportIds": Array [
|
|
117
|
-
9,
|
|
118
|
-
8,
|
|
119
|
-
],
|
|
120
|
-
"subject": Object {
|
|
121
|
-
"$type": "com.atproto.admin.defs#repoRef",
|
|
122
|
-
"did": "user(0)",
|
|
123
|
-
},
|
|
124
|
-
"subjectBlobCids": Array [],
|
|
125
|
-
}
|
|
126
|
-
`;
|
|
127
|
-
|
|
128
3
|
exports[`moderation reporting creates reports of a record. 1`] = `
|
|
129
4
|
Array [
|
|
130
5
|
Object {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { SeedClient, TestNetwork } from '@atproto/dev-env'
|
|
2
2
|
import AtpAgent from '@atproto/api'
|
|
3
3
|
import { AtUri } from '@atproto/syntax'
|
|
4
|
-
import {
|
|
5
|
-
ACKNOWLEDGE,
|
|
6
|
-
TAKEDOWN,
|
|
7
|
-
} from '@atproto/api/src/client/types/com/atproto/admin/defs'
|
|
8
4
|
import {
|
|
9
5
|
REASONOTHER,
|
|
10
6
|
REASONSPAM,
|
|
@@ -24,6 +20,7 @@ describe('admin get record view', () => {
|
|
|
24
20
|
agent = network.pds.getClient()
|
|
25
21
|
sc = network.getSeedClient()
|
|
26
22
|
await basicSeed(sc)
|
|
23
|
+
await network.processAll()
|
|
27
24
|
})
|
|
28
25
|
|
|
29
26
|
afterAll(async () => {
|
|
@@ -31,8 +28,8 @@ describe('admin get record view', () => {
|
|
|
31
28
|
})
|
|
32
29
|
|
|
33
30
|
beforeAll(async () => {
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
await sc.emitModerationEvent({
|
|
32
|
+
event: { $type: 'com.atproto.admin.defs#modEventFlag' },
|
|
36
33
|
subject: {
|
|
37
34
|
$type: 'com.atproto.repo.strongRef',
|
|
38
35
|
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
@@ -58,9 +55,8 @@ describe('admin get record view', () => {
|
|
|
58
55
|
cid: sc.posts[sc.dids.alice][0].ref.cidStr,
|
|
59
56
|
},
|
|
60
57
|
})
|
|
61
|
-
await sc.
|
|
62
|
-
|
|
63
|
-
action: TAKEDOWN,
|
|
58
|
+
await sc.emitModerationEvent({
|
|
59
|
+
event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
|
|
64
60
|
subject: {
|
|
65
61
|
$type: 'com.atproto.repo.strongRef',
|
|
66
62
|
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { SeedClient, TestNetwork } from '@atproto/dev-env'
|
|
2
2
|
import AtpAgent from '@atproto/api'
|
|
3
|
-
import {
|
|
4
|
-
ACKNOWLEDGE,
|
|
5
|
-
TAKEDOWN,
|
|
6
|
-
} from '@atproto/api/src/client/types/com/atproto/admin/defs'
|
|
7
3
|
import {
|
|
8
4
|
REASONOTHER,
|
|
9
5
|
REASONSPAM,
|
|
@@ -23,6 +19,7 @@ describe('admin get repo view', () => {
|
|
|
23
19
|
agent = network.pds.getClient()
|
|
24
20
|
sc = network.getSeedClient()
|
|
25
21
|
await basicSeed(sc)
|
|
22
|
+
await network.processAll()
|
|
26
23
|
})
|
|
27
24
|
|
|
28
25
|
afterAll(async () => {
|
|
@@ -30,8 +27,8 @@ describe('admin get repo view', () => {
|
|
|
30
27
|
})
|
|
31
28
|
|
|
32
29
|
beforeAll(async () => {
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
await sc.emitModerationEvent({
|
|
31
|
+
event: { $type: 'com.atproto.admin.defs#modEventAcknowledge' },
|
|
35
32
|
subject: {
|
|
36
33
|
$type: 'com.atproto.admin.defs#repoRef',
|
|
37
34
|
did: sc.dids.alice,
|
|
@@ -54,9 +51,8 @@ describe('admin get repo view', () => {
|
|
|
54
51
|
did: sc.dids.alice,
|
|
55
52
|
},
|
|
56
53
|
})
|
|
57
|
-
await sc.
|
|
58
|
-
|
|
59
|
-
action: TAKEDOWN,
|
|
54
|
+
await sc.emitModerationEvent({
|
|
55
|
+
event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
|
|
60
56
|
subject: {
|
|
61
57
|
$type: 'com.atproto.admin.defs#repoRef',
|
|
62
58
|
did: sc.dids.alice,
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { TestNetwork, SeedClient } from '@atproto/dev-env'
|
|
2
|
+
import AtpAgent, { ComAtprotoAdminDefs } from '@atproto/api'
|
|
3
|
+
import { forSnapshot } from '../_util'
|
|
4
|
+
import basicSeed from '../seeds/basic'
|
|
5
|
+
import {
|
|
6
|
+
REASONMISLEADING,
|
|
7
|
+
REASONSPAM,
|
|
8
|
+
} from '../../src/lexicon/types/com/atproto/moderation/defs'
|
|
9
|
+
|
|
10
|
+
describe('moderation-events', () => {
|
|
11
|
+
let network: TestNetwork
|
|
12
|
+
let agent: AtpAgent
|
|
13
|
+
let pdsAgent: AtpAgent
|
|
14
|
+
let sc: SeedClient
|
|
15
|
+
|
|
16
|
+
const emitModerationEvent = async (eventData) => {
|
|
17
|
+
return pdsAgent.api.com.atproto.admin.emitModerationEvent(eventData, {
|
|
18
|
+
encoding: 'application/json',
|
|
19
|
+
headers: network.bsky.adminAuthHeaders('moderator'),
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const queryModerationEvents = (eventQuery) =>
|
|
24
|
+
agent.api.com.atproto.admin.queryModerationEvents(eventQuery, {
|
|
25
|
+
headers: network.bsky.adminAuthHeaders('moderator'),
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const seedEvents = async () => {
|
|
29
|
+
const bobsAccount = {
|
|
30
|
+
$type: 'com.atproto.admin.defs#repoRef',
|
|
31
|
+
did: sc.dids.bob,
|
|
32
|
+
}
|
|
33
|
+
const alicesAccount = {
|
|
34
|
+
$type: 'com.atproto.admin.defs#repoRef',
|
|
35
|
+
did: sc.dids.alice,
|
|
36
|
+
}
|
|
37
|
+
const bobsPost = {
|
|
38
|
+
$type: 'com.atproto.repo.strongRef',
|
|
39
|
+
uri: sc.posts[sc.dids.bob][0].ref.uriStr,
|
|
40
|
+
cid: sc.posts[sc.dids.bob][0].ref.cidStr,
|
|
41
|
+
}
|
|
42
|
+
const alicesPost = {
|
|
43
|
+
$type: 'com.atproto.repo.strongRef',
|
|
44
|
+
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
45
|
+
cid: sc.posts[sc.dids.alice][0].ref.cidStr,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
for (let i = 0; i < 4; i++) {
|
|
49
|
+
await emitModerationEvent({
|
|
50
|
+
event: {
|
|
51
|
+
$type: 'com.atproto.admin.defs#modEventReport',
|
|
52
|
+
reportType: i % 2 ? REASONSPAM : REASONMISLEADING,
|
|
53
|
+
comment: 'X',
|
|
54
|
+
},
|
|
55
|
+
// Report bob's account by alice and vice versa
|
|
56
|
+
subject: i % 2 ? bobsAccount : alicesAccount,
|
|
57
|
+
createdBy: i % 2 ? sc.dids.alice : sc.dids.bob,
|
|
58
|
+
})
|
|
59
|
+
await emitModerationEvent({
|
|
60
|
+
event: {
|
|
61
|
+
$type: 'com.atproto.admin.defs#modEventReport',
|
|
62
|
+
reportType: REASONSPAM,
|
|
63
|
+
comment: 'X',
|
|
64
|
+
},
|
|
65
|
+
// Report bob's post by alice and vice versa
|
|
66
|
+
subject: i % 2 ? bobsPost : alicesPost,
|
|
67
|
+
createdBy: i % 2 ? sc.dids.alice : sc.dids.bob,
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
beforeAll(async () => {
|
|
73
|
+
network = await TestNetwork.create({
|
|
74
|
+
dbPostgresSchema: 'bsky_moderation_events',
|
|
75
|
+
})
|
|
76
|
+
agent = network.bsky.getClient()
|
|
77
|
+
pdsAgent = network.pds.getClient()
|
|
78
|
+
sc = network.getSeedClient()
|
|
79
|
+
await basicSeed(sc)
|
|
80
|
+
await network.processAll()
|
|
81
|
+
await seedEvents()
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
afterAll(async () => {
|
|
85
|
+
await network.close()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
describe('query events', () => {
|
|
89
|
+
it('returns all events for record or repo', async () => {
|
|
90
|
+
const [bobsEvents, alicesPostEvents] = await Promise.all([
|
|
91
|
+
queryModerationEvents({
|
|
92
|
+
subject: sc.dids.bob,
|
|
93
|
+
}),
|
|
94
|
+
queryModerationEvents({
|
|
95
|
+
subject: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
96
|
+
}),
|
|
97
|
+
])
|
|
98
|
+
|
|
99
|
+
expect(forSnapshot(bobsEvents.data.events)).toMatchSnapshot()
|
|
100
|
+
expect(forSnapshot(alicesPostEvents.data.events)).toMatchSnapshot()
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('filters events by types', async () => {
|
|
104
|
+
const alicesAccount = {
|
|
105
|
+
$type: 'com.atproto.admin.defs#repoRef',
|
|
106
|
+
did: sc.dids.alice,
|
|
107
|
+
}
|
|
108
|
+
await Promise.all([
|
|
109
|
+
emitModerationEvent({
|
|
110
|
+
event: {
|
|
111
|
+
$type: 'com.atproto.admin.defs#modEventComment',
|
|
112
|
+
comment: 'X',
|
|
113
|
+
},
|
|
114
|
+
subject: alicesAccount,
|
|
115
|
+
createdBy: 'did:plc:moderator',
|
|
116
|
+
}),
|
|
117
|
+
emitModerationEvent({
|
|
118
|
+
event: {
|
|
119
|
+
$type: 'com.atproto.admin.defs#modEventEscalate',
|
|
120
|
+
comment: 'X',
|
|
121
|
+
},
|
|
122
|
+
subject: alicesAccount,
|
|
123
|
+
createdBy: 'did:plc:moderator',
|
|
124
|
+
}),
|
|
125
|
+
])
|
|
126
|
+
const [allEvents, reportEvents] = await Promise.all([
|
|
127
|
+
queryModerationEvents({
|
|
128
|
+
subject: sc.dids.alice,
|
|
129
|
+
}),
|
|
130
|
+
queryModerationEvents({
|
|
131
|
+
subject: sc.dids.alice,
|
|
132
|
+
types: ['com.atproto.admin.defs#modEventReport'],
|
|
133
|
+
}),
|
|
134
|
+
])
|
|
135
|
+
|
|
136
|
+
expect(allEvents.data.events.length).toBeGreaterThan(
|
|
137
|
+
reportEvents.data.events.length,
|
|
138
|
+
)
|
|
139
|
+
expect(
|
|
140
|
+
[...new Set(reportEvents.data.events.map((e) => e.event.$type))].length,
|
|
141
|
+
).toEqual(1)
|
|
142
|
+
|
|
143
|
+
expect(
|
|
144
|
+
[...new Set(allEvents.data.events.map((e) => e.event.$type))].length,
|
|
145
|
+
).toEqual(3)
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
it('returns events for all content by user', async () => {
|
|
149
|
+
const [forAccount, forPost] = await Promise.all([
|
|
150
|
+
queryModerationEvents({
|
|
151
|
+
subject: sc.dids.bob,
|
|
152
|
+
includeAllUserRecords: true,
|
|
153
|
+
}),
|
|
154
|
+
queryModerationEvents({
|
|
155
|
+
subject: sc.posts[sc.dids.bob][0].ref.uriStr,
|
|
156
|
+
includeAllUserRecords: true,
|
|
157
|
+
}),
|
|
158
|
+
])
|
|
159
|
+
|
|
160
|
+
expect(forAccount.data.events.length).toEqual(forPost.data.events.length)
|
|
161
|
+
// Save events are returned from both requests
|
|
162
|
+
expect(forPost.data.events.map(({ id }) => id).sort()).toEqual(
|
|
163
|
+
forAccount.data.events.map(({ id }) => id).sort(),
|
|
164
|
+
)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
it('returns paginated list of events with cursor', async () => {
|
|
168
|
+
const allEvents = await queryModerationEvents({
|
|
169
|
+
subject: sc.dids.bob,
|
|
170
|
+
includeAllUserRecords: true,
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
const getPaginatedEvents = async (
|
|
174
|
+
sortDirection: 'asc' | 'desc' = 'desc',
|
|
175
|
+
) => {
|
|
176
|
+
let defaultCursor: undefined | string = undefined
|
|
177
|
+
const events: ComAtprotoAdminDefs.ModEventView[] = []
|
|
178
|
+
let count = 0
|
|
179
|
+
do {
|
|
180
|
+
// get 1 event at a time and check we get all events
|
|
181
|
+
const { data } = await queryModerationEvents({
|
|
182
|
+
limit: 1,
|
|
183
|
+
subject: sc.dids.bob,
|
|
184
|
+
includeAllUserRecords: true,
|
|
185
|
+
cursor: defaultCursor,
|
|
186
|
+
sortDirection,
|
|
187
|
+
})
|
|
188
|
+
events.push(...data.events)
|
|
189
|
+
defaultCursor = data.cursor
|
|
190
|
+
count++
|
|
191
|
+
// The count is a circuit breaker to prevent infinite loop in case of failing test
|
|
192
|
+
} while (defaultCursor && count < 10)
|
|
193
|
+
|
|
194
|
+
return events
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const defaultEvents = await getPaginatedEvents()
|
|
198
|
+
const reversedEvents = await getPaginatedEvents('asc')
|
|
199
|
+
|
|
200
|
+
expect(allEvents.data.events.length).toEqual(4)
|
|
201
|
+
expect(defaultEvents.length).toEqual(allEvents.data.events.length)
|
|
202
|
+
expect(reversedEvents.length).toEqual(allEvents.data.events.length)
|
|
203
|
+
expect(reversedEvents[0].id).toEqual(defaultEvents[3].id)
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
describe('get event', () => {
|
|
208
|
+
it('gets an event by specific id', async () => {
|
|
209
|
+
const { data } = await pdsAgent.api.com.atproto.admin.getModerationEvent(
|
|
210
|
+
{
|
|
211
|
+
id: 1,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
headers: network.bsky.adminAuthHeaders('moderator'),
|
|
215
|
+
},
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
expect(forSnapshot(data)).toMatchSnapshot()
|
|
219
|
+
})
|
|
220
|
+
})
|
|
221
|
+
})
|