@atproto/ozone 0.0.17-next.0 → 0.0.17-next.1
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/dist/api/util.d.ts +10 -0
- package/dist/auth-verifier.d.ts +2 -2
- package/dist/communication-service/template.d.ts +2 -2
- package/dist/config/config.d.ts +5 -0
- package/dist/config/env.d.ts +2 -0
- package/dist/context.d.ts +6 -0
- package/dist/daemon/blob-diverter.d.ts +26 -0
- package/dist/daemon/event-pusher.d.ts +4 -0
- package/dist/daemon/index.d.ts +1 -0
- package/dist/db/index.js +21 -1
- package/dist/db/index.js.map +3 -3
- package/dist/db/migrations/20240228T003647759Z-add-label-sigs.d.ts +3 -0
- package/dist/db/migrations/index.d.ts +1 -0
- package/dist/db/schema/index.d.ts +2 -1
- package/dist/db/schema/label.d.ts +4 -0
- package/dist/db/schema/moderation_event.d.ts +1 -1
- package/dist/db/schema/moderation_subject_status.d.ts +1 -1
- package/dist/db/schema/signing_key.d.ts +9 -0
- package/dist/index.js +10949 -10628
- package/dist/index.js.map +3 -3
- package/dist/lexicon/index.d.ts +48 -28
- package/dist/lexicon/lexicons.d.ts +4641 -4650
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts +7 -7
- package/dist/lexicon/types/app/bsky/feed/defs.d.ts +1 -0
- package/dist/lexicon/types/app/bsky/graph/defs.d.ts +3 -0
- package/dist/lexicon/types/com/atproto/admin/defs.d.ts +0 -305
- package/dist/lexicon/types/com/atproto/label/defs.d.ts +5 -0
- package/dist/lexicon/types/{com/atproto/admin/createCommunicationTemplate.d.ts → tools/ozone/communication/createTemplate.d.ts} +2 -2
- package/dist/lexicon/types/tools/ozone/communication/defs.d.ts +14 -0
- package/dist/lexicon/types/{com/atproto/admin/listCommunicationTemplates.d.ts → tools/ozone/communication/listTemplates.d.ts} +2 -2
- package/dist/lexicon/types/{com/atproto/admin/updateCommunicationTemplate.d.ts → tools/ozone/communication/updateTemplate.d.ts} +2 -2
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts +269 -0
- package/dist/lexicon/types/{com/atproto/admin/emitModerationEvent.d.ts → tools/ozone/moderation/emitEvent.d.ts} +5 -4
- package/dist/lexicon/types/{com/atproto/admin/getModerationEvent.d.ts → tools/ozone/moderation/getEvent.d.ts} +2 -2
- package/dist/lexicon/types/{com/atproto/admin → tools/ozone/moderation}/getRecord.d.ts +2 -2
- package/dist/lexicon/types/{com/atproto/admin → tools/ozone/moderation}/getRepo.d.ts +2 -2
- package/dist/lexicon/types/{com/atproto/admin/queryModerationEvents.d.ts → tools/ozone/moderation/queryEvents.d.ts} +2 -2
- package/dist/lexicon/types/{com/atproto/admin/queryModerationStatuses.d.ts → tools/ozone/moderation/queryStatuses.d.ts} +2 -2
- package/dist/lexicon/types/{com/atproto/admin → tools/ozone/moderation}/searchRepos.d.ts +2 -2
- package/dist/mod-service/index.d.ts +16 -15
- package/dist/mod-service/subject.d.ts +1 -1
- package/dist/mod-service/types.d.ts +2 -2
- package/dist/mod-service/util.d.ts +6 -0
- package/dist/mod-service/views.d.ts +9 -3
- package/dist/sequencer/sequencer.d.ts +6 -4
- package/dist/util.d.ts +2 -0
- package/package.json +7 -7
- package/src/api/{admin/createCommunicationTemplate.ts → communication/createTemplate.ts} +1 -1
- package/src/api/{admin/deleteCommunicationTemplate.ts → communication/deleteTemplate.ts} +1 -1
- package/src/api/{admin/listCommunicationTemplates.ts → communication/listTemplates.ts} +1 -1
- package/src/api/{admin/updateCommunicationTemplate.ts → communication/updateTemplate.ts} +1 -1
- package/src/api/index.ts +21 -21
- package/src/api/{temp → label}/fetchLabels.ts +4 -2
- package/src/api/label/queryLabels.ts +4 -2
- package/src/api/moderation/emitEvent.ts +218 -0
- package/src/api/{admin/getModerationEvent.ts → moderation/getEvent.ts} +1 -1
- package/src/api/{admin → moderation}/getRecord.ts +2 -2
- package/src/api/{admin → moderation}/getRepo.ts +2 -2
- package/src/api/{admin/queryModerationEvents.ts → moderation/queryEvents.ts} +2 -2
- package/src/api/{admin/queryModerationStatuses.ts → moderation/queryStatuses.ts} +2 -2
- package/src/api/{admin → moderation}/searchRepos.ts +1 -1
- package/src/api/{moderation → report}/createReport.ts +1 -1
- package/src/api/util.ts +119 -0
- package/src/auth-verifier.ts +2 -2
- package/src/communication-service/template.ts +2 -2
- package/src/config/config.ts +14 -0
- package/src/config/env.ts +4 -0
- package/src/context.ts +35 -9
- package/src/daemon/blob-diverter.ts +150 -0
- package/src/daemon/context.ts +9 -5
- package/src/daemon/event-pusher.ts +49 -14
- package/src/daemon/index.ts +1 -0
- package/src/db/migrations/20240228T003647759Z-add-label-sigs.ts +25 -0
- package/src/db/migrations/index.ts +1 -0
- package/src/db/schema/index.ts +2 -0
- package/src/db/schema/label.ts +3 -0
- package/src/db/schema/moderation_event.ts +11 -11
- package/src/db/schema/moderation_subject_status.ts +1 -1
- package/src/db/schema/signing_key.ts +10 -0
- package/src/lexicon/index.ts +178 -138
- package/src/lexicon/lexicons.ts +6078 -6106
- package/src/lexicon/types/app/bsky/actor/defs.ts +11 -11
- package/src/lexicon/types/app/bsky/feed/defs.ts +1 -0
- package/src/lexicon/types/app/bsky/graph/defs.ts +3 -0
- package/src/lexicon/types/com/atproto/admin/defs.ts +0 -697
- package/src/lexicon/types/com/atproto/label/defs.ts +10 -0
- package/src/lexicon/types/{com/atproto/admin/createCommunicationTemplate.ts → tools/ozone/communication/createTemplate.ts} +2 -2
- package/src/lexicon/types/tools/ozone/communication/defs.ts +35 -0
- package/src/lexicon/types/{com/atproto/admin/listCommunicationTemplates.ts → tools/ozone/communication/listTemplates.ts} +2 -2
- package/src/lexicon/types/{com/atproto/admin/updateCommunicationTemplate.ts → tools/ozone/communication/updateTemplate.ts} +2 -2
- package/src/lexicon/types/tools/ozone/moderation/defs.ts +641 -0
- package/src/lexicon/types/{com/atproto/admin/emitModerationEvent.ts → tools/ozone/moderation/emitEvent.ts} +15 -14
- package/src/lexicon/types/{com/atproto/admin/getModerationEvent.ts → tools/ozone/moderation/getEvent.ts} +2 -2
- package/src/lexicon/types/{com/atproto/admin → tools/ozone/moderation}/getRecord.ts +2 -2
- package/src/lexicon/types/{com/atproto/admin → tools/ozone/moderation}/getRepo.ts +2 -2
- package/src/lexicon/types/{com/atproto/admin/queryModerationEvents.ts → tools/ozone/moderation/queryEvents.ts} +3 -3
- package/src/lexicon/types/{com/atproto/admin/queryModerationStatuses.ts → tools/ozone/moderation/queryStatuses.ts} +2 -2
- package/src/lexicon/types/{com/atproto/admin → tools/ozone/moderation}/searchRepos.ts +2 -2
- package/src/mod-service/index.ts +42 -47
- package/src/mod-service/lang.ts +1 -1
- package/src/mod-service/status.ts +19 -16
- package/src/mod-service/subject.ts +1 -1
- package/src/mod-service/types.ts +10 -10
- package/src/mod-service/util.ts +49 -5
- package/src/mod-service/views.ts +45 -18
- package/src/sequencer/sequencer.ts +12 -11
- package/src/util.ts +21 -0
- package/tests/__snapshots__/blob-divert.test.ts.snap +22 -0
- package/tests/__snapshots__/get-record.test.ts.snap +10 -2
- package/tests/__snapshots__/get-repo.test.ts.snap +5 -1
- package/tests/__snapshots__/moderation-events.test.ts.snap +8 -8
- package/tests/__snapshots__/moderation-statuses.test.ts.snap +6 -6
- package/tests/_util.ts +5 -0
- package/tests/blob-divert.test.ts +87 -0
- package/tests/communication-templates.test.ts +30 -34
- package/tests/db.test.ts +6 -6
- package/tests/get-record.test.ts +6 -6
- package/tests/get-repo.test.ts +11 -11
- package/tests/moderation-appeals.test.ts +28 -28
- package/tests/moderation-events.test.ts +44 -44
- package/tests/moderation-status-tags.test.ts +8 -10
- package/tests/moderation-statuses.test.ts +27 -27
- package/tests/moderation.test.ts +50 -57
- package/tests/query-labels.test.ts +86 -10
- package/tests/repo-search.test.ts +8 -8
- package/tests/sequencer.test.ts +6 -3
- package/dist/api/admin/util.d.ts +0 -5
- package/dist/api/moderation/util.d.ts +0 -4
- package/src/api/admin/emitModerationEvent.ts +0 -174
- package/src/api/admin/util.ts +0 -54
- package/src/api/moderation/util.ts +0 -67
- /package/dist/api/{admin/createCommunicationTemplate.d.ts → communication/createTemplate.d.ts} +0 -0
- /package/dist/api/{admin/deleteCommunicationTemplate.d.ts → communication/deleteTemplate.d.ts} +0 -0
- /package/dist/api/{admin/emitModerationEvent.d.ts → communication/listTemplates.d.ts} +0 -0
- /package/dist/api/{admin/getModerationEvent.d.ts → communication/updateTemplate.d.ts} +0 -0
- /package/dist/api/{temp → label}/fetchLabels.d.ts +0 -0
- /package/dist/api/{admin/getRecord.d.ts → moderation/emitEvent.d.ts} +0 -0
- /package/dist/api/{admin/getRepo.d.ts → moderation/getEvent.d.ts} +0 -0
- /package/dist/api/{admin/listCommunicationTemplates.d.ts → moderation/getRecord.d.ts} +0 -0
- /package/dist/api/{admin/queryModerationEvents.d.ts → moderation/getRepo.d.ts} +0 -0
- /package/dist/api/{admin/queryModerationStatuses.d.ts → moderation/queryEvents.d.ts} +0 -0
- /package/dist/api/{admin/searchRepos.d.ts → moderation/queryStatuses.d.ts} +0 -0
- /package/dist/api/{admin/updateCommunicationTemplate.d.ts → moderation/searchRepos.d.ts} +0 -0
- /package/dist/api/{moderation → report}/createReport.d.ts +0 -0
- /package/dist/lexicon/types/{com/atproto/admin/deleteCommunicationTemplate.d.ts → tools/ozone/communication/deleteTemplate.d.ts} +0 -0
- /package/src/lexicon/types/{com/atproto/admin/deleteCommunicationTemplate.ts → tools/ozone/communication/deleteTemplate.ts} +0 -0
package/tests/db.test.ts
CHANGED
|
@@ -48,7 +48,7 @@ describe('db', () => {
|
|
|
48
48
|
return await dbTxn.db
|
|
49
49
|
.insertInto('repo_push_event')
|
|
50
50
|
.values({
|
|
51
|
-
eventType: '
|
|
51
|
+
eventType: 'pds_takedown',
|
|
52
52
|
subjectDid: 'x',
|
|
53
53
|
})
|
|
54
54
|
.returning('subjectDid')
|
|
@@ -68,7 +68,7 @@ describe('db', () => {
|
|
|
68
68
|
.executeTakeFirst()
|
|
69
69
|
|
|
70
70
|
expect(row).toMatchObject({
|
|
71
|
-
eventType: '
|
|
71
|
+
eventType: 'pds_takedown',
|
|
72
72
|
subjectDid: 'x',
|
|
73
73
|
})
|
|
74
74
|
})
|
|
@@ -78,7 +78,7 @@ describe('db', () => {
|
|
|
78
78
|
await dbTxn.db
|
|
79
79
|
.insertInto('repo_push_event')
|
|
80
80
|
.values({
|
|
81
|
-
eventType: '
|
|
81
|
+
eventType: 'pds_takedown',
|
|
82
82
|
subjectDid: 'y',
|
|
83
83
|
})
|
|
84
84
|
.returning('subjectDid')
|
|
@@ -124,7 +124,7 @@ describe('db', () => {
|
|
|
124
124
|
leakedTx = dbTxn
|
|
125
125
|
await dbTxn.db
|
|
126
126
|
.insertInto('repo_push_event')
|
|
127
|
-
.values({ eventType: '
|
|
127
|
+
.values({ eventType: 'pds_takedown', subjectDid: 'a' })
|
|
128
128
|
.execute()
|
|
129
129
|
throw new Error('test tx failed')
|
|
130
130
|
})
|
|
@@ -132,7 +132,7 @@ describe('db', () => {
|
|
|
132
132
|
|
|
133
133
|
const attempt = leakedTx?.db
|
|
134
134
|
.insertInto('repo_push_event')
|
|
135
|
-
.values({ eventType: '
|
|
135
|
+
.values({ eventType: 'pds_takedown', subjectDid: 'b' })
|
|
136
136
|
.execute()
|
|
137
137
|
await expect(attempt).rejects.toThrow('tx already failed')
|
|
138
138
|
|
|
@@ -156,7 +156,7 @@ describe('db', () => {
|
|
|
156
156
|
const query = dbTxn.db
|
|
157
157
|
.insertInto('repo_push_event')
|
|
158
158
|
.values({
|
|
159
|
-
eventType: '
|
|
159
|
+
eventType: 'pds_takedown',
|
|
160
160
|
subjectDid: name,
|
|
161
161
|
})
|
|
162
162
|
.execute()
|
package/tests/get-record.test.ts
CHANGED
|
@@ -56,8 +56,8 @@ describe('admin get record view', () => {
|
|
|
56
56
|
cid: sc.posts[sc.dids.alice][0].ref.cidStr,
|
|
57
57
|
},
|
|
58
58
|
})
|
|
59
|
-
await modClient.
|
|
60
|
-
event: { $type: '
|
|
59
|
+
await modClient.emitEvent({
|
|
60
|
+
event: { $type: 'tools.ozone.moderation.defs#modEventTakedown' },
|
|
61
61
|
subject: {
|
|
62
62
|
$type: 'com.atproto.repo.strongRef',
|
|
63
63
|
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
@@ -67,7 +67,7 @@ describe('admin get record view', () => {
|
|
|
67
67
|
})
|
|
68
68
|
|
|
69
69
|
it('gets a record by uri, even when taken down.', async () => {
|
|
70
|
-
const result = await agent.api.
|
|
70
|
+
const result = await agent.api.tools.ozone.moderation.getRecord(
|
|
71
71
|
{ uri: sc.posts[sc.dids.alice][0].ref.uriStr },
|
|
72
72
|
{ headers: await ozone.modHeaders() },
|
|
73
73
|
)
|
|
@@ -75,7 +75,7 @@ describe('admin get record view', () => {
|
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
it('gets a record by uri and cid.', async () => {
|
|
78
|
-
const result = await agent.api.
|
|
78
|
+
const result = await agent.api.tools.ozone.moderation.getRecord(
|
|
79
79
|
{
|
|
80
80
|
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
81
81
|
cid: sc.posts[sc.dids.alice][0].ref.cidStr,
|
|
@@ -86,7 +86,7 @@ describe('admin get record view', () => {
|
|
|
86
86
|
})
|
|
87
87
|
|
|
88
88
|
it('fails when record does not exist.', async () => {
|
|
89
|
-
const promise = agent.api.
|
|
89
|
+
const promise = agent.api.tools.ozone.moderation.getRecord(
|
|
90
90
|
{
|
|
91
91
|
uri: AtUri.make(
|
|
92
92
|
sc.dids.alice,
|
|
@@ -100,7 +100,7 @@ describe('admin get record view', () => {
|
|
|
100
100
|
})
|
|
101
101
|
|
|
102
102
|
it('fails when record cid does not exist.', async () => {
|
|
103
|
-
const promise = agent.api.
|
|
103
|
+
const promise = agent.api.tools.ozone.moderation.getRecord(
|
|
104
104
|
{
|
|
105
105
|
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
106
106
|
cid: sc.posts[sc.dids.alice][1].ref.cidStr, // Mismatching cid
|
package/tests/get-repo.test.ts
CHANGED
|
@@ -38,8 +38,8 @@ describe('admin get repo view', () => {
|
|
|
38
38
|
})
|
|
39
39
|
|
|
40
40
|
beforeAll(async () => {
|
|
41
|
-
await modClient.
|
|
42
|
-
event: { $type: '
|
|
41
|
+
await modClient.emitEvent({
|
|
42
|
+
event: { $type: 'tools.ozone.moderation.defs#modEventAcknowledge' },
|
|
43
43
|
subject: {
|
|
44
44
|
$type: 'com.atproto.admin.defs#repoRef',
|
|
45
45
|
did: sc.dids.alice,
|
|
@@ -62,8 +62,8 @@ describe('admin get repo view', () => {
|
|
|
62
62
|
did: sc.dids.alice,
|
|
63
63
|
},
|
|
64
64
|
})
|
|
65
|
-
await modClient.
|
|
66
|
-
event: { $type: '
|
|
65
|
+
await modClient.emitEvent({
|
|
66
|
+
event: { $type: 'tools.ozone.moderation.defs#modEventTakedown' },
|
|
67
67
|
subject: {
|
|
68
68
|
$type: 'com.atproto.admin.defs#repoRef',
|
|
69
69
|
did: sc.dids.alice,
|
|
@@ -72,7 +72,7 @@ describe('admin get repo view', () => {
|
|
|
72
72
|
})
|
|
73
73
|
|
|
74
74
|
it('gets a repo by did, even when taken down.', async () => {
|
|
75
|
-
const result = await agent.api.
|
|
75
|
+
const result = await agent.api.tools.ozone.moderation.getRepo(
|
|
76
76
|
{ did: sc.dids.alice },
|
|
77
77
|
{ headers: await ozone.modHeaders() },
|
|
78
78
|
)
|
|
@@ -80,15 +80,15 @@ describe('admin get repo view', () => {
|
|
|
80
80
|
})
|
|
81
81
|
|
|
82
82
|
it('does not include account emails for triage mods.', async () => {
|
|
83
|
-
const { data: admin } = await agent.api.
|
|
83
|
+
const { data: admin } = await agent.api.tools.ozone.moderation.getRepo(
|
|
84
84
|
{ did: sc.dids.bob },
|
|
85
85
|
{ headers: await ozone.modHeaders() },
|
|
86
86
|
)
|
|
87
|
-
const { data: moderator } = await agent.api.
|
|
87
|
+
const { data: moderator } = await agent.api.tools.ozone.moderation.getRepo(
|
|
88
88
|
{ did: sc.dids.bob },
|
|
89
89
|
{ headers: await ozone.modHeaders('moderator') },
|
|
90
90
|
)
|
|
91
|
-
const { data: triage } = await agent.api.
|
|
91
|
+
const { data: triage } = await agent.api.tools.ozone.moderation.getRepo(
|
|
92
92
|
{ did: sc.dids.bob },
|
|
93
93
|
{ headers: await ozone.modHeaders('triage') },
|
|
94
94
|
)
|
|
@@ -100,7 +100,7 @@ describe('admin get repo view', () => {
|
|
|
100
100
|
|
|
101
101
|
it('includes emailConfirmedAt timestamp', async () => {
|
|
102
102
|
const { data: beforeEmailVerification } =
|
|
103
|
-
await agent.api.
|
|
103
|
+
await agent.api.tools.ozone.moderation.getRepo(
|
|
104
104
|
{ did: sc.dids.bob },
|
|
105
105
|
{ headers: await ozone.modHeaders() },
|
|
106
106
|
)
|
|
@@ -122,7 +122,7 @@ describe('admin get repo view', () => {
|
|
|
122
122
|
},
|
|
123
123
|
)
|
|
124
124
|
const { data: afterEmailVerification } =
|
|
125
|
-
await agent.api.
|
|
125
|
+
await agent.api.tools.ozone.moderation.getRepo(
|
|
126
126
|
{ did: sc.dids.bob },
|
|
127
127
|
{ headers: await ozone.modHeaders() },
|
|
128
128
|
)
|
|
@@ -134,7 +134,7 @@ describe('admin get repo view', () => {
|
|
|
134
134
|
})
|
|
135
135
|
|
|
136
136
|
it('fails when repo does not exist.', async () => {
|
|
137
|
-
const promise = agent.api.
|
|
137
|
+
const promise = agent.api.tools.ozone.moderation.getRepo(
|
|
138
138
|
{ did: 'did:plc:doesnotexist' },
|
|
139
139
|
{ headers: await ozone.modHeaders() },
|
|
140
140
|
)
|
|
@@ -4,17 +4,17 @@ import {
|
|
|
4
4
|
basicSeed,
|
|
5
5
|
ModeratorClient,
|
|
6
6
|
} from '@atproto/dev-env'
|
|
7
|
-
import {
|
|
7
|
+
import { ToolsOzoneModerationDefs } from '@atproto/api'
|
|
8
8
|
import {
|
|
9
9
|
REASONMISLEADING,
|
|
10
10
|
REASONSPAM,
|
|
11
|
+
REASONAPPEAL,
|
|
11
12
|
} from '../src/lexicon/types/com/atproto/moderation/defs'
|
|
12
13
|
import {
|
|
13
14
|
REVIEWCLOSED,
|
|
14
15
|
REVIEWOPEN,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import { REVIEWESCALATED } from '../src/lexicon/types/com/atproto/admin/defs'
|
|
16
|
+
REVIEWESCALATED,
|
|
17
|
+
} from '@atproto/api/src/client/types/tools/ozone/moderation/defs'
|
|
18
18
|
|
|
19
19
|
describe('moderation-appeals', () => {
|
|
20
20
|
let network: TestNetwork
|
|
@@ -39,8 +39,8 @@ describe('moderation-appeals', () => {
|
|
|
39
39
|
subject: string,
|
|
40
40
|
status: string,
|
|
41
41
|
appealed: boolean | undefined,
|
|
42
|
-
): Promise<
|
|
43
|
-
const res = await modClient.
|
|
42
|
+
): Promise<ToolsOzoneModerationDefs.SubjectStatusView | undefined> => {
|
|
43
|
+
const res = await modClient.queryStatuses({
|
|
44
44
|
subject,
|
|
45
45
|
})
|
|
46
46
|
expect(res.subjectStatuses[0]?.reviewState).toEqual(status)
|
|
@@ -66,9 +66,9 @@ describe('moderation-appeals', () => {
|
|
|
66
66
|
|
|
67
67
|
it('only changes subject status if original author of the content or a moderator is appealing', async () => {
|
|
68
68
|
// Create a report by alice
|
|
69
|
-
await modClient.
|
|
69
|
+
await modClient.emitEvent({
|
|
70
70
|
event: {
|
|
71
|
-
$type: '
|
|
71
|
+
$type: 'tools.ozone.moderation.defs#modEventReport',
|
|
72
72
|
reportType: REASONMISLEADING,
|
|
73
73
|
},
|
|
74
74
|
subject: getBobsPostSubject(),
|
|
@@ -90,9 +90,9 @@ describe('moderation-appeals', () => {
|
|
|
90
90
|
await assertBobsPostStatus(REVIEWOPEN, undefined)
|
|
91
91
|
|
|
92
92
|
// Emit report event as moderator
|
|
93
|
-
await modClient.
|
|
93
|
+
await modClient.emitEvent({
|
|
94
94
|
event: {
|
|
95
|
-
$type: '
|
|
95
|
+
$type: 'tools.ozone.moderation.defs#modEventReport',
|
|
96
96
|
reportType: REASONAPPEAL,
|
|
97
97
|
},
|
|
98
98
|
subject: getBobsPostSubject(),
|
|
@@ -132,18 +132,18 @@ describe('moderation-appeals', () => {
|
|
|
132
132
|
})
|
|
133
133
|
it('allows multiple appeals and updates last appealed timestamp', async () => {
|
|
134
134
|
// Resolve appeal with acknowledge
|
|
135
|
-
await modClient.
|
|
135
|
+
await modClient.emitEvent({
|
|
136
136
|
event: {
|
|
137
|
-
$type: '
|
|
137
|
+
$type: 'tools.ozone.moderation.defs#modEventResolveAppeal',
|
|
138
138
|
},
|
|
139
139
|
subject: getBobsPostSubject(),
|
|
140
140
|
})
|
|
141
141
|
|
|
142
142
|
const previousStatus = await assertBobsPostStatus(REVIEWESCALATED, false)
|
|
143
143
|
|
|
144
|
-
await modClient.
|
|
144
|
+
await modClient.emitEvent({
|
|
145
145
|
event: {
|
|
146
|
-
$type: '
|
|
146
|
+
$type: 'tools.ozone.moderation.defs#modEventReport',
|
|
147
147
|
reportType: REASONAPPEAL,
|
|
148
148
|
},
|
|
149
149
|
subject: getBobsPostSubject(),
|
|
@@ -165,26 +165,26 @@ describe('moderation-appeals', () => {
|
|
|
165
165
|
})
|
|
166
166
|
it('appeal status is maintained while review state changes based on incoming events', async () => {
|
|
167
167
|
// Bob reports alice's post
|
|
168
|
-
await modClient.
|
|
168
|
+
await modClient.emitEvent({
|
|
169
169
|
event: {
|
|
170
|
-
$type: '
|
|
170
|
+
$type: 'tools.ozone.moderation.defs#modEventReport',
|
|
171
171
|
reportType: REASONMISLEADING,
|
|
172
172
|
},
|
|
173
173
|
subject: getAlicesPostSubject(),
|
|
174
174
|
})
|
|
175
175
|
|
|
176
176
|
// Moderator acknowledges the report, assume a label was applied too
|
|
177
|
-
await modClient.
|
|
177
|
+
await modClient.emitEvent({
|
|
178
178
|
event: {
|
|
179
|
-
$type: '
|
|
179
|
+
$type: 'tools.ozone.moderation.defs#modEventAcknowledge',
|
|
180
180
|
},
|
|
181
181
|
subject: getAlicesPostSubject(),
|
|
182
182
|
})
|
|
183
183
|
|
|
184
184
|
// Alice appeals the report
|
|
185
|
-
await modClient.
|
|
185
|
+
await modClient.emitEvent({
|
|
186
186
|
event: {
|
|
187
|
-
$type: '
|
|
187
|
+
$type: 'tools.ozone.moderation.defs#modEventReport',
|
|
188
188
|
reportType: REASONAPPEAL,
|
|
189
189
|
},
|
|
190
190
|
subject: getAlicesPostSubject(),
|
|
@@ -197,9 +197,9 @@ describe('moderation-appeals', () => {
|
|
|
197
197
|
)
|
|
198
198
|
|
|
199
199
|
// Bob reports it again
|
|
200
|
-
await modClient.
|
|
200
|
+
await modClient.emitEvent({
|
|
201
201
|
event: {
|
|
202
|
-
$type: '
|
|
202
|
+
$type: 'tools.ozone.moderation.defs#modEventReport',
|
|
203
203
|
reportType: REASONSPAM,
|
|
204
204
|
},
|
|
205
205
|
subject: getAlicesPostSubject(),
|
|
@@ -213,9 +213,9 @@ describe('moderation-appeals', () => {
|
|
|
213
213
|
)
|
|
214
214
|
|
|
215
215
|
// Emit an escalation event
|
|
216
|
-
await modClient.
|
|
216
|
+
await modClient.emitEvent({
|
|
217
217
|
event: {
|
|
218
|
-
$type: '
|
|
218
|
+
$type: 'tools.ozone.moderation.defs#modEventEscalate',
|
|
219
219
|
},
|
|
220
220
|
subject: getAlicesPostSubject(),
|
|
221
221
|
})
|
|
@@ -227,9 +227,9 @@ describe('moderation-appeals', () => {
|
|
|
227
227
|
)
|
|
228
228
|
|
|
229
229
|
// Emit an acknowledge event
|
|
230
|
-
await modClient.
|
|
230
|
+
await modClient.emitEvent({
|
|
231
231
|
event: {
|
|
232
|
-
$type: '
|
|
232
|
+
$type: 'tools.ozone.moderation.defs#modEventAcknowledge',
|
|
233
233
|
},
|
|
234
234
|
subject: getAlicesPostSubject(),
|
|
235
235
|
})
|
|
@@ -238,9 +238,9 @@ describe('moderation-appeals', () => {
|
|
|
238
238
|
await assertSubjectStatus(getAlicesPostSubject().uri, REVIEWCLOSED, true)
|
|
239
239
|
|
|
240
240
|
// Emit a resolveAppeal event
|
|
241
|
-
await modClient.
|
|
241
|
+
await modClient.emitEvent({
|
|
242
242
|
event: {
|
|
243
|
-
$type: '
|
|
243
|
+
$type: 'tools.ozone.moderation.defs#modEventResolveAppeal',
|
|
244
244
|
comment: 'lgtm',
|
|
245
245
|
},
|
|
246
246
|
subject: getAlicesPostSubject(),
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
basicSeed,
|
|
7
7
|
ModeratorClient,
|
|
8
8
|
} from '@atproto/dev-env'
|
|
9
|
-
import {
|
|
9
|
+
import { ToolsOzoneModerationDefs } from '@atproto/api'
|
|
10
10
|
import Mail from 'nodemailer/lib/mailer'
|
|
11
11
|
import { forSnapshot } from './_util'
|
|
12
12
|
import {
|
|
@@ -76,10 +76,10 @@ describe('moderation-events', () => {
|
|
|
76
76
|
describe('query events', () => {
|
|
77
77
|
it('returns all events for record or repo', async () => {
|
|
78
78
|
const [bobsEvents, alicesPostEvents] = await Promise.all([
|
|
79
|
-
modClient.
|
|
79
|
+
modClient.queryEvents({
|
|
80
80
|
subject: sc.dids.bob,
|
|
81
81
|
}),
|
|
82
|
-
modClient.
|
|
82
|
+
modClient.queryEvents({
|
|
83
83
|
subject: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
84
84
|
}),
|
|
85
85
|
])
|
|
@@ -94,28 +94,28 @@ describe('moderation-events', () => {
|
|
|
94
94
|
did: sc.dids.alice,
|
|
95
95
|
}
|
|
96
96
|
await Promise.all([
|
|
97
|
-
modClient.
|
|
97
|
+
modClient.emitEvent({
|
|
98
98
|
event: {
|
|
99
|
-
$type: '
|
|
99
|
+
$type: 'tools.ozone.moderation.defs#modEventComment',
|
|
100
100
|
comment: 'X',
|
|
101
101
|
},
|
|
102
102
|
subject: alicesAccount,
|
|
103
103
|
}),
|
|
104
|
-
modClient.
|
|
104
|
+
modClient.emitEvent({
|
|
105
105
|
event: {
|
|
106
|
-
$type: '
|
|
106
|
+
$type: 'tools.ozone.moderation.defs#modEventEscalate',
|
|
107
107
|
comment: 'X',
|
|
108
108
|
},
|
|
109
109
|
subject: alicesAccount,
|
|
110
110
|
}),
|
|
111
111
|
])
|
|
112
112
|
const [allEvents, reportEvents] = await Promise.all([
|
|
113
|
-
modClient.
|
|
113
|
+
modClient.queryEvents({
|
|
114
114
|
subject: sc.dids.alice,
|
|
115
115
|
}),
|
|
116
|
-
modClient.
|
|
116
|
+
modClient.queryEvents({
|
|
117
117
|
subject: sc.dids.alice,
|
|
118
|
-
types: ['
|
|
118
|
+
types: ['tools.ozone.moderation.defs#modEventReport'],
|
|
119
119
|
}),
|
|
120
120
|
])
|
|
121
121
|
|
|
@@ -133,11 +133,11 @@ describe('moderation-events', () => {
|
|
|
133
133
|
|
|
134
134
|
it('returns events for all content by user', async () => {
|
|
135
135
|
const [forAccount, forPost] = await Promise.all([
|
|
136
|
-
modClient.
|
|
136
|
+
modClient.queryEvents({
|
|
137
137
|
subject: sc.dids.bob,
|
|
138
138
|
includeAllUserRecords: true,
|
|
139
139
|
}),
|
|
140
|
-
modClient.
|
|
140
|
+
modClient.queryEvents({
|
|
141
141
|
subject: sc.posts[sc.dids.bob][0].ref.uriStr,
|
|
142
142
|
includeAllUserRecords: true,
|
|
143
143
|
}),
|
|
@@ -151,7 +151,7 @@ describe('moderation-events', () => {
|
|
|
151
151
|
})
|
|
152
152
|
|
|
153
153
|
it('returns paginated list of events with cursor', async () => {
|
|
154
|
-
const allEvents = await modClient.
|
|
154
|
+
const allEvents = await modClient.queryEvents({
|
|
155
155
|
subject: sc.dids.bob,
|
|
156
156
|
includeAllUserRecords: true,
|
|
157
157
|
})
|
|
@@ -160,11 +160,11 @@ describe('moderation-events', () => {
|
|
|
160
160
|
sortDirection: 'asc' | 'desc' = 'desc',
|
|
161
161
|
) => {
|
|
162
162
|
let defaultCursor: undefined | string = undefined
|
|
163
|
-
const events:
|
|
163
|
+
const events: ToolsOzoneModerationDefs.ModEventView[] = []
|
|
164
164
|
let count = 0
|
|
165
165
|
do {
|
|
166
166
|
// get 1 event at a time and check we get all events
|
|
167
|
-
const res = await modClient.
|
|
167
|
+
const res = await modClient.queryEvents({
|
|
168
168
|
limit: 1,
|
|
169
169
|
subject: sc.dids.bob,
|
|
170
170
|
includeAllUserRecords: true,
|
|
@@ -194,10 +194,10 @@ describe('moderation-events', () => {
|
|
|
194
194
|
|
|
195
195
|
it('returns report events matching reportType filters', async () => {
|
|
196
196
|
const [spamEvents, misleadingEvents] = await Promise.all([
|
|
197
|
-
modClient.
|
|
197
|
+
modClient.queryEvents({
|
|
198
198
|
reportTypes: [REASONSPAM],
|
|
199
199
|
}),
|
|
200
|
-
modClient.
|
|
200
|
+
modClient.queryEvents({
|
|
201
201
|
reportTypes: [REASONMISLEADING, REASONAPPEAL],
|
|
202
202
|
}),
|
|
203
203
|
])
|
|
@@ -209,13 +209,13 @@ describe('moderation-events', () => {
|
|
|
209
209
|
it('returns events matching keyword in comment', async () => {
|
|
210
210
|
const [eventsWithX, eventsWithTest, eventsWithComment] =
|
|
211
211
|
await Promise.all([
|
|
212
|
-
modClient.
|
|
212
|
+
modClient.queryEvents({
|
|
213
213
|
comment: 'X',
|
|
214
214
|
}),
|
|
215
|
-
modClient.
|
|
215
|
+
modClient.queryEvents({
|
|
216
216
|
comment: 'test',
|
|
217
217
|
}),
|
|
218
|
-
modClient.
|
|
218
|
+
modClient.queryEvents({
|
|
219
219
|
hasComment: true,
|
|
220
220
|
}),
|
|
221
221
|
])
|
|
@@ -227,9 +227,9 @@ describe('moderation-events', () => {
|
|
|
227
227
|
|
|
228
228
|
it('returns events matching filter params for labels', async () => {
|
|
229
229
|
const [negatedLabelEvent, createdLabelEvent] = await Promise.all([
|
|
230
|
-
modClient.
|
|
230
|
+
modClient.emitEvent({
|
|
231
231
|
event: {
|
|
232
|
-
$type: '
|
|
232
|
+
$type: 'tools.ozone.moderation.defs#modEventLabel',
|
|
233
233
|
comment: 'X',
|
|
234
234
|
negateLabelVals: ['L1', 'L2'],
|
|
235
235
|
createLabelVals: [],
|
|
@@ -240,9 +240,9 @@ describe('moderation-events', () => {
|
|
|
240
240
|
did: sc.dids.alice,
|
|
241
241
|
},
|
|
242
242
|
}),
|
|
243
|
-
modClient.
|
|
243
|
+
modClient.emitEvent({
|
|
244
244
|
event: {
|
|
245
|
-
$type: '
|
|
245
|
+
$type: 'tools.ozone.moderation.defs#modEventLabel',
|
|
246
246
|
comment: 'X',
|
|
247
247
|
createLabelVals: ['L1', 'L2'],
|
|
248
248
|
negateLabelVals: [],
|
|
@@ -256,16 +256,16 @@ describe('moderation-events', () => {
|
|
|
256
256
|
])
|
|
257
257
|
const [withTwoLabels, withoutTwoLabels, withOneLabel, withoutOneLabel] =
|
|
258
258
|
await Promise.all([
|
|
259
|
-
modClient.
|
|
259
|
+
modClient.queryEvents({
|
|
260
260
|
addedLabels: ['L1', 'L3'],
|
|
261
261
|
}),
|
|
262
|
-
modClient.
|
|
262
|
+
modClient.queryEvents({
|
|
263
263
|
removedLabels: ['L1', 'L2'],
|
|
264
264
|
}),
|
|
265
|
-
modClient.
|
|
265
|
+
modClient.queryEvents({
|
|
266
266
|
addedLabels: ['L1'],
|
|
267
267
|
}),
|
|
268
|
-
modClient.
|
|
268
|
+
modClient.queryEvents({
|
|
269
269
|
removedLabels: ['L2'],
|
|
270
270
|
}),
|
|
271
271
|
])
|
|
@@ -286,9 +286,9 @@ describe('moderation-events', () => {
|
|
|
286
286
|
add: string[]
|
|
287
287
|
remove: string[]
|
|
288
288
|
}) =>
|
|
289
|
-
modClient.
|
|
289
|
+
modClient.emitEvent({
|
|
290
290
|
event: {
|
|
291
|
-
$type: '
|
|
291
|
+
$type: 'tools.ozone.moderation.defs#modEventTag',
|
|
292
292
|
comment: 'X',
|
|
293
293
|
add,
|
|
294
294
|
remove,
|
|
@@ -301,14 +301,14 @@ describe('moderation-events', () => {
|
|
|
301
301
|
const addEvent = await tagEvent({ add: ['L1', 'L2'], remove: [] })
|
|
302
302
|
const addAndRemoveEvent = await tagEvent({ add: ['L3'], remove: ['L2'] })
|
|
303
303
|
const [addFinder, addAndRemoveFinder, _removeFinder] = await Promise.all([
|
|
304
|
-
modClient.
|
|
304
|
+
modClient.queryEvents({
|
|
305
305
|
addedTags: ['L1'],
|
|
306
306
|
}),
|
|
307
|
-
modClient.
|
|
307
|
+
modClient.queryEvents({
|
|
308
308
|
addedTags: ['L3'],
|
|
309
309
|
removedTags: ['L2'],
|
|
310
310
|
}),
|
|
311
|
-
modClient.
|
|
311
|
+
modClient.queryEvents({
|
|
312
312
|
removedTags: ['L2'],
|
|
313
313
|
}),
|
|
314
314
|
])
|
|
@@ -334,9 +334,9 @@ describe('moderation-events', () => {
|
|
|
334
334
|
it('are tracked on takedown event', async () => {
|
|
335
335
|
const post = sc.posts[sc.dids.carol][0]
|
|
336
336
|
assert(post.images.length > 1)
|
|
337
|
-
await modClient.
|
|
337
|
+
await modClient.emitEvent({
|
|
338
338
|
event: {
|
|
339
|
-
$type: '
|
|
339
|
+
$type: 'tools.ozone.moderation.defs#modEventTakedown',
|
|
340
340
|
},
|
|
341
341
|
subject: {
|
|
342
342
|
$type: 'com.atproto.repo.strongRef',
|
|
@@ -345,14 +345,14 @@ describe('moderation-events', () => {
|
|
|
345
345
|
},
|
|
346
346
|
subjectBlobCids: [post.images[0].image.ref.toString()],
|
|
347
347
|
})
|
|
348
|
-
const result = await modClient.
|
|
348
|
+
const result = await modClient.queryEvents({
|
|
349
349
|
subject: post.ref.uriStr,
|
|
350
|
-
types: ['
|
|
350
|
+
types: ['tools.ozone.moderation.defs#modEventTakedown'],
|
|
351
351
|
})
|
|
352
352
|
expect(result.events[0]).toMatchObject({
|
|
353
353
|
createdBy: network.ozone.moderatorAccnt.did,
|
|
354
354
|
event: {
|
|
355
|
-
$type: '
|
|
355
|
+
$type: 'tools.ozone.moderation.defs#modEventTakedown',
|
|
356
356
|
},
|
|
357
357
|
subjectBlobCids: [post.images[0].image.ref.toString()],
|
|
358
358
|
})
|
|
@@ -360,9 +360,9 @@ describe('moderation-events', () => {
|
|
|
360
360
|
|
|
361
361
|
it("are tracked on reverse-takedown event even if they aren't specified", async () => {
|
|
362
362
|
const post = sc.posts[sc.dids.carol][0]
|
|
363
|
-
await modClient.
|
|
363
|
+
await modClient.emitEvent({
|
|
364
364
|
event: {
|
|
365
|
-
$type: '
|
|
365
|
+
$type: 'tools.ozone.moderation.defs#modEventReverseTakedown',
|
|
366
366
|
},
|
|
367
367
|
subject: {
|
|
368
368
|
$type: 'com.atproto.repo.strongRef',
|
|
@@ -370,13 +370,13 @@ describe('moderation-events', () => {
|
|
|
370
370
|
cid: post.ref.cidStr,
|
|
371
371
|
},
|
|
372
372
|
})
|
|
373
|
-
const result = await modClient.
|
|
373
|
+
const result = await modClient.queryEvents({
|
|
374
374
|
subject: post.ref.uriStr,
|
|
375
375
|
})
|
|
376
376
|
expect(result.events[0]).toMatchObject({
|
|
377
377
|
createdBy: network.ozone.moderatorAccnt.did,
|
|
378
378
|
event: {
|
|
379
|
-
$type: '
|
|
379
|
+
$type: 'tools.ozone.moderation.defs#modEventReverseTakedown',
|
|
380
380
|
},
|
|
381
381
|
subjectBlobCids: [post.images[0].image.ref.toString()],
|
|
382
382
|
})
|
|
@@ -408,9 +408,9 @@ describe('moderation-events', () => {
|
|
|
408
408
|
|
|
409
409
|
it('sends email via pds.', async () => {
|
|
410
410
|
const mail = await getMailFrom(
|
|
411
|
-
modClient.
|
|
411
|
+
modClient.emitEvent({
|
|
412
412
|
event: {
|
|
413
|
-
$type: '
|
|
413
|
+
$type: 'tools.ozone.moderation.defs#modEventEmail',
|
|
414
414
|
comment: 'Reaching out to Alice',
|
|
415
415
|
subjectLine: 'Hello',
|
|
416
416
|
content: 'Hey Alice, how are you?',
|
|
@@ -37,32 +37,30 @@ describe('moderation-status-tags', () => {
|
|
|
37
37
|
subject: bobsAccount,
|
|
38
38
|
reportedBy: sc.dids.alice,
|
|
39
39
|
})
|
|
40
|
-
await modClient.
|
|
40
|
+
await modClient.emitEvent({
|
|
41
41
|
subject: bobsAccount,
|
|
42
42
|
event: {
|
|
43
|
-
$type: '
|
|
43
|
+
$type: 'tools.ozone.moderation.defs#modEventTag',
|
|
44
44
|
add: ['interaction-churn'],
|
|
45
45
|
remove: [],
|
|
46
46
|
},
|
|
47
47
|
})
|
|
48
|
-
const statusAfterInteractionTag = await modClient.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
)
|
|
48
|
+
const statusAfterInteractionTag = await modClient.queryStatuses({
|
|
49
|
+
subject: bobsAccount.did,
|
|
50
|
+
})
|
|
53
51
|
expect(statusAfterInteractionTag.subjectStatuses[0].tags).toContain(
|
|
54
52
|
'interaction-churn',
|
|
55
53
|
)
|
|
56
54
|
|
|
57
|
-
await modClient.
|
|
55
|
+
await modClient.emitEvent({
|
|
58
56
|
subject: bobsAccount,
|
|
59
57
|
event: {
|
|
60
|
-
$type: '
|
|
58
|
+
$type: 'tools.ozone.moderation.defs#modEventTag',
|
|
61
59
|
remove: ['interaction-churn'],
|
|
62
60
|
add: ['follow-churn'],
|
|
63
61
|
},
|
|
64
62
|
})
|
|
65
|
-
const statusAfterFollowTag = await modClient.
|
|
63
|
+
const statusAfterFollowTag = await modClient.queryStatuses({
|
|
66
64
|
subject: bobsAccount.did,
|
|
67
65
|
})
|
|
68
66
|
|