@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.
- package/CHANGELOG.md +9 -0
- package/dist/api/moderation/getRecord.d.ts.map +1 -1
- package/dist/api/moderation/getRecord.js +3 -2
- package/dist/api/moderation/getRecord.js.map +1 -1
- package/dist/api/moderation/getRepo.d.ts.map +1 -1
- package/dist/api/moderation/getRepo.js +3 -2
- package/dist/api/moderation/getRepo.js.map +1 -1
- package/dist/api/proxied.d.ts.map +1 -1
- package/dist/api/proxied.js +10 -0
- package/dist/api/proxied.js.map +1 -1
- package/dist/context.d.ts +3 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +13 -0
- package/dist/context.js.map +1 -1
- package/dist/mod-service/index.d.ts.map +1 -1
- package/dist/mod-service/index.js +8 -1
- package/dist/mod-service/index.js.map +1 -1
- package/dist/mod-service/views.d.ts +5 -2
- package/dist/mod-service/views.d.ts.map +1 -1
- package/dist/mod-service/views.js +17 -6
- package/dist/mod-service/views.js.map +1 -1
- package/dist/util.d.ts +8 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +41 -1
- package/dist/util.js.map +1 -1
- package/package.json +4 -3
- package/src/api/moderation/getRecord.ts +3 -2
- package/src/api/moderation/getRepo.ts +3 -2
- package/src/api/proxied.ts +14 -0
- package/src/context.ts +20 -1
- package/src/mod-service/index.ts +8 -1
- package/src/mod-service/views.ts +30 -5
- package/src/util.ts +50 -0
- package/tests/3p-labeler.test.ts +271 -0
- package/tests/get-lists.test.ts +109 -0
|
@@ -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
|
+
})
|