@atproto/bsky 0.0.11 → 0.0.12

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.
Files changed (155) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/api/com/atproto/admin/util.d.ts +5 -0
  3. package/dist/context.d.ts +6 -1
  4. package/dist/db/index.js +51 -2
  5. package/dist/db/index.js.map +3 -3
  6. package/dist/db/migrations/20230929T192920807Z-record-cursor-indexes.d.ts +3 -0
  7. package/dist/db/migrations/index.d.ts +1 -0
  8. package/dist/did-cache.d.ts +2 -2
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.js +1381 -530
  11. package/dist/index.js.map +3 -3
  12. package/dist/lexicon/index.d.ts +8 -0
  13. package/dist/lexicon/lexicons.d.ts +231 -3
  14. package/dist/lexicon/types/app/bsky/actor/defs.d.ts +1 -0
  15. package/dist/lexicon/types/com/atproto/admin/defs.d.ts +28 -0
  16. package/dist/lexicon/types/com/atproto/admin/getAccountInfo.d.ts +29 -0
  17. package/dist/lexicon/types/com/atproto/admin/getSubjectStatus.d.ts +39 -0
  18. package/dist/lexicon/types/com/atproto/admin/searchRepos.d.ts +0 -1
  19. package/dist/lexicon/types/com/atproto/admin/updateSubjectStatus.d.ts +46 -0
  20. package/dist/lexicon/types/com/atproto/server/createAccount.d.ts +2 -0
  21. package/dist/lexicon/types/com/atproto/server/createSession.d.ts +1 -0
  22. package/dist/lexicon/types/com/atproto/server/refreshSession.d.ts +1 -0
  23. package/dist/lexicon/types/com/atproto/server/reserveSigningKey.d.ts +30 -0
  24. package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts +1 -0
  25. package/dist/services/actor/types.d.ts +1 -0
  26. package/dist/services/graph/index.d.ts +2 -0
  27. package/dist/services/moderation/index.d.ts +13 -3
  28. package/package.json +13 -14
  29. package/src/api/app/bsky/feed/getAuthorFeed.ts +2 -2
  30. package/src/api/app/bsky/feed/getPostThread.ts +2 -2
  31. package/src/api/app/bsky/notification/listNotifications.ts +33 -22
  32. package/src/api/com/atproto/admin/getModerationAction.ts +28 -2
  33. package/src/api/com/atproto/admin/getModerationReport.ts +27 -2
  34. package/src/api/com/atproto/admin/getRecord.ts +14 -2
  35. package/src/api/com/atproto/admin/getRepo.ts +13 -2
  36. package/src/api/com/atproto/admin/reverseModerationAction.ts +31 -5
  37. package/src/api/com/atproto/admin/searchRepos.ts +2 -5
  38. package/src/api/com/atproto/admin/takeModerationAction.ts +41 -7
  39. package/src/api/com/atproto/admin/util.ts +50 -0
  40. package/src/api/well-known.ts +8 -0
  41. package/src/auth.ts +12 -5
  42. package/src/auto-moderator/index.ts +1 -0
  43. package/src/context.ts +25 -1
  44. package/src/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +40 -0
  45. package/src/db/migrations/index.ts +1 -0
  46. package/src/did-cache.ts +29 -14
  47. package/src/feed-gen/with-friends.ts +2 -2
  48. package/src/index.ts +4 -1
  49. package/src/indexer/subscription.ts +1 -21
  50. package/src/lexicon/index.ts +48 -0
  51. package/src/lexicon/lexicons.ts +246 -4
  52. package/src/lexicon/types/app/bsky/actor/defs.ts +1 -0
  53. package/src/lexicon/types/com/atproto/admin/defs.ts +61 -0
  54. package/src/lexicon/types/com/atproto/admin/getAccountInfo.ts +41 -0
  55. package/src/lexicon/types/com/atproto/admin/getSubjectStatus.ts +54 -0
  56. package/src/lexicon/types/com/atproto/admin/searchRepos.ts +0 -1
  57. package/src/lexicon/types/com/atproto/admin/updateSubjectStatus.ts +61 -0
  58. package/src/lexicon/types/com/atproto/server/createAccount.ts +2 -0
  59. package/src/lexicon/types/com/atproto/server/createSession.ts +1 -0
  60. package/src/lexicon/types/com/atproto/server/refreshSession.ts +1 -0
  61. package/src/lexicon/types/com/atproto/server/reserveSigningKey.ts +44 -0
  62. package/src/lexicon/types/com/atproto/sync/listRepos.ts +1 -0
  63. package/src/logger.ts +8 -0
  64. package/src/services/actor/index.ts +7 -1
  65. package/src/services/actor/types.ts +1 -0
  66. package/src/services/actor/views.ts +26 -8
  67. package/src/services/graph/index.ts +26 -7
  68. package/src/services/indexing/index.ts +15 -17
  69. package/src/services/moderation/index.ts +94 -14
  70. package/src/services/moderation/views.ts +1 -0
  71. package/tests/__snapshots__/feed-generation.test.ts.snap +12 -12
  72. package/tests/__snapshots__/indexing.test.ts.snap +4 -4
  73. package/tests/admin/__snapshots__/get-moderation-action.test.ts.snap +172 -0
  74. package/tests/admin/__snapshots__/get-moderation-actions.test.ts.snap +178 -0
  75. package/tests/admin/__snapshots__/get-moderation-report.test.ts.snap +177 -0
  76. package/tests/admin/__snapshots__/get-moderation-reports.test.ts.snap +307 -0
  77. package/tests/admin/__snapshots__/get-record.test.ts.snap +275 -0
  78. package/tests/admin/__snapshots__/get-repo.test.ts.snap +103 -0
  79. package/tests/admin/get-moderation-action.test.ts +100 -0
  80. package/tests/admin/get-moderation-actions.test.ts +164 -0
  81. package/tests/admin/get-moderation-report.test.ts +100 -0
  82. package/tests/admin/get-moderation-reports.test.ts +332 -0
  83. package/tests/admin/get-record.test.ts +115 -0
  84. package/tests/admin/get-repo.test.ts +101 -0
  85. package/tests/{moderation.test.ts → admin/moderation.test.ts} +107 -9
  86. package/tests/admin/repo-search.test.ts +124 -0
  87. package/tests/algos/hot-classic.test.ts +3 -5
  88. package/tests/algos/whats-hot.test.ts +3 -5
  89. package/tests/algos/with-friends.test.ts +2 -4
  90. package/tests/auth.test.ts +64 -0
  91. package/tests/auto-moderator/fuzzy-matcher.test.ts +2 -3
  92. package/tests/auto-moderator/labeler.test.ts +5 -7
  93. package/tests/auto-moderator/takedowns.test.ts +11 -12
  94. package/tests/blob-resolver.test.ts +1 -3
  95. package/tests/did-cache.test.ts +2 -5
  96. package/tests/feed-generation.test.ts +8 -6
  97. package/tests/handle-invalidation.test.ts +2 -3
  98. package/tests/image/server.test.ts +1 -4
  99. package/tests/image/sharp.test.ts +1 -1
  100. package/tests/indexing.test.ts +4 -4
  101. package/tests/notification-server.test.ts +2 -3
  102. package/tests/pipeline/backpressure.test.ts +2 -3
  103. package/tests/pipeline/reingest.test.ts +7 -4
  104. package/tests/pipeline/repartition.test.ts +2 -3
  105. package/tests/reprocessing.test.ts +2 -6
  106. package/tests/seeds/basic.ts +4 -4
  107. package/tests/seeds/follows.ts +1 -1
  108. package/tests/seeds/likes.ts +1 -1
  109. package/tests/seeds/reposts.ts +1 -1
  110. package/tests/seeds/users-bulk.ts +1 -1
  111. package/tests/seeds/users.ts +1 -1
  112. package/tests/server.test.ts +1 -3
  113. package/tests/subscription/repo.test.ts +2 -4
  114. package/tests/views/__snapshots__/author-feed.test.ts.snap +24 -24
  115. package/tests/views/__snapshots__/block-lists.test.ts.snap +42 -7
  116. package/tests/views/__snapshots__/blocks.test.ts.snap +2 -2
  117. package/tests/views/__snapshots__/list-feed.test.ts.snap +6 -6
  118. package/tests/views/__snapshots__/mute-lists.test.ts.snap +15 -4
  119. package/tests/views/__snapshots__/mutes.test.ts.snap +2 -2
  120. package/tests/views/__snapshots__/notifications.test.ts.snap +2 -2
  121. package/tests/views/__snapshots__/posts.test.ts.snap +8 -8
  122. package/tests/views/__snapshots__/thread.test.ts.snap +10 -10
  123. package/tests/views/__snapshots__/timeline.test.ts.snap +58 -58
  124. package/tests/views/actor-likes.test.ts +2 -3
  125. package/tests/views/actor-search.test.ts +5 -5
  126. package/tests/views/admin/repo-search.test.ts +2 -4
  127. package/tests/views/author-feed.test.ts +2 -4
  128. package/tests/views/block-lists.test.ts +34 -7
  129. package/tests/views/blocks.test.ts +6 -3
  130. package/tests/views/follows.test.ts +2 -4
  131. package/tests/views/likes.test.ts +2 -5
  132. package/tests/views/list-feed.test.ts +2 -4
  133. package/tests/views/mute-lists.test.ts +23 -5
  134. package/tests/views/mutes.test.ts +2 -5
  135. package/tests/views/notifications.test.ts +2 -4
  136. package/tests/views/posts.test.ts +2 -5
  137. package/tests/views/profile.test.ts +4 -5
  138. package/tests/views/reposts.test.ts +2 -4
  139. package/tests/views/suggested-follows.test.ts +2 -3
  140. package/tests/views/suggestions.test.ts +2 -4
  141. package/tests/views/thread.test.ts +2 -4
  142. package/tests/views/threadgating.test.ts +2 -3
  143. package/tests/views/timeline.test.ts +2 -4
  144. package/dist/env.d.ts +0 -1
  145. package/example.dev.env +0 -5
  146. package/src/env.ts +0 -9
  147. package/tests/seeds/client.ts +0 -466
  148. /package/tests/{__snapshots__ → admin/__snapshots__}/moderation.test.ts.snap +0 -0
  149. /package/tests/{image/fixtures → sample-img}/at.png +0 -0
  150. /package/tests/{image/fixtures → sample-img}/hd-key.jpg +0 -0
  151. /package/tests/{image/fixtures → sample-img}/key-alt.jpg +0 -0
  152. /package/tests/{image/fixtures → sample-img}/key-landscape-large.jpg +0 -0
  153. /package/tests/{image/fixtures → sample-img}/key-landscape-small.jpg +0 -0
  154. /package/tests/{image/fixtures → sample-img}/key-portrait-large.jpg +0 -0
  155. /package/tests/{image/fixtures → sample-img}/key-portrait-small.jpg +0 -0
