@atproto/bsky 0.0.123 → 0.0.124

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.
@@ -1,5 +1,9 @@
1
1
  import assert from 'node:assert'
2
- import { AtpAgent } from '@atproto/api'
2
+ import {
3
+ AppBskyLabelerDefs,
4
+ AtpAgent,
5
+ ComAtprotoModerationDefs,
6
+ } from '@atproto/api'
3
7
  import { RecordRef, SeedClient, TestNetwork, basicSeed } from '@atproto/dev-env'
4
8
  import { ids } from '../../src/lexicon/lexicons'
5
9
  import { isView as isRecordEmbedView } from '../../src/lexicon/types/app/bsky/embed/record'
@@ -14,6 +18,7 @@ describe('labeler service views', () => {
14
18
  // account dids, for convenience
15
19
  let alice: string
16
20
  let bob: string
21
+ let carol: string
17
22
 
18
23
  let aliceService: RecordRef
19
24
 
@@ -27,6 +32,7 @@ describe('labeler service views', () => {
27
32
  await basicSeed(sc)
28
33
  alice = sc.dids.alice
29
34
  bob = sc.dids.bob
35
+ carol = sc.dids.carol
30
36
 
31
37
  const aliceRes = await pdsAgent.api.com.atproto.repo.createRecord(
32
38
  {
@@ -190,4 +196,47 @@ describe('labeler service views', () => {
190
196
  // Cleanup
191
197
  await network.bsky.ctx.dataplane.untakedownActor({ did: alice })
192
198
  })
199
+
200
+ it(`returns additional labeler data`, async () => {
201
+ await pdsAgent.api.com.atproto.repo.createRecord(
202
+ {
203
+ repo: carol,
204
+ collection: ids.AppBskyLabelerService,
205
+ rkey: 'self',
206
+ record: {
207
+ policies: {
208
+ labelValues: ['spam', '!hide', 'scam', 'impersonation'],
209
+ },
210
+ createdAt: new Date().toISOString(),
211
+ reasonTypes: [ComAtprotoModerationDefs.REASONOTHER],
212
+ subjectTypes: ['record'],
213
+ subjectCollections: ['app.bsky.feed.post'],
214
+ },
215
+ },
216
+ { headers: sc.getHeaders(carol), encoding: 'application/json' },
217
+ )
218
+ await network.processAll()
219
+
220
+ const view = await agent.api.app.bsky.labeler.getServices(
221
+ { dids: [carol], detailed: true },
222
+ {
223
+ headers: await network.serviceHeaders(
224
+ bob,
225
+ ids.AppBskyLabelerGetServices,
226
+ ),
227
+ },
228
+ )
229
+
230
+ const labelerView = view.data.views[0]
231
+ expect(AppBskyLabelerDefs.isLabelerViewDetailed(labelerView)).toBe(true)
232
+ // for TS only
233
+ if (!AppBskyLabelerDefs.isLabelerViewDetailed(labelerView)) return
234
+ expect(labelerView).toBeTruthy()
235
+ expect(labelerView.reasonTypes).toEqual([
236
+ ComAtprotoModerationDefs.REASONOTHER,
237
+ ])
238
+ expect(labelerView.subjectTypes).toEqual(['record'])
239
+ expect(labelerView.subjectCollections).toEqual(['app.bsky.feed.post'])
240
+ expect(forSnapshot(view.data)).toMatchSnapshot()
241
+ })
193
242
  })