@atproto/ozone 0.1.10 → 0.1.11
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 +9 -0
- package/dist/api/moderation/emitEvent.d.ts.map +1 -1
- package/dist/api/moderation/emitEvent.js +4 -0
- package/dist/api/moderation/emitEvent.js.map +1 -1
- package/dist/api/moderation/queryStatuses.d.ts.map +1 -1
- package/dist/api/moderation/queryStatuses.js +2 -1
- package/dist/api/moderation/queryStatuses.js.map +1 -1
- package/dist/api/util.d.ts +1 -1
- package/dist/api/util.d.ts.map +1 -1
- package/dist/api/util.js +2 -0
- package/dist/api/util.js.map +1 -1
- package/dist/db/migrations/20240408T192432676Z-mute-reporting.d.ts +4 -0
- package/dist/db/migrations/20240408T192432676Z-mute-reporting.d.ts.map +1 -0
- package/dist/db/migrations/20240408T192432676Z-mute-reporting.js +18 -0
- package/dist/db/migrations/20240408T192432676Z-mute-reporting.js.map +1 -0
- package/dist/db/migrations/index.d.ts +1 -0
- package/dist/db/migrations/index.d.ts.map +1 -1
- package/dist/db/migrations/index.js +2 -1
- package/dist/db/migrations/index.js.map +1 -1
- package/dist/db/schema/moderation_event.d.ts +1 -1
- package/dist/db/schema/moderation_event.d.ts.map +1 -1
- package/dist/db/schema/moderation_subject_status.d.ts +1 -0
- package/dist/db/schema/moderation_subject_status.d.ts.map +1 -1
- package/dist/lexicon/lexicons.d.ts +36 -0
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +45 -0
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts +22 -2
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/defs.js +22 -2
- package/dist/lexicon/types/tools/ozone/moderation/defs.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/emitEvent.d.ts +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/emitEvent.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/queryStatuses.d.ts +2 -0
- package/dist/lexicon/types/tools/ozone/moderation/queryStatuses.d.ts.map +1 -1
- package/dist/mod-service/index.d.ts +6 -2
- package/dist/mod-service/index.d.ts.map +1 -1
- package/dist/mod-service/index.js +25 -1
- package/dist/mod-service/index.js.map +1 -1
- package/dist/mod-service/status.d.ts +21 -1
- package/dist/mod-service/status.d.ts.map +1 -1
- package/dist/mod-service/status.js +23 -0
- package/dist/mod-service/status.js.map +1 -1
- package/dist/mod-service/views.d.ts.map +1 -1
- package/dist/mod-service/views.js +3 -0
- package/dist/mod-service/views.js.map +1 -1
- package/package.json +3 -3
- package/src/api/moderation/emitEvent.ts +9 -0
- package/src/api/moderation/queryStatuses.ts +2 -0
- package/src/api/util.ts +2 -0
- package/src/db/migrations/20240408T192432676Z-mute-reporting.ts +15 -0
- package/src/db/migrations/index.ts +1 -0
- package/src/db/schema/moderation_event.ts +3 -0
- package/src/db/schema/moderation_subject_status.ts +1 -0
- package/src/lexicon/lexicons.ts +47 -0
- package/src/lexicon/types/tools/ozone/moderation/defs.ts +56 -0
- package/src/lexicon/types/tools/ozone/moderation/emitEvent.ts +3 -0
- package/src/lexicon/types/tools/ozone/moderation/queryStatuses.ts +2 -0
- package/src/mod-service/index.ts +33 -0
- package/src/mod-service/status.ts +26 -0
- package/src/mod-service/views.ts +3 -0
- package/tests/__snapshots__/moderation-events.test.ts.snap +5 -0
- package/tests/report-muting.test.ts +100 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TestNetwork,
|
|
3
|
+
SeedClient,
|
|
4
|
+
basicSeed,
|
|
5
|
+
ModeratorClient,
|
|
6
|
+
} from '@atproto/dev-env'
|
|
7
|
+
import {
|
|
8
|
+
ComAtprotoModerationDefs,
|
|
9
|
+
ToolsOzoneModerationDefs,
|
|
10
|
+
} from '@atproto/api'
|
|
11
|
+
import {
|
|
12
|
+
REVIEWNONE,
|
|
13
|
+
REVIEWOPEN,
|
|
14
|
+
} from '../src/lexicon/types/tools/ozone/moderation/defs'
|
|
15
|
+
|
|
16
|
+
describe('report-muting', () => {
|
|
17
|
+
let network: TestNetwork
|
|
18
|
+
let sc: SeedClient
|
|
19
|
+
let modClient: ModeratorClient
|
|
20
|
+
|
|
21
|
+
beforeAll(async () => {
|
|
22
|
+
network = await TestNetwork.create({
|
|
23
|
+
dbPostgresSchema: 'ozone_report_muting',
|
|
24
|
+
})
|
|
25
|
+
sc = network.getSeedClient()
|
|
26
|
+
modClient = network.ozone.getModClient()
|
|
27
|
+
await basicSeed(sc)
|
|
28
|
+
await network.processAll()
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
afterAll(async () => {
|
|
32
|
+
await network.close()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const assertSubjectStatus = async (
|
|
36
|
+
subject: string,
|
|
37
|
+
status?: string,
|
|
38
|
+
): Promise<ToolsOzoneModerationDefs.SubjectStatusView | undefined> => {
|
|
39
|
+
const res = await modClient.queryStatuses({
|
|
40
|
+
subject,
|
|
41
|
+
})
|
|
42
|
+
expect(res.subjectStatuses[0]?.reviewState).toEqual(status)
|
|
43
|
+
return res.subjectStatuses[0]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
it('does not change reviewState when muted reporter reports', async () => {
|
|
47
|
+
const bobsPostSubject = {
|
|
48
|
+
$type: 'com.atproto.repo.strongRef',
|
|
49
|
+
uri: sc.posts[sc.dids.bob][1].ref.uriStr,
|
|
50
|
+
cid: sc.posts[sc.dids.bob][1].ref.cidStr,
|
|
51
|
+
}
|
|
52
|
+
const carolsAccountSubject = {
|
|
53
|
+
$type: 'com.atproto.admin.defs#repoRef',
|
|
54
|
+
did: sc.dids.carol,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
await modClient.emitEvent({
|
|
58
|
+
event: {
|
|
59
|
+
$type: 'tools.ozone.moderation.defs#modEventMuteReporter',
|
|
60
|
+
durationInHours: 24,
|
|
61
|
+
},
|
|
62
|
+
subject: carolsAccountSubject,
|
|
63
|
+
})
|
|
64
|
+
await sc.createReport({
|
|
65
|
+
reportedBy: sc.dids.carol,
|
|
66
|
+
reasonType: ComAtprotoModerationDefs.REASONMISLEADING,
|
|
67
|
+
reason: 'misleading',
|
|
68
|
+
subject: bobsPostSubject,
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
// Verify that a subject status was not created for bob's post since the reporter was muted
|
|
72
|
+
await assertSubjectStatus(bobsPostSubject.uri, undefined)
|
|
73
|
+
// Verify, however, that the event was logged
|
|
74
|
+
await modClient.queryEvents({
|
|
75
|
+
subject: bobsPostSubject.uri,
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
// Verify that reporting mute duration is stored for the reporter
|
|
79
|
+
const carolsStatus = await assertSubjectStatus(sc.dids.carol, REVIEWNONE)
|
|
80
|
+
expect(
|
|
81
|
+
new Date(`${carolsStatus?.muteReportingUntil}`).getTime(),
|
|
82
|
+
).toBeGreaterThan(Date.now())
|
|
83
|
+
|
|
84
|
+
await modClient.emitEvent({
|
|
85
|
+
event: {
|
|
86
|
+
$type: 'tools.ozone.moderation.defs#modEventUnmuteReporter',
|
|
87
|
+
},
|
|
88
|
+
subject: carolsAccountSubject,
|
|
89
|
+
})
|
|
90
|
+
await sc.createReport({
|
|
91
|
+
reportedBy: sc.dids.carol,
|
|
92
|
+
reasonType: ComAtprotoModerationDefs.REASONMISLEADING,
|
|
93
|
+
reason: 'misleading',
|
|
94
|
+
subject: bobsPostSubject,
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
// Verify that a subject status was created for bob's post since the reporter was no longer muted
|
|
98
|
+
await assertSubjectStatus(bobsPostSubject.uri, REVIEWOPEN)
|
|
99
|
+
})
|
|
100
|
+
})
|