@atproto/bsky 0.0.14 → 0.0.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.
Files changed (195) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/api/app/bsky/feed/searchPosts.d.ts +3 -0
  3. package/dist/api/com/atproto/moderation/util.d.ts +4 -3
  4. package/dist/config.d.ts +2 -2
  5. package/dist/context.d.ts +16 -1
  6. package/dist/db/index.js +26 -1
  7. package/dist/db/index.js.map +3 -3
  8. package/dist/db/migrations/20231003T202833377Z-create-moderation-subject-status.d.ts +3 -0
  9. package/dist/db/migrations/index.d.ts +1 -0
  10. package/dist/db/pagination.d.ts +2 -1
  11. package/dist/db/{periodic-moderation-action-reversal.d.ts → periodic-moderation-event-reversal.d.ts} +3 -5
  12. package/dist/db/tables/moderation.d.ts +24 -34
  13. package/dist/feed-gen/types.d.ts +1 -1
  14. package/dist/index.d.ts +2 -1
  15. package/dist/index.js +3332 -2430
  16. package/dist/index.js.map +3 -3
  17. package/dist/lexicon/index.d.ts +18 -18
  18. package/dist/lexicon/lexicons.d.ts +460 -385
  19. package/dist/lexicon/types/app/bsky/feed/defs.d.ts +1 -7
  20. package/dist/lexicon/types/app/bsky/graph/defs.d.ts +1 -0
  21. package/dist/lexicon/types/com/atproto/admin/defs.d.ts +116 -48
  22. package/dist/lexicon/types/com/atproto/admin/{takeModerationAction.d.ts → emitModerationEvent.d.ts} +5 -6
  23. package/dist/lexicon/types/com/atproto/admin/{getModerationAction.d.ts → getModerationEvent.d.ts} +1 -1
  24. package/dist/lexicon/types/com/atproto/admin/{getModerationActions.d.ts → queryModerationEvents.d.ts} +5 -1
  25. package/dist/lexicon/types/com/atproto/admin/{getModerationReports.d.ts → queryModerationStatuses.d.ts} +12 -6
  26. package/dist/lexicon/types/com/atproto/admin/sendEmail.d.ts +1 -0
  27. package/dist/lexicon/types/com/atproto/{admin/getModerationReport.d.ts → temp/fetchLabels.d.ts} +7 -3
  28. package/dist/migrate-moderation-data.d.ts +1 -0
  29. package/dist/services/actor/views.d.ts +2 -5
  30. package/dist/services/feed/index.d.ts +1 -0
  31. package/dist/services/feed/util.d.ts +9 -1
  32. package/dist/services/feed/views.d.ts +6 -17
  33. package/dist/services/graph/index.d.ts +5 -29
  34. package/dist/services/graph/types.d.ts +1 -0
  35. package/dist/services/moderation/index.d.ts +135 -72
  36. package/dist/services/moderation/pagination.d.ts +36 -0
  37. package/dist/services/moderation/status.d.ts +13 -0
  38. package/dist/services/moderation/types.d.ts +35 -0
  39. package/dist/services/moderation/views.d.ts +18 -14
  40. package/dist/util/debug.d.ts +1 -1
  41. package/package.json +14 -15
  42. package/src/api/app/bsky/actor/getSuggestions.ts +45 -21
  43. package/src/api/app/bsky/feed/getActorFeeds.ts +2 -1
  44. package/src/api/app/bsky/feed/getActorLikes.ts +1 -3
  45. package/src/api/app/bsky/feed/getAuthorFeed.ts +1 -3
  46. package/src/api/app/bsky/feed/getFeed.ts +9 -9
  47. package/src/api/app/bsky/feed/getFeedGenerator.ts +3 -0
  48. package/src/api/app/bsky/feed/getFeedGenerators.ts +2 -1
  49. package/src/api/app/bsky/feed/getListFeed.ts +1 -3
  50. package/src/api/app/bsky/feed/getPostThread.ts +31 -58
  51. package/src/api/app/bsky/feed/getPosts.ts +21 -18
  52. package/src/api/app/bsky/feed/getSuggestedFeeds.ts +2 -1
  53. package/src/api/app/bsky/feed/getTimeline.ts +1 -3
  54. package/src/api/app/bsky/feed/searchPosts.ts +130 -0
  55. package/src/api/app/bsky/graph/getList.ts +6 -3
  56. package/src/api/app/bsky/graph/getListBlocks.ts +3 -2
  57. package/src/api/app/bsky/graph/getListMutes.ts +2 -1
  58. package/src/api/app/bsky/graph/getLists.ts +2 -1
  59. package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +3 -1
  60. package/src/api/blob-resolver.ts +6 -11
  61. package/src/api/com/atproto/admin/emitModerationEvent.ts +220 -0
  62. package/src/api/com/atproto/admin/{getModerationActions.ts → getModerationEvent.ts} +5 -11
  63. package/src/api/com/atproto/admin/getRecord.ts +1 -0
  64. package/src/api/com/atproto/admin/{getModerationReports.ts → queryModerationEvents.ts} +13 -16
  65. package/src/api/com/atproto/admin/queryModerationStatuses.ts +55 -0
  66. package/src/api/com/atproto/admin/util.ts +3 -1
  67. package/src/api/com/atproto/moderation/createReport.ts +9 -7
  68. package/src/api/com/atproto/moderation/util.ts +38 -20
  69. package/src/api/com/atproto/temp/fetchLabels.ts +30 -0
  70. package/src/api/index.ts +12 -14
  71. package/src/auth.ts +29 -21
  72. package/src/auto-moderator/index.ts +26 -19
  73. package/src/config.ts +6 -6
  74. package/src/context.ts +15 -9
  75. package/src/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts +123 -0
  76. package/src/db/migrations/index.ts +1 -0
  77. package/src/db/pagination.ts +26 -3
  78. package/src/db/{periodic-moderation-action-reversal.ts → periodic-moderation-event-reversal.ts} +51 -55
  79. package/src/db/tables/moderation.ts +35 -52
  80. package/src/feed-gen/best-of-follows.ts +6 -3
  81. package/src/feed-gen/bsky-team.ts +1 -1
  82. package/src/feed-gen/hot-classic.ts +1 -1
  83. package/src/feed-gen/mutuals.ts +6 -2
  84. package/src/feed-gen/types.ts +1 -1
  85. package/src/feed-gen/whats-hot.ts +1 -1
  86. package/src/feed-gen/with-friends.ts +7 -3
  87. package/src/index.ts +2 -1
  88. package/src/lexicon/index.ts +52 -67
  89. package/src/lexicon/lexicons.ts +674 -579
  90. package/src/lexicon/types/app/bsky/actor/defs.ts +2 -2
  91. package/src/lexicon/types/app/bsky/actor/searchActors.ts +2 -2
  92. package/src/lexicon/types/app/bsky/actor/searchActorsTypeahead.ts +2 -2
  93. package/src/lexicon/types/app/bsky/feed/defs.ts +1 -18
  94. package/src/lexicon/types/app/bsky/feed/searchPosts.ts +3 -3
  95. package/src/lexicon/types/app/bsky/graph/defs.ts +3 -2
  96. package/src/lexicon/types/app/bsky/unspecced/searchActorsSkeleton.ts +4 -4
  97. package/src/lexicon/types/app/bsky/unspecced/searchPostsSkeleton.ts +3 -3
  98. package/src/lexicon/types/com/atproto/admin/defs.ts +278 -84
  99. package/src/lexicon/types/com/atproto/admin/disableAccountInvites.ts +1 -1
  100. package/src/lexicon/types/com/atproto/admin/{takeModerationAction.ts → emitModerationEvent.ts} +13 -11
  101. package/src/lexicon/types/com/atproto/admin/enableAccountInvites.ts +1 -1
  102. package/src/lexicon/types/com/atproto/admin/{getModerationReport.ts → getModerationEvent.ts} +1 -1
  103. package/src/lexicon/types/com/atproto/admin/{getModerationReports.ts → queryModerationEvents.ts} +8 -15
  104. package/src/lexicon/types/com/atproto/admin/queryModerationStatuses.ts +70 -0
  105. package/src/lexicon/types/com/atproto/admin/sendEmail.ts +1 -0
  106. package/src/lexicon/types/com/atproto/label/defs.ts +9 -9
  107. package/src/lexicon/types/com/atproto/label/queryLabels.ts +2 -2
  108. package/src/lexicon/types/com/atproto/repo/applyWrites.ts +1 -1
  109. package/src/lexicon/types/com/atproto/repo/createRecord.ts +2 -2
  110. package/src/lexicon/types/com/atproto/repo/deleteRecord.ts +2 -2
  111. package/src/lexicon/types/com/atproto/repo/listRecords.ts +1 -1
  112. package/src/lexicon/types/com/atproto/repo/putRecord.ts +3 -3
  113. package/src/lexicon/types/com/atproto/sync/listBlobs.ts +1 -1
  114. package/src/lexicon/types/com/atproto/sync/subscribeRepos.ts +4 -4
  115. package/src/lexicon/types/com/atproto/{admin/getModerationActions.ts → temp/fetchLabels.ts} +3 -5
  116. package/src/migrate-moderation-data.ts +414 -0
  117. package/src/services/actor/views.ts +5 -14
  118. package/src/services/feed/index.ts +26 -7
  119. package/src/services/feed/util.ts +47 -19
  120. package/src/services/feed/views.ts +68 -4
  121. package/src/services/graph/index.ts +21 -3
  122. package/src/services/graph/types.ts +1 -0
  123. package/src/services/indexing/plugins/block.ts +2 -3
  124. package/src/services/indexing/plugins/feed-generator.ts +2 -3
  125. package/src/services/indexing/plugins/follow.ts +2 -3
  126. package/src/services/indexing/plugins/like.ts +2 -3
  127. package/src/services/indexing/plugins/list-block.ts +2 -3
  128. package/src/services/indexing/plugins/list-item.ts +2 -3
  129. package/src/services/indexing/plugins/list.ts +2 -3
  130. package/src/services/indexing/plugins/post.ts +3 -4
  131. package/src/services/indexing/plugins/repost.ts +2 -3
  132. package/src/services/indexing/plugins/thread-gate.ts +2 -3
  133. package/src/services/label/index.ts +2 -3
  134. package/src/services/moderation/index.ts +380 -395
  135. package/src/services/moderation/pagination.ts +96 -0
  136. package/src/services/moderation/status.ts +244 -0
  137. package/src/services/moderation/types.ts +49 -0
  138. package/src/services/moderation/views.ts +278 -329
  139. package/src/util/debug.ts +2 -2
  140. package/tests/__snapshots__/feed-generation.test.ts.snap +322 -6
  141. package/tests/__snapshots__/indexing.test.ts.snap +0 -6
  142. package/tests/admin/__snapshots__/get-record.test.ts.snap +30 -132
  143. package/tests/admin/__snapshots__/get-repo.test.ts.snap +14 -60
  144. package/tests/admin/__snapshots__/moderation-events.test.ts.snap +146 -0
  145. package/tests/admin/__snapshots__/moderation-statuses.test.ts.snap +64 -0
  146. package/tests/admin/__snapshots__/moderation.test.ts.snap +0 -125
  147. package/tests/admin/get-record.test.ts +5 -9
  148. package/tests/admin/get-repo.test.ts +38 -9
  149. package/tests/admin/moderation-events.test.ts +221 -0
  150. package/tests/admin/moderation-statuses.test.ts +145 -0
  151. package/tests/admin/moderation.test.ts +512 -860
  152. package/tests/admin/repo-search.test.ts +2 -3
  153. package/tests/auto-moderator/fuzzy-matcher.test.ts +2 -1
  154. package/tests/auto-moderator/takedowns.test.ts +45 -18
  155. package/tests/feed-generation.test.ts +57 -9
  156. package/tests/views/__snapshots__/block-lists.test.ts.snap +3 -9
  157. package/tests/views/__snapshots__/blocks.test.ts.snap +0 -9
  158. package/tests/views/__snapshots__/mute-lists.test.ts.snap +5 -5
  159. package/tests/views/__snapshots__/mutes.test.ts.snap +0 -3
  160. package/tests/views/__snapshots__/thread.test.ts.snap +0 -30
  161. package/tests/views/actor-search.test.ts +2 -3
  162. package/tests/views/author-feed.test.ts +42 -36
  163. package/tests/views/follows.test.ts +40 -35
  164. package/tests/views/list-feed.test.ts +17 -9
  165. package/tests/views/notifications.test.ts +13 -9
  166. package/tests/views/profile.test.ts +20 -18
  167. package/tests/views/suggestions.test.ts +15 -7
  168. package/tests/views/thread.test.ts +54 -26
  169. package/tests/views/threadgating.test.ts +51 -19
  170. package/tests/views/timeline.test.ts +21 -13
  171. package/dist/api/com/atproto/admin/reverseModerationAction.d.ts +0 -3
  172. package/dist/api/com/atproto/admin/takeModerationAction.d.ts +0 -3
  173. package/dist/lexicon/types/com/atproto/admin/resolveModerationReports.d.ts +0 -36
  174. package/dist/lexicon/types/com/atproto/admin/reverseModerationAction.d.ts +0 -36
  175. package/src/api/com/atproto/admin/getModerationAction.ts +0 -44
  176. package/src/api/com/atproto/admin/getModerationReport.ts +0 -43
  177. package/src/api/com/atproto/admin/resolveModerationReports.ts +0 -24
  178. package/src/api/com/atproto/admin/reverseModerationAction.ts +0 -115
  179. package/src/api/com/atproto/admin/takeModerationAction.ts +0 -156
  180. package/src/lexicon/types/com/atproto/admin/getModerationAction.ts +0 -41
  181. package/src/lexicon/types/com/atproto/admin/resolveModerationReports.ts +0 -49
  182. package/src/lexicon/types/com/atproto/admin/reverseModerationAction.ts +0 -49
  183. package/tests/admin/__snapshots__/get-moderation-action.test.ts.snap +0 -172
  184. package/tests/admin/__snapshots__/get-moderation-actions.test.ts.snap +0 -178
  185. package/tests/admin/__snapshots__/get-moderation-report.test.ts.snap +0 -177
  186. package/tests/admin/__snapshots__/get-moderation-reports.test.ts.snap +0 -307
  187. package/tests/admin/get-moderation-action.test.ts +0 -100
  188. package/tests/admin/get-moderation-actions.test.ts +0 -164
  189. package/tests/admin/get-moderation-report.test.ts +0 -100
  190. package/tests/admin/get-moderation-reports.test.ts +0 -332
  191. /package/dist/api/com/atproto/admin/{getModerationAction.d.ts → emitModerationEvent.d.ts} +0 -0
  192. /package/dist/api/com/atproto/admin/{getModerationActions.d.ts → getModerationEvent.d.ts} +0 -0
  193. /package/dist/api/com/atproto/admin/{getModerationReport.d.ts → queryModerationEvents.d.ts} +0 -0
  194. /package/dist/api/com/atproto/admin/{getModerationReports.d.ts → queryModerationStatuses.d.ts} +0 -0
  195. /package/dist/api/com/atproto/{admin/resolveModerationReports.d.ts → temp/fetchLabels.d.ts} +0 -0
