@atproto/ozone 0.1.15 → 0.1.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.
@@ -0,0 +1,109 @@
1
+ import {
2
+ SeedClient,
3
+ TestNetwork,
4
+ TestOzone,
5
+ basicSeed,
6
+ ModeratorClient,
7
+ RecordRef,
8
+ } from '@atproto/dev-env'
9
+ import AtpAgent, { BSKY_LABELER_DID } from '@atproto/api'
10
+ import { TAKEDOWN_LABEL } from '../src/mod-service'
11
+
12
+ describe('admin get lists', () => {
13
+ let network: TestNetwork
14
+ let ozone: TestOzone
15
+ let agent: AtpAgent
16
+ let appviewAgent: AtpAgent
17
+ let sc: SeedClient
18
+ let modClient: ModeratorClient
19
+ let alicesList: RecordRef
20
+
21
+ beforeAll(async () => {
22
+ network = await TestNetwork.create({
23
+ dbPostgresSchema: 'ozone_admin_get_lists',
24
+ })
25
+ ozone = network.ozone
26
+ agent = ozone.getClient()
27
+ appviewAgent = network.bsky.getClient()
28
+ sc = network.getSeedClient()
29
+ modClient = ozone.getModClient()
30
+ await basicSeed(sc)
31
+ alicesList = await sc.createList(sc.dids.alice, "Alice's List", 'mod')
32
+ AtpAgent.configure({ appLabelers: [ozone.ctx.cfg.service.did] })
33
+ await network.processAll()
34
+ })
35
+
36
+ afterAll(async () => {
37
+ AtpAgent.configure({ appLabelers: [BSKY_LABELER_DID] })
38
+ await network.close()
39
+ })
40
+
41
+ const getAlicesList = async () => {
42
+ const [{ data: fromOzone }, { data: fromAppview }] = await Promise.all([
43
+ agent.api.app.bsky.graph.getLists(
44
+ { actor: sc.dids.alice },
45
+ { headers: await ozone.modHeaders() },
46
+ ),
47
+ appviewAgent.api.app.bsky.graph.getLists({ actor: sc.dids.alice }),
48
+ ])
49
+
50
+ return { fromOzone, fromAppview }
51
+ }
52
+
53
+ it('returns lists from takendown account', async () => {
54
+ const beforeTakedown = await getAlicesList()
55
+ expect(beforeTakedown.fromOzone.lists[0].uri).toEqual(alicesList.uriStr)
56
+ expect(beforeTakedown.fromAppview.lists[0].uri).toEqual(alicesList.uriStr)
57
+
58
+ // Takedown alice's account
59
+ await modClient.emitEvent({
60
+ event: { $type: 'tools.ozone.moderation.defs#modEventTakedown' },
61
+ subject: {
62
+ $type: 'com.atproto.admin.defs#repoRef',
63
+ did: sc.dids.alice,
64
+ },
65
+ })
66
+ await network.processAll()
67
+
68
+ const afterTakedown = await getAlicesList()
69
+
70
+ // Verify that takendown list is shown when queried through ozone but not through appview
71
+ expect(afterTakedown.fromAppview.lists.length).toBe(0)
72
+ expect(afterTakedown.fromOzone.lists[0].uri).toEqual(alicesList.uriStr)
73
+
74
+ // Reverse alice's account takedown
75
+ await modClient.emitEvent({
76
+ event: { $type: 'tools.ozone.moderation.defs#modEventReverseTakedown' },
77
+ subject: {
78
+ $type: 'com.atproto.admin.defs#repoRef',
79
+ did: sc.dids.alice,
80
+ },
81
+ })
82
+ await network.processAll()
83
+ })
84
+
85
+ it('returns takendown lists', async () => {
86
+ const beforeTakedown = await getAlicesList()
87
+ expect(beforeTakedown.fromOzone.lists[0].uri).toEqual(alicesList.uriStr)
88
+ expect(beforeTakedown.fromAppview.lists[0].uri).toEqual(alicesList.uriStr)
89
+
90
+ // Takedown alice's list using a !takedown label
91
+ await network.bsky.db.db
92
+ .insertInto('label')
93
+ .values({
94
+ src: ozone.ctx.cfg.service.did,
95
+ uri: alicesList.uriStr,
96
+ cid: alicesList.cidStr,
97
+ val: TAKEDOWN_LABEL,
98
+ neg: false,
99
+ cts: new Date().toISOString(),
100
+ })
101
+ .execute()
102
+
103
+ const afterTakedown = await getAlicesList()
104
+
105
+ // Verify that takendown list is shown when queried through ozone but not through appview
106
+ expect(afterTakedown.fromAppview.lists.length).toBe(0)
107
+ expect(afterTakedown.fromOzone.lists[0].uri).toEqual(alicesList.uriStr)
108
+ })
109
+ })