@@ -1,9 +1,7 @@
1
1
  import AtpAgent from '@atproto/api'
2
- import { TestNetwork } from '@atproto/dev-env'
2
+ import { TestNetwork, SeedClient, RecordRef } from '@atproto/dev-env'
3
3
  import { forSnapshot } from '../_util'
4
- import { SeedClient } from '../seeds/client'
5
4
  import basicSeed from '../seeds/basic'
6
- import { RecordRef } from '@atproto/bsky/tests/seeds/client'
7
5
  import { BlockedActorError } from '@atproto/api/src/client/types/app/bsky/feed/getAuthorFeed'
8
6
  import { BlockedByActorError } from '@atproto/api/src/client/types/app/bsky/feed/getAuthorFeed'
9
7
 
@@ -25,7 +23,7 @@ describe('pds views with blocking from block lists', () => {
25
23
  })
26
24
  agent = network.bsky.getClient()
27
25
  pdsAgent = network.pds.getClient()
28
- sc = new SeedClient(pdsAgent)
26
+ sc = network.getSeedClient()
29
27
  await basicSeed(sc)
30
28
  alice = sc.dids.alice
31
29
  bob = sc.dids.bob
@@ -52,7 +50,7 @@ describe('pds views with blocking from block lists', () => {
52
50
  it('creates a list with some items', async () => {
53
51
  const avatar = await sc.uploadFile(
54
52
  alice,
55
- 'tests/image/fixtures/key-portrait-small.jpg',
53
+ 'tests/sample-img/key-portrait-small.jpg',
56
54
  'image/jpeg',
57
55
  )
58
56
  // alice creates block list with bob & carol that dan uses
@@ -60,7 +58,7 @@ describe('pds views with blocking from block lists', () => {
60
58
  { repo: alice },
61
59
  {
62
60
  name: 'alice blocks',
63
- purpose: 'app.bsky.graph.defs#blocklist',
61
+ purpose: 'app.bsky.graph.defs#modlist',
64
62
  description: 'big list of blocks',
65
63
  avatar: avatar.image,
66
64
  createdAt: new Date().toISOString(),
@@ -86,6 +84,15 @@ describe('pds views with blocking from block lists', () => {
86
84
  },
87
85
  sc.getHeaders(alice),
88
86
  )
87
+ await pdsAgent.api.app.bsky.graph.listitem.create(
88
+ { repo: alice },
89
+ {
90
+ subject: sc.dids.dan,
91
+ list: list.uri,
92
+ createdAt: new Date().toISOString(),
93
+ },
94
+ sc.getHeaders(alice),
95
+ )
89
96
  await network.processAll()
90
97
  })
91
98
 
@@ -194,6 +201,7 @@ describe('pds views with blocking from block lists', () => {
194
201
  { headers: await network.serviceHeaders(carol) },
195
202
  )
196
203
  expect(resCarol.data.viewer?.blocking).toBeUndefined()
204
+ expect(resCarol.data.viewer?.blockingByList).toBeUndefined()
197
205
  expect(resCarol.data.viewer?.blockedBy).toBe(true)
198
206
 
199
207
  const resDan = await agent.api.app.bsky.actor.getProfile(
@@ -201,6 +209,9 @@ describe('pds views with blocking from block lists', () => {
201
209
  { headers: await network.serviceHeaders(dan) },
202
210
  )
203
211
  expect(resDan.data.viewer?.blocking).toBeDefined()
212
+ expect(resDan.data.viewer?.blockingByList?.uri).toEqual(
213
+ resDan.data.viewer?.blocking,
214
+ )
204
215
  expect(resDan.data.viewer?.blockedBy).toBe(false)
205
216
  })
206
217
 
@@ -210,8 +221,10 @@ describe('pds views with blocking from block lists', () => {
210
221
  { headers: await network.serviceHeaders(carol) },
211
222
  )
212
223
  expect(resCarol.data.profiles[0].viewer?.blocking).toBeUndefined()
224
+ expect(resCarol.data.profiles[0].viewer?.blockingByList).toBeUndefined()
213
225
  expect(resCarol.data.profiles[0].viewer?.blockedBy).toBe(false)
214
226
  expect(resCarol.data.profiles[1].viewer?.blocking).toBeUndefined()
227
+ expect(resCarol.data.profiles[1].viewer?.blockingByList).toBeUndefined()
215
228
  expect(resCarol.data.profiles[1].viewer?.blockedBy).toBe(true)
216
229
 
217
230
  const resDan = await agent.api.app.bsky.actor.getProfiles(
@@ -219,11 +232,25 @@ describe('pds views with blocking from block lists', () => {
219
232
  { headers: await network.serviceHeaders(dan) },
220
233
  )
221
234
  expect(resDan.data.profiles[0].viewer?.blocking).toBeUndefined()
235
+ expect(resDan.data.profiles[0].viewer?.blockingByList).toBeUndefined()
222
236
  expect(resDan.data.profiles[0].viewer?.blockedBy).toBe(false)
223
237
  expect(resDan.data.profiles[1].viewer?.blocking).toBeDefined()
238
+ expect(resDan.data.profiles[1].viewer?.blockingByList?.uri).toEqual(
239
+ resDan.data.profiles[1].viewer?.blocking,
240
+ )
224
241
  expect(resDan.data.profiles[1].viewer?.blockedBy).toBe(false)
225
242
  })
226
243
 
244
+ it('ignores self-blocks', async () => {
245
+ const res = await agent.api.app.bsky.actor.getProfile(
246
+ { actor: dan }, // dan subscribes to list that contains himself
247
+ { headers: await network.serviceHeaders(dan) },
248
+ )
249
+ expect(res.data.viewer?.blocking).toBeUndefined()
250
+ expect(res.data.viewer?.blockingByList).toBeUndefined()
251
+ expect(res.data.viewer?.blockedBy).toBe(false)
252
+ })
253
+
227
254
  it('does not return notifs for blocked accounts', async () => {
228
255
  const resCarol = await agent.api.app.bsky.notification.listNotifications(
229
256
  {
@@ -337,7 +364,7 @@ describe('pds views with blocking from block lists', () => {
337
364
  { repo: alice },
338
365
  {
339
366
  name: 'new list',
340
- purpose: 'app.bsky.graph.defs#blocklist',
367
+ purpose: 'app.bsky.graph.defs#modlist',
341
368
  description: 'blah blah',
342
369
  createdAt: new Date().toISOString(),
343
370
  },
@@ -1,4 +1,5 @@
1
1
  import assert from 'assert'
2
+ import { TestNetwork, RecordRef, SeedClient } from '@atproto/dev-env'
2
3
  import AtpAgent, { AtUri } from '@atproto/api'
3
4
  import { BlockedActorError } from '@atproto/api/src/client/types/app/bsky/feed/getAuthorFeed'
4
5
  import { BlockedByActorError } from '@atproto/api/src/client/types/app/bsky/feed/getAuthorFeed'
@@ -7,9 +8,7 @@ import {
7
8
  isViewRecord as isEmbedViewRecord,
8
9
  isViewBlocked as isEmbedViewBlocked,
9
10
  } from '@atproto/api/src/client/types/app/bsky/embed/record'
10
- import { TestNetwork } from '@atproto/dev-env'
11
11
  import { forSnapshot } from '../_util'
12
- import { RecordRef, SeedClient } from '../seeds/client'
13
12
  import basicSeed from '../seeds/basic'
14
13
 
15
14
  describe('pds views with blocking', () => {
@@ -32,7 +31,7 @@ describe('pds views with blocking', () => {
32
31
  })
33
32
  agent = network.bsky.getClient()
34
33
  pdsAgent = network.pds.getClient()
35
- sc = new SeedClient(pdsAgent)
34
+ sc = network.getSeedClient()
36
35
  await basicSeed(sc)
37
36
  alice = sc.dids.alice
38
37
  carol = sc.dids.carol
@@ -226,8 +225,10 @@ describe('pds views with blocking', () => {
226
225
  { headers: await network.serviceHeaders(carol) },
227
226
  )
228
227
  expect(resCarol.data.profiles[0].viewer?.blocking).toBeUndefined()
228
+ expect(resCarol.data.profiles[0].viewer?.blockingByList).toBeUndefined()
229
229
  expect(resCarol.data.profiles[0].viewer?.blockedBy).toBe(false)
230
230
  expect(resCarol.data.profiles[1].viewer?.blocking).toBeUndefined()
231
+ expect(resCarol.data.profiles[1].viewer?.blockingByList).toBeUndefined()
231
232
  expect(resCarol.data.profiles[1].viewer?.blockedBy).toBe(true)
232
233
 
233
234
  const resDan = await agent.api.app.bsky.actor.getProfiles(
@@ -235,8 +236,10 @@ describe('pds views with blocking', () => {
235
236
  { headers: await network.serviceHeaders(dan) },
236
237
  )
237
238
  expect(resDan.data.profiles[0].viewer?.blocking).toBeUndefined()
239
+ expect(resDan.data.profiles[0].viewer?.blockingByList).toBeUndefined()
238
240
  expect(resDan.data.profiles[0].viewer?.blockedBy).toBe(false)
239
241
  expect(resDan.data.profiles[1].viewer?.blocking).toBeDefined()
242
+ expect(resDan.data.profiles[1].viewer?.blockingByList).toBeUndefined()
240
243
  expect(resDan.data.profiles[1].viewer?.blockedBy).toBe(false)
241
244
  })
242
245
 
@@ -1,7 +1,6 @@
1
1
  import AtpAgent from '@atproto/api'
2
- import { TestNetwork } from '@atproto/dev-env'
2
+ import { TestNetwork, SeedClient } from '@atproto/dev-env'
3
3
  import { forSnapshot, paginateAll, stripViewer } from '../_util'
4
- import { SeedClient } from '../seeds/client'
5
4
  import followsSeed from '../seeds/follows'
6
5
  import { TAKEDOWN } from '@atproto/api/src/client/types/com/atproto/admin/defs'
7
6
 
@@ -18,8 +17,7 @@ describe('pds follow views', () => {
18
17
  dbPostgresSchema: 'bsky_views_follows',
19
18
  })
20
19
  agent = network.bsky.getClient()
21
- const pdsAgent = network.pds.getClient()
22
- sc = new SeedClient(pdsAgent)
20
+ sc = network.getSeedClient()
23
21
  await followsSeed(sc)
24
22
  await network.processAll()
25
23
  await network.bsky.processAll()
@@ -1,13 +1,11 @@
1
1
  import AtpAgent from '@atproto/api'
2
- import { TestNetwork } from '@atproto/dev-env'
3
- import { SeedClient } from '../seeds/client'
2
+ import { TestNetwork, SeedClient } from '@atproto/dev-env'
4
3
  import likesSeed from '../seeds/likes'
5
4
  import { constantDate, forSnapshot, paginateAll, stripViewer } from '../_util'
6
5
 
7
6
  describe('pds like views', () => {
8
7
  let network: TestNetwork
9
8
  let agent: AtpAgent
10
- let pdsAgent: AtpAgent
11
9
  let sc: SeedClient
12
10
 
13
11
  // account dids, for convenience
@@ -19,8 +17,7 @@ describe('pds like views', () => {
19
17
  dbPostgresSchema: 'bsky_views_likes',
20
18
  })
21
19
  agent = network.bsky.getClient()
22
- pdsAgent = network.pds.getClient()
23
- sc = new SeedClient(pdsAgent)
20
+ sc = network.getSeedClient()
24
21
  await likesSeed(sc)
25
22
  await network.processAll()
26
23
  alice = sc.dids.alice
@@ -1,7 +1,6 @@
1
1
  import AtpAgent from '@atproto/api'
2
- import { TestNetwork } from '@atproto/dev-env'
2
+ import { TestNetwork, SeedClient, RecordRef } from '@atproto/dev-env'
3
3
  import { forSnapshot, paginateAll, stripViewerFromPost } from '../_util'
4
- import { RecordRef, SeedClient } from '../seeds/client'
5
4
  import basicSeed from '../seeds/basic'
6
5
  import { TAKEDOWN } from '@atproto/api/src/client/types/com/atproto/admin/defs'
7
6
 
@@ -22,8 +21,7 @@ describe('list feed views', () => {
22
21
  dbPostgresSchema: 'bsky_views_list_feed',
23
22
  })
24
23
  agent = network.bsky.getClient()
25
- const pdsAgent = network.pds.getClient()
26
- sc = new SeedClient(pdsAgent)
24
+ sc = network.getSeedClient()
27
25
  await basicSeed(sc)
28
26
  alice = sc.dids.alice
29
27
  bob = sc.dids.bob
@@ -1,7 +1,6 @@
1
1
  import AtpAgent, { AtUri } from '@atproto/api'
2
- import { TestNetwork } from '@atproto/dev-env'
2
+ import { TestNetwork, SeedClient, RecordRef } from '@atproto/dev-env'
3
3
  import { forSnapshot } from '../_util'
4
- import { RecordRef, SeedClient } from '../seeds/client'
5
4
  import basicSeed from '../seeds/basic'
6
5
 
7
6
  describe('bsky views with mutes from mute lists', () => {
@@ -21,7 +20,7 @@ describe('bsky views with mutes from mute lists', () => {
21
20
  })
22
21
  agent = network.bsky.getClient()
23
22
  pdsAgent = network.pds.getClient()
24
- sc = new SeedClient(pdsAgent)
23
+ sc = network.getSeedClient()
25
24
  await basicSeed(sc)
26
25
  alice = sc.dids.alice
27
26
  bob = sc.dids.bob
@@ -43,7 +42,7 @@ describe('bsky views with mutes from mute lists', () => {
43
42
  it('creates a list with some items', async () => {
44
43
  const avatar = await sc.uploadFile(
45
44
  alice,
46
- 'tests/image/fixtures/key-portrait-small.jpg',
45
+ 'tests/sample-img/key-portrait-small.jpg',
47
46
  'image/jpeg',
48
47
  )
49
48
  // alice creates mute list with bob & carol that dan uses
@@ -80,6 +79,16 @@ describe('bsky views with mutes from mute lists', () => {
80
79
  },
81
80
  sc.getHeaders(alice),
82
81
  )
82
+ await pdsAgent.api.app.bsky.graph.listitem.create(
83
+ { repo: alice },
84
+ {
85
+ subject: sc.dids.dan,
86
+ list: list.uri,
87
+ reason: 'idk',
88
+ createdAt: new Date().toISOString(),
89
+ },
90
+ sc.getHeaders(alice),
91
+ )
83
92
  await network.processAll()
84
93
  })
85
94
 
@@ -161,6 +170,15 @@ describe('bsky views with mutes from mute lists', () => {
161
170
  expect(res.data.profiles[1].viewer?.mutedByList?.uri).toEqual(listUri)
162
171
  })
163
172
 
173
+ it('ignores self-mutes', async () => {
174
+ const res = await agent.api.app.bsky.actor.getProfile(
175
+ { actor: dan }, // dan subscribes to list that contains himself
176
+ { headers: await network.serviceHeaders(dan) },
177
+ )
178
+ expect(res.data.viewer?.muted).toBe(false)
179
+ expect(res.data.viewer?.mutedByList).toBeUndefined()
180
+ })
181
+
164
182
  it('does not return notifs for muted accounts', async () => {
165
183
  const res = await agent.api.app.bsky.notification.listNotifications(
166
184
  {
@@ -343,7 +361,7 @@ describe('bsky views with mutes from mute lists', () => {
343
361
  expect(got.data.list.name).toBe('updated alice mutes')
344
362
  expect(got.data.list.description).toBe('new descript')
345
363
  expect(got.data.list.avatar).toBeUndefined()
346
- expect(got.data.items.length).toBe(2)
364
+ expect(got.data.items.length).toBe(3)
347
365
  })
348
366
 
349
367
  it('embeds lists in posts', async () => {
@@ -1,14 +1,12 @@
1
1
  import AtpAgent from '@atproto/api'
2
- import { TestNetwork } from '@atproto/dev-env'
2
+ import { TestNetwork, SeedClient } from '@atproto/dev-env'
3
3
  import { forSnapshot, paginateAll } from '../_util'
4
- import { SeedClient } from '../seeds/client'
5
4
  import basicSeed from '../seeds/basic'
6
5
  import usersBulkSeed from '../seeds/users-bulk'
7
6
 
8
7
  describe('mute views', () => {
9
8
  let network: TestNetwork
10
9
  let agent: AtpAgent
11
- let pdsAgent: AtpAgent
12
10
  let sc: SeedClient
13
11
  let alice: string
14
12
  let bob: string
@@ -22,8 +20,7 @@ describe('mute views', () => {
22
20
  dbPostgresSchema: 'bsky_views_mutes',
23
21
  })
24
22
  agent = network.bsky.getClient()
25
- pdsAgent = network.pds.getClient()
26
- sc = new SeedClient(pdsAgent)
23
+ sc = network.getSeedClient()
27
24
  await basicSeed(sc)
28
25
  await usersBulkSeed(sc, 10)
29
26
  alice = sc.dids.alice
@@ -1,8 +1,7 @@
1
1
  import AtpAgent from '@atproto/api'
2
- import { TestNetwork } from '@atproto/dev-env'
2
+ import { TestNetwork, SeedClient } from '@atproto/dev-env'
3
3
  import { TAKEDOWN } from '@atproto/api/src/client/types/com/atproto/admin/defs'
4
4
  import { forSnapshot, paginateAll } from '../_util'
5
- import { SeedClient } from '../seeds/client'
6
5
  import basicSeed from '../seeds/basic'
7
6
  import { Notification } from '../../src/lexicon/types/app/bsky/notification/listNotifications'
8
7
 
@@ -19,8 +18,7 @@ describe('notification views', () => {
19
18
  dbPostgresSchema: 'bsky_views_notifications',
20
19
  })
21
20
  agent = network.bsky.getClient()
22
- const pdsAgent = network.pds.getClient()
23
- sc = new SeedClient(pdsAgent)
21
+ sc = network.getSeedClient()
24
22
  await basicSeed(sc)
25
23
  await network.processAll()
26
24
  await network.bsky.processAll()
@@ -1,7 +1,6 @@
1
1
  import AtpAgent, { AppBskyFeedPost } from '@atproto/api'
2
- import { TestNetwork } from '@atproto/dev-env'
2
+ import { TestNetwork, SeedClient } from '@atproto/dev-env'
3
3
  import { forSnapshot, stripViewerFromPost } from '../_util'
4
- import { SeedClient } from '../seeds/client'
5
4
  import basicSeed from '../seeds/basic'
6
5
 
7
6
  describe('pds posts views', () => {
@@ -16,10 +15,9 @@ describe('pds posts views', () => {
16
15
  })
17
16
  agent = network.bsky.getClient()
18
17
  pdsAgent = network.pds.getClient()
19
- sc = new SeedClient(pdsAgent)
18
+ sc = network.getSeedClient()
20
19
  await basicSeed(sc)
21
20
  await network.processAll()
22
- await network.bsky.processAll()
23
21
  })
24
22
 
25
23
  afterAll(async () => {
@@ -99,7 +97,6 @@ describe('pds posts views', () => {
99
97
  )
100
98
 
101
99
  await network.processAll()
102
- await network.bsky.processAll()
103
100
 
104
101
  const { data } = await agent.api.app.bsky.feed.getPosts({ uris: [uri] })
105
102
 
@@ -1,10 +1,9 @@
1
1
  import fs from 'fs/promises'
2
2
  import AtpAgent from '@atproto/api'
3
- import { TestNetwork } from '@atproto/dev-env'
3
+ import { TestNetwork, SeedClient } from '@atproto/dev-env'
4
4
  import { TAKEDOWN } from '@atproto/api/src/client/types/com/atproto/admin/defs'
5
5
  import { forSnapshot, stripViewer } from '../_util'
6
6
  import { ids } from '../../src/lexicon/lexicons'
7
- import { SeedClient } from '../seeds/client'
8
7
  import basicSeed from '../seeds/basic'
9
8
 
10
9
  describe('pds profile views', () => {
@@ -24,7 +23,7 @@ describe('pds profile views', () => {
24
23
  })
25
24
  agent = network.bsky.getClient()
26
25
  pdsAgent = network.pds.getClient()
27
- sc = new SeedClient(pdsAgent)
26
+ sc = network.getSeedClient()
28
27
  await basicSeed(sc)
29
28
  await network.processAll()
30
29
  await network.bsky.processAll()
@@ -109,10 +108,10 @@ describe('pds profile views', () => {
109
108
 
110
109
  it('presents avatars & banners', async () => {
111
110
  const avatarImg = await fs.readFile(
112
- 'tests/image/fixtures/key-portrait-small.jpg',
111
+ 'tests/sample-img/key-portrait-small.jpg',
113
112
  )
114
113
  const bannerImg = await fs.readFile(
115
- 'tests/image/fixtures/key-landscape-small.jpg',
114
+ 'tests/sample-img/key-landscape-small.jpg',
116
115
  )
117
116
  const avatarRes = await pdsAgent.api.com.atproto.repo.uploadBlob(
118
117
  avatarImg,
@@ -1,7 +1,6 @@
1
1
  import AtpAgent from '@atproto/api'
2
- import { TestNetwork } from '@atproto/dev-env'
2
+ import { TestNetwork, SeedClient } from '@atproto/dev-env'
3
3
  import { forSnapshot, paginateAll, stripViewer } from '../_util'
4
- import { SeedClient } from '../seeds/client'
5
4
  import repostsSeed from '../seeds/reposts'
6
5
 
7
6
  describe('pds repost views', () => {
@@ -18,8 +17,7 @@ describe('pds repost views', () => {
18
17
  dbPostgresSchema: 'bsky_views_reposts',
19
18
  })
20
19
  agent = network.bsky.getClient()
21
- const pdsAgent = network.pds.getClient()
22
- sc = new SeedClient(pdsAgent)
20
+ sc = network.getSeedClient()
23
21
  await repostsSeed(sc)
24
22
  await network.processAll()
25
23
  alice = sc.dids.alice
@@ -1,6 +1,5 @@
1
1
  import AtpAgent, { AtUri } from '@atproto/api'
2
- import { TestNetwork } from '@atproto/dev-env'
3
- import { SeedClient } from '../seeds/client'
2
+ import { TestNetwork, SeedClient } from '@atproto/dev-env'
4
3
  import likesSeed from '../seeds/likes'
5
4
 
6
5
  describe('suggested follows', () => {
@@ -15,7 +14,7 @@ describe('suggested follows', () => {
15
14
  })
16
15
  agent = network.bsky.getClient()
17
16
  pdsAgent = network.pds.getClient()
18
- sc = new SeedClient(pdsAgent)
17
+ sc = network.getSeedClient()
19
18
  await likesSeed(sc)
20
19
  await network.processAll()
21
20
  await network.bsky.processAll()
@@ -1,7 +1,6 @@
1
1
  import AtpAgent from '@atproto/api'
2
- import { TestNetwork } from '@atproto/dev-env'
2
+ import { TestNetwork, SeedClient } from '@atproto/dev-env'
3
3
  import { stripViewer } from '../_util'
4
- import { SeedClient } from '../seeds/client'
5
4
  import basicSeed from '../seeds/basic'
6
5
 
7
6
  describe('pds user search views', () => {
@@ -14,8 +13,7 @@ describe('pds user search views', () => {
14
13
  dbPostgresSchema: 'bsky_views_suggestions',
15
14
  })
16
15
  agent = network.bsky.getClient()
17
- const pdsAgent = network.pds.getClient()
18
- sc = new SeedClient(pdsAgent)
16
+ sc = network.getSeedClient()
19
17
  await basicSeed(sc)
20
18
  await network.processAll()
21
19
  await network.bsky.processAll()
@@ -1,8 +1,7 @@
1
1
  import AtpAgent, { AppBskyFeedGetPostThread } from '@atproto/api'
2
- import { TestNetwork } from '@atproto/dev-env'
2
+ import { TestNetwork, SeedClient } from '@atproto/dev-env'
3
3
  import { TAKEDOWN } from '@atproto/api/src/client/types/com/atproto/admin/defs'
4
4
  import { forSnapshot, stripViewerFromThread } from '../_util'
5
- import { SeedClient } from '../seeds/client'
6
5
  import basicSeed from '../seeds/basic'
7
6
  import assert from 'assert'
8
7
  import { isThreadViewPost } from '@atproto/api/src/client/types/app/bsky/feed/defs'
@@ -22,8 +21,7 @@ describe('pds thread views', () => {
22
21
  dbPostgresSchema: 'bsky_views_thread',
23
22
  })
24
23
  agent = network.bsky.getClient()
25
- const pdsAgent = network.pds.getClient()
26
- sc = new SeedClient(pdsAgent)
24
+ sc = network.getSeedClient()
27
25
  await basicSeed(sc)
28
26
  alice = sc.dids.alice
29
27
  bob = sc.dids.bob
@@ -1,11 +1,10 @@
1
1
  import assert from 'assert'
2
2
  import AtpAgent from '@atproto/api'
3
- import { TestNetwork } from '@atproto/dev-env'
3
+ import { TestNetwork, SeedClient } from '@atproto/dev-env'
4
4
  import {
5
5
  isNotFoundPost,
6
6
  isThreadViewPost,
7
7
  } from '../../src/lexicon/types/app/bsky/feed/defs'
8
- import { SeedClient } from '../seeds/client'
9
8
  import basicSeed from '../seeds/basic'
10
9
  import { forSnapshot } from '../_util'
11
10
 
@@ -21,7 +20,7 @@ describe('views with thread gating', () => {
21
20
  })
22
21
  agent = network.bsky.getClient()
23
22
  pdsAgent = network.pds.getClient()
24
- sc = new SeedClient(pdsAgent)
23
+ sc = network.getSeedClient()
25
24
  await basicSeed(sc)
26
25
  await network.processAll()
27
26
  })
@@ -1,9 +1,8 @@
1
1
  import assert from 'assert'
2
2
  import AtpAgent from '@atproto/api'
3
- import { TestNetwork } from '@atproto/dev-env'
3
+ import { TestNetwork, SeedClient } from '@atproto/dev-env'
4
4
  import { TAKEDOWN } from '@atproto/api/src/client/types/com/atproto/admin/defs'
5
5
  import { forSnapshot, getOriginator, paginateAll } from '../_util'
6
- import { SeedClient } from '../seeds/client'
7
6
  import basicSeed from '../seeds/basic'
8
7
  import { FeedAlgorithm } from '../../src/api/app/bsky/util/feed'
9
8
  import { FeedViewPost } from '../../src/lexicon/types/app/bsky/feed/defs'
@@ -24,8 +23,7 @@ describe('timeline views', () => {
24
23
  dbPostgresSchema: 'bsky_views_home_feed',
25
24
  })
26
25
  agent = network.bsky.getClient()
27
- const pdsAgent = network.pds.getClient()
28
- sc = new SeedClient(pdsAgent)
26
+ sc = network.getSeedClient()
29
27
  await basicSeed(sc)
30
28
  await network.processAll()
31
29
  alice = sc.dids.alice
package/dist/env.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/example.dev.env DELETED
@@ -1,5 +0,0 @@
1
- DB_POSTGRES_URL="postgres://bsky:yksb@localhost/bsky_dev"
2
- DEBUG_MODE=1
3
- LOG_ENABLED="true"
4
- LOG_LEVEL=debug
5
- LOG_DESTINATION=1
package/src/env.ts DELETED
@@ -1,9 +0,0 @@
1
- // NOTE: this file should be imported first, particularly before `@atproto/common` (for logging), to ensure that environment variables are respected in library code
2
- import dotenv from 'dotenv'
3
-
4
- const env = process.env.ENV
5
- if (env) {
6
- dotenv.config({ path: `./.${env}.env` })
7
- } else {
8
- dotenv.config()
9
- }