@@ -2,7 +2,6 @@ import AtpAgent from '@atproto/api'
2
2
  import { TestNetwork, SeedClient } from '@atproto/dev-env'
3
3
  import { forSnapshot, paginateAll, stripViewer } from '../_util'
4
4
  import followsSeed from '../seeds/follows'
5
- import { TAKEDOWN } from '@atproto/api/src/client/types/com/atproto/admin/defs'
6
5
 
7
6
  describe('pds follow views', () => {
8
7
  let agent: AtpAgent
@@ -121,22 +120,21 @@ describe('pds follow views', () => {
121
120
  })
122
121
 
123
122
  it('blocks followers by actor takedown', async () => {
124
- const { data: modAction } =
125
- await agent.api.com.atproto.admin.takeModerationAction(
126
- {
127
- action: TAKEDOWN,
128
- subject: {
129
- $type: 'com.atproto.admin.defs#repoRef',
130
- did: sc.dids.dan,
131
- },
132
- createdBy: 'did:example:admin',
133
- reason: 'Y',
134
- },
135
- {
136
- encoding: 'application/json',
137
- headers: network.pds.adminAuthHeaders(),
123
+ await agent.api.com.atproto.admin.emitModerationEvent(
124
+ {
125
+ event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
126
+ subject: {
127
+ $type: 'com.atproto.admin.defs#repoRef',
128
+ did: sc.dids.dan,
138
129
  },
139
- )
130
+ createdBy: 'did:example:admin',
131
+ reason: 'Y',
132
+ },
133
+ {
134
+ encoding: 'application/json',
135
+ headers: network.pds.adminAuthHeaders(),
136
+ },
137
+ )
140
138
 
141
139
  const aliceFollowers = await agent.api.app.bsky.graph.getFollowers(
142
140
  { actor: sc.dids.alice },
@@ -147,9 +145,13 @@ describe('pds follow views', () => {
147
145
  sc.dids.dan,
148
146
  )
149
147
 
150
- await agent.api.com.atproto.admin.reverseModerationAction(
148
+ await agent.api.com.atproto.admin.emitModerationEvent(
151
149
  {
152
- id: modAction.id,
150
+ event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' },
151
+ subject: {
152
+ $type: 'com.atproto.admin.defs#repoRef',
153
+ did: sc.dids.dan,
154
+ },
153
155
  createdBy: 'did:example:admin',
154
156
  reason: 'Y',
155
157
  },
@@ -250,22 +252,21 @@ describe('pds follow views', () => {
250
252
  })
251
253
 
252
254
  it('blocks follows by actor takedown', async () => {
253
- const { data: modAction } =
254
- await agent.api.com.atproto.admin.takeModerationAction(
255
- {
256
- action: TAKEDOWN,
257
- subject: {
258
- $type: 'com.atproto.admin.defs#repoRef',
259
- did: sc.dids.dan,
260
- },
261
- createdBy: 'did:example:admin',
262
- reason: 'Y',
263
- },
264
- {
265
- encoding: 'application/json',
266
- headers: network.pds.adminAuthHeaders(),
255
+ await agent.api.com.atproto.admin.emitModerationEvent(
256
+ {
257
+ event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
258
+ subject: {
259
+ $type: 'com.atproto.admin.defs#repoRef',
260
+ did: sc.dids.dan,
267
261
  },
268
- )
262
+ createdBy: 'did:example:admin',
263
+ reason: 'Y',
264
+ },
265
+ {
266
+ encoding: 'application/json',
267
+ headers: network.pds.adminAuthHeaders(),
268
+ },
269
+ )
269
270
 
270
271
  const aliceFollows = await agent.api.app.bsky.graph.getFollows(
271
272
  { actor: sc.dids.alice },
@@ -276,9 +277,13 @@ describe('pds follow views', () => {
276
277
  sc.dids.dan,
277
278
  )
278
279
 
279
- await agent.api.com.atproto.admin.reverseModerationAction(
280
+ await agent.api.com.atproto.admin.emitModerationEvent(
280
281
  {
281
- id: modAction.id,
282
+ event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' },
283
+ subject: {
284
+ $type: 'com.atproto.admin.defs#repoRef',
285
+ did: sc.dids.dan,
286
+ },
282
287
  createdBy: 'did:example:admin',
283
288
  reason: 'Y',
284
289
  },
@@ -2,7 +2,6 @@ import AtpAgent from '@atproto/api'
2
2
  import { TestNetwork, SeedClient, RecordRef } from '@atproto/dev-env'
3
3
  import { forSnapshot, paginateAll, stripViewerFromPost } from '../_util'
4
4
  import basicSeed from '../seeds/basic'
5
- import { TAKEDOWN } from '@atproto/api/src/client/types/com/atproto/admin/defs'
6
5
 
7
6
  describe('list feed views', () => {
8
7
  let network: TestNetwork
@@ -113,9 +112,9 @@ describe('list feed views', () => {
113
112
  })
114
113
 
115
114
  it('blocks posts by actor takedown', async () => {
116
- const actionRes = await agent.api.com.atproto.admin.takeModerationAction(
115
+ await agent.api.com.atproto.admin.emitModerationEvent(
117
116
  {
118
- action: TAKEDOWN,
117
+ event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
119
118
  subject: {
120
119
  $type: 'com.atproto.admin.defs#repoRef',
121
120
  did: bob,
@@ -136,9 +135,13 @@ describe('list feed views', () => {
136
135
  expect(hasBob).toBe(false)
137
136
 
138
137
  // Cleanup
139
- await agent.api.com.atproto.admin.reverseModerationAction(
138
+ await agent.api.com.atproto.admin.emitModerationEvent(
140
139
  {
141
- id: actionRes.data.id,
140
+ event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' },
141
+ subject: {
142
+ $type: 'com.atproto.admin.defs#repoRef',
143
+ did: bob,
144
+ },
142
145
  createdBy: 'did:example:admin',
143
146
  reason: 'Y',
144
147
  },
@@ -151,9 +154,9 @@ describe('list feed views', () => {
151
154
 
152
155
  it('blocks posts by record takedown.', async () => {
153
156
  const postRef = sc.replies[bob][0].ref // Post and reply parent
154
- const actionRes = await agent.api.com.atproto.admin.takeModerationAction(
157
+ await agent.api.com.atproto.admin.emitModerationEvent(
155
158
  {
156
- action: TAKEDOWN,
159
+ event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
157
160
  subject: {
158
161
  $type: 'com.atproto.repo.strongRef',
159
162
  uri: postRef.uriStr,
@@ -177,9 +180,14 @@ describe('list feed views', () => {
177
180
  expect(hasPost).toBe(false)
178
181
 
179
182
  // Cleanup
180
- await agent.api.com.atproto.admin.reverseModerationAction(
183
+ await agent.api.com.atproto.admin.emitModerationEvent(
181
184
  {
182
- id: actionRes.data.id,
185
+ event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' },
186
+ subject: {
187
+ $type: 'com.atproto.repo.strongRef',
188
+ uri: postRef.uriStr,
189
+ cid: postRef.cidStr,
190
+ },
183
191
  createdBy: 'did:example:admin',
184
192
  reason: 'Y',
185
193
  },
@@ -1,6 +1,5 @@
1
1
  import AtpAgent from '@atproto/api'
2
2
  import { TestNetwork, SeedClient } from '@atproto/dev-env'
3
- import { TAKEDOWN } from '@atproto/api/src/client/types/com/atproto/admin/defs'
4
3
  import { forSnapshot, paginateAll } from '../_util'
5
4
  import basicSeed from '../seeds/basic'
6
5
  import { Notification } from '../../src/lexicon/types/app/bsky/notification/listNotifications'
@@ -61,7 +60,7 @@ describe('notification views', () => {
61
60
  { headers: await network.serviceHeaders(sc.dids.bob) },
62
61
  )
63
62
 
64
- expect(notifCountBob.data.count).toBe(4)
63
+ expect(notifCountBob.data.count).toBeGreaterThanOrEqual(3)
65
64
  })
66
65
 
67
66
  it('generates notifications for all reply ancestors', async () => {
@@ -89,7 +88,7 @@ describe('notification views', () => {
89
88
  { headers: await network.serviceHeaders(sc.dids.bob) },
90
89
  )
91
90
 
92
- expect(notifCountBob.data.count).toBe(5)
91
+ expect(notifCountBob.data.count).toBeGreaterThanOrEqual(4)
93
92
  })
94
93
 
95
94
  it('does not give notifs for a deleted subject', async () => {
@@ -233,11 +232,11 @@ describe('notification views', () => {
233
232
  it('fetches notifications omitting mentions and replies for taken-down posts', async () => {
234
233
  const postRef1 = sc.replies[sc.dids.carol][0].ref // Reply
235
234
  const postRef2 = sc.posts[sc.dids.dan][1].ref // Mention
236
- const actionResults = await Promise.all(
235
+ await Promise.all(
237
236
  [postRef1, postRef2].map((postRef) =>
238
- agent.api.com.atproto.admin.takeModerationAction(
237
+ agent.api.com.atproto.admin.emitModerationEvent(
239
238
  {
240
- action: TAKEDOWN,
239
+ event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
241
240
  subject: {
242
241
  $type: 'com.atproto.repo.strongRef',
243
242
  uri: postRef.uriStr,
@@ -270,10 +269,15 @@ describe('notification views', () => {
270
269
 
271
270
  // Cleanup
272
271
  await Promise.all(
273
- actionResults.map((result) =>
274
- agent.api.com.atproto.admin.reverseModerationAction(
272
+ [postRef1, postRef2].map((postRef) =>
273
+ agent.api.com.atproto.admin.emitModerationEvent(
275
274
  {
276
- id: result.data.id,
275
+ event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' },
276
+ subject: {
277
+ $type: 'com.atproto.repo.strongRef',
278
+ uri: postRef.uriStr,
279
+ cid: postRef.cidStr,
280
+ },
277
281
  createdBy: 'did:example:admin',
278
282
  reason: 'Y',
279
283
  },
@@ -1,7 +1,6 @@
1
1
  import fs from 'fs/promises'
2
2
  import AtpAgent from '@atproto/api'
3
3
  import { TestNetwork, SeedClient } from '@atproto/dev-env'
4
- import { TAKEDOWN } from '@atproto/api/src/client/types/com/atproto/admin/defs'
5
4
  import { forSnapshot, stripViewer } from '../_util'
6
5
  import { ids } from '../../src/lexicon/lexicons'
7
6
  import basicSeed from '../seeds/basic'
@@ -186,22 +185,21 @@ describe('pds profile views', () => {
186
185
  })
187
186
 
188
187
  it('blocked by actor takedown', async () => {
189
- const { data: action } =
190
- await agent.api.com.atproto.admin.takeModerationAction(
191
- {
192
- action: TAKEDOWN,
193
- subject: {
194
- $type: 'com.atproto.admin.defs#repoRef',
195
- did: alice,
196
- },
197
- createdBy: 'did:example:admin',
198
- reason: 'Y',
199
- },
200
- {
201
- encoding: 'application/json',
202
- headers: network.pds.adminAuthHeaders(),
188
+ await agent.api.com.atproto.admin.emitModerationEvent(
189
+ {
190
+ event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
191
+ subject: {
192
+ $type: 'com.atproto.admin.defs#repoRef',
193
+ did: alice,
203
194
  },
204
- )
195
+ createdBy: 'did:example:admin',
196
+ reason: 'Y',
197
+ },
198
+ {
199
+ encoding: 'application/json',
200
+ headers: network.pds.adminAuthHeaders(),
201
+ },
202
+ )
205
203
  const promise = agent.api.app.bsky.actor.getProfile(
206
204
  { actor: alice },
207
205
  { headers: await network.serviceHeaders(bob) },
@@ -210,9 +208,13 @@ describe('pds profile views', () => {
210
208
  await expect(promise).rejects.toThrow('Account has been taken down')
211
209
 
212
210
  // Cleanup
213
- await agent.api.com.atproto.admin.reverseModerationAction(
211
+ await agent.api.com.atproto.admin.emitModerationEvent(
214
212
  {
215
- id: action.id,
213
+ event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' },
214
+ subject: {
215
+ $type: 'com.atproto.admin.defs#repoRef',
216
+ did: alice,
217
+ },
216
218
  createdBy: 'did:example:admin',
217
219
  reason: 'Y',
218
220
  },
@@ -19,10 +19,12 @@ describe('pds user search views', () => {
19
19
  await network.bsky.processAll()
20
20
 
21
21
  const suggestions = [
22
- { did: sc.dids.bob, order: 1 },
23
- { did: sc.dids.carol, order: 2 },
24
- { did: sc.dids.dan, order: 3 },
22
+ { did: sc.dids.alice, order: 1 },
23
+ { did: sc.dids.bob, order: 2 },
24
+ { did: sc.dids.carol, order: 3 },
25
+ { did: sc.dids.dan, order: 4 },
25
26
  ]
27
+
26
28
  await network.bsky.ctx.db
27
29
  .getPrimary()
28
30
  .db.insertInto('suggested_follow')
@@ -63,16 +65,22 @@ describe('pds user search views', () => {
63
65
  { limit: 1 },
64
66
  { headers: await network.serviceHeaders(sc.dids.carol) },
65
67
  )
68
+ expect(result1.data.actors.length).toBe(1)
69
+ expect(result1.data.actors[0].handle).toEqual('bob.test')
70
+
66
71
  const result2 = await agent.api.app.bsky.actor.getSuggestions(
67
72
  { limit: 1, cursor: result1.data.cursor },
68
73
  { headers: await network.serviceHeaders(sc.dids.carol) },
69
74
  )
70
-
71
- expect(result1.data.actors.length).toBe(1)
72
- expect(result1.data.actors[0].handle).toEqual('bob.test')
73
-
74
75
  expect(result2.data.actors.length).toBe(1)
75
76
  expect(result2.data.actors[0].handle).toEqual('dan.test')
77
+
78
+ const result3 = await agent.api.app.bsky.actor.getSuggestions(
79
+ { limit: 1, cursor: result2.data.cursor },
80
+ { headers: await network.serviceHeaders(sc.dids.carol) },
81
+ )
82
+ expect(result3.data.actors.length).toBe(0)
83
+ expect(result3.data.cursor).toBeUndefined()
76
84
  })
77
85
 
78
86
  it('fetches suggestions unauthed', async () => {
@@ -1,6 +1,5 @@
1
1
  import AtpAgent, { AppBskyFeedGetPostThread } from '@atproto/api'
2
2
  import { TestNetwork, SeedClient } from '@atproto/dev-env'
3
- import { TAKEDOWN } from '@atproto/api/src/client/types/com/atproto/admin/defs'
4
3
  import { forSnapshot, stripViewerFromThread } from '../_util'
5
4
  import basicSeed from '../seeds/basic'
6
5
  import assert from 'assert'
@@ -167,9 +166,9 @@ describe('pds thread views', () => {
167
166
  describe('takedown', () => {
168
167
  it('blocks post by actor', async () => {
169
168
  const { data: modAction } =
170
- await agent.api.com.atproto.admin.takeModerationAction(
169
+ await agent.api.com.atproto.admin.emitModerationEvent(
171
170
  {
172
- action: TAKEDOWN,
171
+ event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
173
172
  subject: {
174
173
  $type: 'com.atproto.admin.defs#repoRef',
175
174
  did: alice,
@@ -194,9 +193,13 @@ describe('pds thread views', () => {
194
193
  )
195
194
 
196
195
  // Cleanup
197
- await agent.api.com.atproto.admin.reverseModerationAction(
196
+ await agent.api.com.atproto.admin.emitModerationEvent(
198
197
  {
199
- id: modAction.id,
198
+ event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' },
199
+ subject: {
200
+ $type: 'com.atproto.admin.defs#repoRef',
201
+ did: alice,
202
+ },
200
203
  createdBy: 'did:example:admin',
201
204
  reason: 'Y',
202
205
  },
@@ -209,9 +212,9 @@ describe('pds thread views', () => {
209
212
 
210
213
  it('blocks replies by actor', async () => {
211
214
  const { data: modAction } =
212
- await agent.api.com.atproto.admin.takeModerationAction(
215
+ await agent.api.com.atproto.admin.emitModerationEvent(
213
216
  {
214
- action: TAKEDOWN,
217
+ event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
215
218
  subject: {
216
219
  $type: 'com.atproto.admin.defs#repoRef',
217
220
  did: carol,
@@ -234,9 +237,13 @@ describe('pds thread views', () => {
234
237
  expect(forSnapshot(thread.data.thread)).toMatchSnapshot()
235
238
 
236
239
  // Cleanup
237
- await agent.api.com.atproto.admin.reverseModerationAction(
240
+ await agent.api.com.atproto.admin.emitModerationEvent(
238
241
  {
239
- id: modAction.id,
242
+ event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' },
243
+ subject: {
244
+ $type: 'com.atproto.admin.defs#repoRef',
245
+ did: carol,
246
+ },
240
247
  createdBy: 'did:example:admin',
241
248
  reason: 'Y',
242
249
  },
@@ -249,9 +256,9 @@ describe('pds thread views', () => {
249
256
 
250
257
  it('blocks ancestors by actor', async () => {
251
258
  const { data: modAction } =
252
- await agent.api.com.atproto.admin.takeModerationAction(
259
+ await agent.api.com.atproto.admin.emitModerationEvent(
253
260
  {
254
- action: TAKEDOWN,
261
+ event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
255
262
  subject: {
256
263
  $type: 'com.atproto.admin.defs#repoRef',
257
264
  did: bob,
@@ -274,9 +281,13 @@ describe('pds thread views', () => {
274
281
  expect(forSnapshot(thread.data.thread)).toMatchSnapshot()
275
282
 
276
283
  // Cleanup
277
- await agent.api.com.atproto.admin.reverseModerationAction(
284
+ await agent.api.com.atproto.admin.emitModerationEvent(
278
285
  {
279
- id: modAction.id,
286
+ event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' },
287
+ subject: {
288
+ $type: 'com.atproto.admin.defs#repoRef',
289
+ did: bob,
290
+ },
280
291
  createdBy: 'did:example:admin',
281
292
  reason: 'Y',
282
293
  },
@@ -290,9 +301,9 @@ describe('pds thread views', () => {
290
301
  it('blocks post by record', async () => {
291
302
  const postRef = sc.posts[alice][1].ref
292
303
  const { data: modAction } =
293
- await agent.api.com.atproto.admin.takeModerationAction(
304
+ await agent.api.com.atproto.admin.emitModerationEvent(
294
305
  {
295
- action: TAKEDOWN,
306
+ event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
296
307
  subject: {
297
308
  $type: 'com.atproto.repo.strongRef',
298
309
  uri: postRef.uriStr,
@@ -317,9 +328,14 @@ describe('pds thread views', () => {
317
328
  )
318
329
 
319
330
  // Cleanup
320
- await agent.api.com.atproto.admin.reverseModerationAction(
331
+ await agent.api.com.atproto.admin.emitModerationEvent(
321
332
  {
322
- id: modAction.id,
333
+ event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' },
334
+ subject: {
335
+ $type: 'com.atproto.repo.strongRef',
336
+ uri: postRef.uriStr,
337
+ cid: postRef.cidStr,
338
+ },
323
339
  createdBy: 'did:example:admin',
324
340
  reason: 'Y',
325
341
  },
@@ -339,9 +355,9 @@ describe('pds thread views', () => {
339
355
  const parent = threadPreTakedown.data.thread.parent?.['post']
340
356
 
341
357
  const { data: modAction } =
342
- await agent.api.com.atproto.admin.takeModerationAction(
358
+ await agent.api.com.atproto.admin.emitModerationEvent(
343
359
  {
344
- action: TAKEDOWN,
360
+ event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
345
361
  subject: {
346
362
  $type: 'com.atproto.repo.strongRef',
347
363
  uri: parent.uri,
@@ -365,9 +381,14 @@ describe('pds thread views', () => {
365
381
  expect(forSnapshot(thread.data.thread)).toMatchSnapshot()
366
382
 
367
383
  // Cleanup
368
- await agent.api.com.atproto.admin.reverseModerationAction(
384
+ await agent.api.com.atproto.admin.emitModerationEvent(
369
385
  {
370
- id: modAction.id,
386
+ event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' },
387
+ subject: {
388
+ $type: 'com.atproto.repo.strongRef',
389
+ uri: parent.uri,
390
+ cid: parent.cid,
391
+ },
371
392
  createdBy: 'did:example:admin',
372
393
  reason: 'Y',
373
394
  },
@@ -388,9 +409,9 @@ describe('pds thread views', () => {
388
409
 
389
410
  const actionResults = await Promise.all(
390
411
  [post1, post2].map((post) =>
391
- agent.api.com.atproto.admin.takeModerationAction(
412
+ agent.api.com.atproto.admin.emitModerationEvent(
392
413
  {
393
- action: TAKEDOWN,
414
+ event: { $type: 'com.atproto.admin.defs#modEventTakedown' },
394
415
  subject: {
395
416
  $type: 'com.atproto.repo.strongRef',
396
417
  uri: post.uri,
@@ -417,10 +438,17 @@ describe('pds thread views', () => {
417
438
 
418
439
  // Cleanup
419
440
  await Promise.all(
420
- actionResults.map((result) =>
421
- agent.api.com.atproto.admin.reverseModerationAction(
441
+ [post1, post2].map((post) =>
442
+ agent.api.com.atproto.admin.emitModerationEvent(
422
443
  {
423
- id: result.data.id,
444
+ event: {
445
+ $type: 'com.atproto.admin.defs#modEventReverseTakedown',
446
+ },
447
+ subject: {
448
+ $type: 'com.atproto.repo.strongRef',
449
+ uri: post.uri,
450
+ cid: post.cid,
451
+ },
424
452
  createdBy: 'did:example:admin',
425
453
  reason: 'Y',
426
454
  },