@atproto/bsky 0.0.76 → 0.0.78

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 (226) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/api/app/bsky/feed/getActorLikes.js +2 -2
  3. package/dist/api/app/bsky/feed/getActorLikes.js.map +1 -1
  4. package/dist/api/app/bsky/feed/getLikes.js +6 -6
  5. package/dist/api/app/bsky/feed/getLikes.js.map +1 -1
  6. package/dist/api/app/bsky/feed/getListFeed.d.ts.map +1 -1
  7. package/dist/api/app/bsky/feed/getListFeed.js +19 -3
  8. package/dist/api/app/bsky/feed/getListFeed.js.map +1 -1
  9. package/dist/api/app/bsky/feed/getPosts.js +4 -4
  10. package/dist/api/app/bsky/feed/getPosts.js.map +1 -1
  11. package/dist/api/app/bsky/feed/getQuotes.d.ts +4 -0
  12. package/dist/api/app/bsky/feed/getQuotes.d.ts.map +1 -0
  13. package/dist/api/app/bsky/feed/getQuotes.js +67 -0
  14. package/dist/api/app/bsky/feed/getQuotes.js.map +1 -0
  15. package/dist/api/app/bsky/feed/getRepostedBy.js +6 -6
  16. package/dist/api/app/bsky/feed/getRepostedBy.js.map +1 -1
  17. package/dist/api/app/bsky/feed/searchPosts.js +4 -4
  18. package/dist/api/app/bsky/feed/searchPosts.js.map +1 -1
  19. package/dist/api/app/bsky/graph/getFollowers.js +8 -8
  20. package/dist/api/app/bsky/graph/getFollowers.js.map +1 -1
  21. package/dist/api/app/bsky/graph/getList.js +7 -7
  22. package/dist/api/app/bsky/graph/getList.js.map +1 -1
  23. package/dist/api/app/bsky/notification/listNotifications.d.ts.map +1 -1
  24. package/dist/api/app/bsky/notification/listNotifications.js +29 -8
  25. package/dist/api/app/bsky/notification/listNotifications.js.map +1 -1
  26. package/dist/api/index.d.ts.map +1 -1
  27. package/dist/api/index.js +2 -0
  28. package/dist/api/index.js.map +1 -1
  29. package/dist/data-plane/server/db/database-schema.d.ts +4 -2
  30. package/dist/data-plane/server/db/database-schema.d.ts.map +1 -1
  31. package/dist/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.d.ts +4 -0
  32. package/dist/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.d.ts.map +1 -0
  33. package/dist/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.js +15 -0
  34. package/dist/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.js.map +1 -0
  35. package/dist/data-plane/server/db/migrations/20240723T220703655Z-quotes.d.ts +4 -0
  36. package/dist/data-plane/server/db/migrations/20240723T220703655Z-quotes.d.ts.map +1 -0
  37. package/dist/data-plane/server/db/migrations/20240723T220703655Z-quotes.js +30 -0
  38. package/dist/data-plane/server/db/migrations/20240723T220703655Z-quotes.js.map +1 -0
  39. package/dist/data-plane/server/db/migrations/20240801T193939827Z-post-gate.d.ts +4 -0
  40. package/dist/data-plane/server/db/migrations/20240801T193939827Z-post-gate.d.ts.map +1 -0
  41. package/dist/data-plane/server/db/migrations/20240801T193939827Z-post-gate.js +20 -0
  42. package/dist/data-plane/server/db/migrations/20240801T193939827Z-post-gate.js.map +1 -0
  43. package/dist/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.d.ts +4 -0
  44. package/dist/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.d.ts.map +1 -0
  45. package/dist/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.js +28 -0
  46. package/dist/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.js.map +1 -0
  47. package/dist/data-plane/server/db/migrations/index.d.ts +4 -0
  48. package/dist/data-plane/server/db/migrations/index.d.ts.map +1 -1
  49. package/dist/data-plane/server/db/migrations/index.js +5 -1
  50. package/dist/data-plane/server/db/migrations/index.js.map +1 -1
  51. package/dist/data-plane/server/db/tables/post-agg.d.ts +1 -0
  52. package/dist/data-plane/server/db/tables/post-agg.d.ts.map +1 -1
  53. package/dist/data-plane/server/db/tables/post-gate.d.ts +14 -0
  54. package/dist/data-plane/server/db/tables/post-gate.d.ts.map +1 -0
  55. package/dist/data-plane/server/db/tables/post-gate.js +4 -0
  56. package/dist/data-plane/server/db/tables/post-gate.js.map +1 -0
  57. package/dist/data-plane/server/db/tables/post.d.ts +3 -0
  58. package/dist/data-plane/server/db/tables/post.d.ts.map +1 -1
  59. package/dist/data-plane/server/db/tables/quote.d.ts +16 -0
  60. package/dist/data-plane/server/db/tables/quote.d.ts.map +1 -0
  61. package/dist/data-plane/server/db/tables/quote.js +4 -0
  62. package/dist/data-plane/server/db/tables/quote.js.map +1 -0
  63. package/dist/data-plane/server/indexing/index.d.ts +2 -0
  64. package/dist/data-plane/server/indexing/index.d.ts.map +1 -1
  65. package/dist/data-plane/server/indexing/index.js +6 -0
  66. package/dist/data-plane/server/indexing/index.js.map +1 -1
  67. package/dist/data-plane/server/indexing/plugins/post-gate.d.ts +10 -0
  68. package/dist/data-plane/server/indexing/plugins/post-gate.d.ts.map +1 -0
  69. package/dist/data-plane/server/indexing/plugins/post-gate.js +101 -0
  70. package/dist/data-plane/server/indexing/plugins/post-gate.js.map +1 -0
  71. package/dist/data-plane/server/indexing/plugins/post.d.ts +2 -0
  72. package/dist/data-plane/server/indexing/plugins/post.d.ts.map +1 -1
  73. package/dist/data-plane/server/indexing/plugins/post.js +122 -15
  74. package/dist/data-plane/server/indexing/plugins/post.js.map +1 -1
  75. package/dist/data-plane/server/indexing/plugins/thread-gate.d.ts.map +1 -1
  76. package/dist/data-plane/server/indexing/plugins/thread-gate.js +12 -0
  77. package/dist/data-plane/server/indexing/plugins/thread-gate.js.map +1 -1
  78. package/dist/data-plane/server/routes/index.d.ts.map +1 -1
  79. package/dist/data-plane/server/routes/index.js +2 -0
  80. package/dist/data-plane/server/routes/index.js.map +1 -1
  81. package/dist/data-plane/server/routes/interactions.d.ts.map +1 -1
  82. package/dist/data-plane/server/routes/interactions.js +2 -1
  83. package/dist/data-plane/server/routes/interactions.js.map +1 -1
  84. package/dist/data-plane/server/routes/quotes.d.ts +6 -0
  85. package/dist/data-plane/server/routes/quotes.d.ts.map +1 -0
  86. package/dist/data-plane/server/routes/quotes.js +27 -0
  87. package/dist/data-plane/server/routes/quotes.js.map +1 -0
  88. package/dist/data-plane/server/routes/records.d.ts.map +1 -1
  89. package/dist/data-plane/server/routes/records.js +11 -1
  90. package/dist/data-plane/server/routes/records.js.map +1 -1
  91. package/dist/data-plane/server/util.d.ts +6 -7
  92. package/dist/data-plane/server/util.d.ts.map +1 -1
  93. package/dist/data-plane/server/util.js +1 -9
  94. package/dist/data-plane/server/util.js.map +1 -1
  95. package/dist/hydration/feed.d.ts +10 -0
  96. package/dist/hydration/feed.d.ts.map +1 -1
  97. package/dist/hydration/feed.js +31 -7
  98. package/dist/hydration/feed.js.map +1 -1
  99. package/dist/hydration/hydrator.d.ts +4 -2
  100. package/dist/hydration/hydrator.d.ts.map +1 -1
  101. package/dist/hydration/hydrator.js +89 -34
  102. package/dist/hydration/hydrator.js.map +1 -1
  103. package/dist/hydration/util.d.ts +0 -1
  104. package/dist/hydration/util.d.ts.map +1 -1
  105. package/dist/hydration/util.js +1 -5
  106. package/dist/hydration/util.js.map +1 -1
  107. package/dist/lexicon/index.d.ts +2 -0
  108. package/dist/lexicon/index.d.ts.map +1 -1
  109. package/dist/lexicon/index.js +4 -0
  110. package/dist/lexicon/index.js.map +1 -1
  111. package/dist/lexicon/lexicons.d.ts +144 -0
  112. package/dist/lexicon/lexicons.d.ts.map +1 -1
  113. package/dist/lexicon/lexicons.js +146 -1
  114. package/dist/lexicon/lexicons.js.map +1 -1
  115. package/dist/lexicon/types/app/bsky/embed/record.d.ts +9 -1
  116. package/dist/lexicon/types/app/bsky/embed/record.d.ts.map +1 -1
  117. package/dist/lexicon/types/app/bsky/embed/record.js +11 -1
  118. package/dist/lexicon/types/app/bsky/embed/record.js.map +1 -1
  119. package/dist/lexicon/types/app/bsky/feed/defs.d.ts +2 -0
  120. package/dist/lexicon/types/app/bsky/feed/defs.d.ts.map +1 -1
  121. package/dist/lexicon/types/app/bsky/feed/defs.js.map +1 -1
  122. package/dist/lexicon/types/app/bsky/feed/getQuotes.d.ts +44 -0
  123. package/dist/lexicon/types/app/bsky/feed/getQuotes.d.ts.map +1 -0
  124. package/dist/lexicon/types/app/bsky/feed/getQuotes.js +3 -0
  125. package/dist/lexicon/types/app/bsky/feed/getQuotes.js.map +1 -0
  126. package/dist/lexicon/types/app/bsky/feed/postgate.d.ts +25 -0
  127. package/dist/lexicon/types/app/bsky/feed/postgate.d.ts.map +1 -0
  128. package/dist/lexicon/types/app/bsky/feed/postgate.js +27 -0
  129. package/dist/lexicon/types/app/bsky/feed/postgate.js.map +1 -0
  130. package/dist/lexicon/types/app/bsky/feed/threadgate.d.ts +2 -0
  131. package/dist/lexicon/types/app/bsky/feed/threadgate.d.ts.map +1 -1
  132. package/dist/lexicon/types/app/bsky/feed/threadgate.js.map +1 -1
  133. package/dist/proto/bsky_connect.d.ts +30 -1
  134. package/dist/proto/bsky_connect.d.ts.map +1 -1
  135. package/dist/proto/bsky_connect.js +29 -0
  136. package/dist/proto/bsky_connect.js.map +1 -1
  137. package/dist/proto/bsky_pb.d.ts +135 -1
  138. package/dist/proto/bsky_pb.d.ts.map +1 -1
  139. package/dist/proto/bsky_pb.js +425 -5
  140. package/dist/proto/bsky_pb.js.map +1 -1
  141. package/dist/util/uris.d.ts +12 -0
  142. package/dist/util/uris.d.ts.map +1 -0
  143. package/dist/util/uris.js +34 -0
  144. package/dist/util/uris.js.map +1 -0
  145. package/dist/views/index.d.ts +8 -2
  146. package/dist/views/index.d.ts.map +1 -1
  147. package/dist/views/index.js +84 -39
  148. package/dist/views/index.js.map +1 -1
  149. package/dist/views/types.d.ts +1 -1
  150. package/dist/views/types.d.ts.map +1 -1
  151. package/dist/views/types.js.map +1 -1
  152. package/dist/views/util.d.ts +11 -1
  153. package/dist/views/util.d.ts.map +1 -1
  154. package/dist/views/util.js +19 -8
  155. package/dist/views/util.js.map +1 -1
  156. package/package.json +4 -4
  157. package/proto/bsky.proto +42 -2
  158. package/src/api/app/bsky/feed/getActorLikes.ts +1 -1
  159. package/src/api/app/bsky/feed/getLikes.ts +1 -1
  160. package/src/api/app/bsky/feed/getListFeed.ts +30 -3
  161. package/src/api/app/bsky/feed/getPosts.ts +1 -1
  162. package/src/api/app/bsky/feed/getQuotes.ts +108 -0
  163. package/src/api/app/bsky/feed/getRepostedBy.ts +1 -1
  164. package/src/api/app/bsky/feed/searchPosts.ts +1 -1
  165. package/src/api/app/bsky/graph/getFollowers.ts +1 -1
  166. package/src/api/app/bsky/graph/getList.ts +5 -5
  167. package/src/api/app/bsky/notification/listNotifications.ts +32 -6
  168. package/src/api/index.ts +2 -0
  169. package/src/data-plane/server/db/database-schema.ts +7 -3
  170. package/src/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.ts +12 -0
  171. package/src/data-plane/server/db/migrations/20240723T220703655Z-quotes.ts +28 -0
  172. package/src/data-plane/server/db/migrations/20240801T193939827Z-post-gate.ts +17 -0
  173. package/src/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.ts +25 -0
  174. package/src/data-plane/server/db/migrations/index.ts +4 -0
  175. package/src/data-plane/server/db/tables/post-agg.ts +1 -0
  176. package/src/data-plane/server/db/tables/post-gate.ts +12 -0
  177. package/src/data-plane/server/db/tables/post.ts +3 -0
  178. package/src/data-plane/server/db/tables/quote.ts +15 -0
  179. package/src/data-plane/server/indexing/index.ts +7 -0
  180. package/src/data-plane/server/indexing/plugins/post-gate.ts +104 -0
  181. package/src/data-plane/server/indexing/plugins/post.ts +151 -16
  182. package/src/data-plane/server/indexing/plugins/thread-gate.ts +12 -0
  183. package/src/data-plane/server/routes/index.ts +2 -0
  184. package/src/data-plane/server/routes/interactions.ts +2 -1
  185. package/src/data-plane/server/routes/quotes.ts +32 -0
  186. package/src/data-plane/server/routes/records.ts +11 -1
  187. package/src/data-plane/server/util.ts +0 -8
  188. package/src/hydration/feed.ts +58 -12
  189. package/src/hydration/hydrator.ts +94 -22
  190. package/src/hydration/util.ts +0 -4
  191. package/src/lexicon/index.ts +12 -0
  192. package/src/lexicon/lexicons.ts +149 -1
  193. package/src/lexicon/types/app/bsky/embed/record.ts +20 -0
  194. package/src/lexicon/types/app/bsky/feed/defs.ts +2 -0
  195. package/src/lexicon/types/app/bsky/feed/getQuotes.ts +54 -0
  196. package/src/lexicon/types/app/bsky/feed/postgate.ts +47 -0
  197. package/src/lexicon/types/app/bsky/feed/threadgate.ts +2 -0
  198. package/src/proto/bsky_connect.ts +35 -0
  199. package/src/proto/bsky_pb.ts +424 -1
  200. package/src/util/uris.ts +31 -0
  201. package/src/views/index.ts +91 -35
  202. package/src/views/types.ts +1 -0
  203. package/src/views/util.ts +37 -7
  204. package/tests/__snapshots__/feed-generation.test.ts.snap +42 -0
  205. package/tests/data-plane/__snapshots__/indexing.test.ts.snap +20 -0
  206. package/tests/data-plane/indexing.test.ts +1 -0
  207. package/tests/postgates.test.ts +186 -0
  208. package/tests/seed/feed-hidden-replies.ts +62 -0
  209. package/tests/seed/postgates.ts +56 -0
  210. package/tests/views/__snapshots__/author-feed.test.ts.snap +65 -0
  211. package/tests/views/__snapshots__/block-lists.test.ts.snap +7 -0
  212. package/tests/views/__snapshots__/blocks.test.ts.snap +11 -0
  213. package/tests/views/__snapshots__/list-feed.test.ts.snap +24 -0
  214. package/tests/views/__snapshots__/lists.test.ts.snap +185 -1
  215. package/tests/views/__snapshots__/mute-lists.test.ts.snap +8 -0
  216. package/tests/views/__snapshots__/mutes.test.ts.snap +6 -0
  217. package/tests/views/__snapshots__/posts.test.ts.snap +15 -0
  218. package/tests/views/__snapshots__/quotes.test.ts.snap +402 -0
  219. package/tests/views/__snapshots__/thread.test.ts.snap +50 -0
  220. package/tests/views/__snapshots__/timeline.test.ts.snap +191 -0
  221. package/tests/views/author-feed.test.ts +3 -9
  222. package/tests/views/feed-hidden-replies.test.ts +246 -0
  223. package/tests/views/feed-view-post.test.ts +501 -0
  224. package/tests/views/list-feed.test.ts +12 -0
  225. package/tests/views/lists.test.ts +83 -18
  226. package/tests/views/quotes.test.ts +105 -0
@@ -0,0 +1,501 @@
1
+ import { AtpAgent, AppBskyFeedDefs, AtUri } from '@atproto/api'
2
+ import { TestNetwork, SeedClient, basicSeed } from '@atproto/dev-env'
3
+ import { ids } from '../../src/lexicon/lexicons'
4
+
5
+ /**
6
+ * The frontend computes feed slices for display using at-most one
7
+ * `FeedViewPost` slice. If that slice results in an "orphaned" thread e.g.
8
+ * parent or root is blocked, that slice is tossed out and the next
9
+ * `FeedViewPost` slice is considered. That process continues until a
10
+ * contiguous `root -> child` slice can be found.
11
+ *
12
+ * For the tests below, we test with up to 4 slices: one root and up to 3
13
+ * replies. Some tests focus on the first slice, and others ensure that at
14
+ * least one contiguous slice is returned.
15
+ */
16
+ const LIMIT = 4
17
+
18
+ describe('pds thread views', () => {
19
+ let network: TestNetwork
20
+ let agent: AtpAgent
21
+ let pdsAgent: AtpAgent
22
+ let sc: SeedClient
23
+
24
+ // account dids, for convenience
25
+ let alice: string
26
+ let bob: string
27
+ let carol: string
28
+ let dan: string
29
+
30
+ beforeAll(async () => {
31
+ network = await TestNetwork.create({
32
+ dbPostgresSchema: 'bsky_views_feed_view_post',
33
+ })
34
+ agent = network.bsky.getClient()
35
+ pdsAgent = network.pds.getClient()
36
+ sc = network.getSeedClient()
37
+ await basicSeed(sc)
38
+ alice = sc.dids.alice
39
+ bob = sc.dids.bob
40
+ carol = sc.dids.carol
41
+ dan = sc.dids.dan
42
+
43
+ await sc.follow(carol, alice)
44
+ await sc.follow(carol, bob)
45
+ await sc.follow(carol, dan)
46
+ await sc.follow(dan, alice)
47
+ await sc.follow(dan, bob)
48
+ await sc.follow(dan, carol)
49
+
50
+ await network.processAll()
51
+ })
52
+
53
+ afterAll(async () => {
54
+ await network.close()
55
+ })
56
+
57
+ it(`[A] -> [B], A blocks B, viewed as C`, async () => {
58
+ const A = await sc.post(alice, `A`)
59
+ await network.processAll()
60
+ const B = await sc.reply(bob, A.ref, A.ref, `B`)
61
+ await network.processAll()
62
+ const block = await pdsAgent.api.app.bsky.graph.block.create(
63
+ { repo: alice },
64
+ { createdAt: new Date().toISOString(), subject: bob },
65
+ sc.getHeaders(alice),
66
+ )
67
+
68
+ await network.processAll()
69
+
70
+ const timeline = await agent.api.app.bsky.feed.getTimeline(
71
+ { limit: LIMIT },
72
+ {
73
+ headers: await network.serviceHeaders(
74
+ carol,
75
+ ids.AppBskyFeedGetTimeline,
76
+ ),
77
+ },
78
+ )
79
+
80
+ const sliceA = timeline.data.feed.find((f) => f.post.uri === A.ref.uriStr)
81
+ const sliceB = timeline.data.feed.find((f) => f.post.uri === B.ref.uriStr)
82
+
83
+ expect(sliceA).toBeDefined()
84
+ expect(sliceB).toBeDefined()
85
+
86
+ if (!sliceA || !sliceB) {
87
+ throw new Error('sliceA or sliceB is undefined')
88
+ }
89
+
90
+ expect(AppBskyFeedDefs.isBlockedPost(sliceB.reply?.parent)).toBe(true)
91
+ expect(AppBskyFeedDefs.isBlockedPost(sliceB.reply?.root)).toBe(true)
92
+
93
+ await pdsAgent.api.app.bsky.graph.block.delete(
94
+ { repo: alice, rkey: new AtUri(block.uri).rkey },
95
+ sc.getHeaders(alice),
96
+ )
97
+ })
98
+
99
+ it(`[A] -> [B] -> [C], A blocks B, viewed as C`, async () => {
100
+ const A = await sc.post(alice, `A`)
101
+ await network.processAll()
102
+ const B = await sc.reply(bob, A.ref, A.ref, `B`)
103
+ await network.processAll()
104
+ const C = await sc.reply(carol, A.ref, B.ref, `C`)
105
+ const block = await pdsAgent.api.app.bsky.graph.block.create(
106
+ { repo: alice },
107
+ { createdAt: new Date().toISOString(), subject: bob },
108
+ sc.getHeaders(alice),
109
+ )
110
+
111
+ await network.processAll()
112
+
113
+ const timeline = await agent.api.app.bsky.feed.getTimeline(
114
+ { limit: LIMIT },
115
+ {
116
+ headers: await network.serviceHeaders(
117
+ carol,
118
+ ids.AppBskyFeedGetTimeline,
119
+ ),
120
+ },
121
+ )
122
+
123
+ const sliceC = timeline.data.feed.find((f) => f.post.uri === C.ref.uriStr)
124
+
125
+ expect(sliceC).toBeDefined()
126
+ expect(sliceC?.reply).toBeDefined()
127
+
128
+ if (!sliceC || !sliceC.reply) {
129
+ throw new Error('sliceC is undefined')
130
+ }
131
+
132
+ expect(sliceC.reply.parent.uri).toEqual(B.ref.uriStr)
133
+ expect(sliceC.reply.root.uri).toEqual(A.ref.uriStr)
134
+ expect(AppBskyFeedDefs.isPostView(sliceC.reply.parent)).toBe(true)
135
+ expect(AppBskyFeedDefs.isBlockedPost(sliceC.reply.root)).toBe(true)
136
+
137
+ await pdsAgent.api.app.bsky.graph.block.delete(
138
+ { repo: alice, rkey: new AtUri(block.uri).rkey },
139
+ sc.getHeaders(alice),
140
+ )
141
+ })
142
+
143
+ it(`[A] -> [B] -> [C], C blocks A, viewed as C`, async () => {
144
+ const A = await sc.post(alice, `A`)
145
+ await network.processAll()
146
+ const B = await sc.reply(bob, A.ref, A.ref, `B`)
147
+ await network.processAll()
148
+ const C = await sc.reply(carol, A.ref, B.ref, `C`)
149
+ const block = await pdsAgent.api.app.bsky.graph.block.create(
150
+ { repo: carol },
151
+ { createdAt: new Date().toISOString(), subject: alice },
152
+ sc.getHeaders(carol),
153
+ )
154
+
155
+ await network.processAll()
156
+
157
+ const timeline = await agent.api.app.bsky.feed.getTimeline(
158
+ // make sure we process all slices in this test
159
+ { limit: LIMIT },
160
+ {
161
+ headers: await network.serviceHeaders(
162
+ carol,
163
+ ids.AppBskyFeedGetTimeline,
164
+ ),
165
+ },
166
+ )
167
+
168
+ const sliceB = timeline.data.feed.find((f) => f.post.uri === B.ref.uriStr)
169
+ const sliceC = timeline.data.feed.find((f) => f.post.uri === C.ref.uriStr)
170
+
171
+ expect(sliceB).toBeUndefined()
172
+ expect(sliceC).toBeUndefined()
173
+
174
+ await pdsAgent.api.app.bsky.graph.block.delete(
175
+ { repo: carol, rkey: new AtUri(block.uri).rkey },
176
+ sc.getHeaders(carol),
177
+ )
178
+ })
179
+
180
+ it(`[A] -> [B] -> [C], C blocks B, viewed as C`, async () => {
181
+ const A = await sc.post(alice, `A`)
182
+ await network.processAll()
183
+ const B = await sc.reply(bob, A.ref, A.ref, `B`)
184
+ await network.processAll()
185
+ const C = await sc.reply(carol, A.ref, B.ref, `C`)
186
+ const block = await pdsAgent.api.app.bsky.graph.block.create(
187
+ { repo: carol },
188
+ { createdAt: new Date().toISOString(), subject: bob },
189
+ sc.getHeaders(carol),
190
+ )
191
+
192
+ await network.processAll()
193
+
194
+ const timeline = await agent.api.app.bsky.feed.getTimeline(
195
+ // make sure we process all slices in this test
196
+ { limit: LIMIT },
197
+ {
198
+ headers: await network.serviceHeaders(
199
+ carol,
200
+ ids.AppBskyFeedGetTimeline,
201
+ ),
202
+ },
203
+ )
204
+
205
+ const sliceA = timeline.data.feed.find((f) => f.post.uri === A.ref.uriStr)
206
+ const sliceC = timeline.data.feed.find((f) => f.post.uri === C.ref.uriStr)
207
+
208
+ expect(sliceA).toBeDefined()
209
+ expect(sliceC).toBeUndefined()
210
+
211
+ await pdsAgent.api.app.bsky.graph.block.delete(
212
+ { repo: carol, rkey: new AtUri(block.uri).rkey },
213
+ sc.getHeaders(carol),
214
+ )
215
+ })
216
+
217
+ it(`[A] -> [B] -> [C] -> [D], A blocks C, viewed as C`, async () => {
218
+ const A = await sc.post(alice, `A`)
219
+ await network.processAll()
220
+ const B = await sc.reply(bob, A.ref, A.ref, `B`)
221
+ await network.processAll()
222
+ const C = await sc.reply(carol, A.ref, B.ref, `C`)
223
+ await network.processAll()
224
+ const D = await sc.reply(dan, A.ref, C.ref, `D`)
225
+ const block = await pdsAgent.api.app.bsky.graph.block.create(
226
+ { repo: alice },
227
+ { createdAt: new Date().toISOString(), subject: carol },
228
+ sc.getHeaders(alice),
229
+ )
230
+
231
+ await network.processAll()
232
+
233
+ const timeline = await agent.api.app.bsky.feed.getTimeline(
234
+ { limit: LIMIT },
235
+ {
236
+ headers: await network.serviceHeaders(
237
+ carol,
238
+ ids.AppBskyFeedGetTimeline,
239
+ ),
240
+ },
241
+ )
242
+
243
+ const sliceD = timeline.data.feed.find((f) => f.post.uri === D.ref.uriStr)
244
+
245
+ expect(sliceD).toBeDefined()
246
+ expect(sliceD?.reply).toBeDefined()
247
+
248
+ if (!sliceD || !sliceD.reply) {
249
+ throw new Error('sliceD is undefined')
250
+ }
251
+
252
+ expect(sliceD.reply.parent.uri).toEqual(C.ref.uriStr)
253
+ expect(sliceD.reply.root.uri).toEqual(A.ref.uriStr)
254
+ expect(AppBskyFeedDefs.isPostView(sliceD.reply.parent)).toBe(true)
255
+ expect(AppBskyFeedDefs.isBlockedPost(sliceD.reply.root)).toBe(true)
256
+
257
+ await pdsAgent.api.app.bsky.graph.block.delete(
258
+ { repo: alice, rkey: new AtUri(block.uri).rkey },
259
+ sc.getHeaders(alice),
260
+ )
261
+ })
262
+
263
+ it(`[A] -> [B] -> [C] -> [D], A blocks C, viewed as D`, async () => {
264
+ const A = await sc.post(alice, `A`)
265
+ await network.processAll()
266
+ const B = await sc.reply(bob, A.ref, A.ref, `B`)
267
+ await network.processAll()
268
+ const C = await sc.reply(carol, A.ref, B.ref, `C`)
269
+ await network.processAll()
270
+ const D = await sc.reply(dan, A.ref, C.ref, `D`)
271
+ const block = await pdsAgent.api.app.bsky.graph.block.create(
272
+ { repo: alice },
273
+ { createdAt: new Date().toISOString(), subject: carol },
274
+ sc.getHeaders(alice),
275
+ )
276
+
277
+ await network.processAll()
278
+
279
+ const timeline = await agent.api.app.bsky.feed.getTimeline(
280
+ { limit: LIMIT },
281
+ {
282
+ headers: await network.serviceHeaders(dan, ids.AppBskyFeedGetTimeline),
283
+ },
284
+ )
285
+
286
+ const sliceD = timeline.data.feed.find((f) => f.post.uri === D.ref.uriStr)
287
+
288
+ expect(sliceD).toBeDefined()
289
+ expect(sliceD?.reply).toBeDefined()
290
+
291
+ if (!sliceD || !sliceD.reply) {
292
+ throw new Error('sliceD is undefined')
293
+ }
294
+
295
+ expect(sliceD.reply.parent.uri).toEqual(C.ref.uriStr)
296
+ expect(sliceD.reply.root.uri).toEqual(A.ref.uriStr)
297
+ expect(AppBskyFeedDefs.isPostView(sliceD.reply.parent)).toBe(true)
298
+ expect(AppBskyFeedDefs.isBlockedPost(sliceD.reply.root)).toBe(true)
299
+
300
+ await pdsAgent.api.app.bsky.graph.block.delete(
301
+ { repo: alice, rkey: new AtUri(block.uri).rkey },
302
+ sc.getHeaders(alice),
303
+ )
304
+ })
305
+
306
+ it(`[A] -> [B] -> [C] -> [D], A blocks B, viewed as C`, async () => {
307
+ const A = await sc.post(alice, `A`)
308
+ await network.processAll()
309
+ const B = await sc.reply(bob, A.ref, A.ref, `B`)
310
+ await network.processAll()
311
+ const C = await sc.reply(carol, A.ref, B.ref, `C`)
312
+ await network.processAll()
313
+ const D = await sc.reply(dan, A.ref, C.ref, `D`)
314
+ const block = await pdsAgent.api.app.bsky.graph.block.create(
315
+ { repo: alice },
316
+ { createdAt: new Date().toISOString(), subject: bob },
317
+ sc.getHeaders(alice),
318
+ )
319
+
320
+ await network.processAll()
321
+
322
+ const timeline = await agent.api.app.bsky.feed.getTimeline(
323
+ { limit: LIMIT },
324
+ {
325
+ headers: await network.serviceHeaders(
326
+ carol,
327
+ ids.AppBskyFeedGetTimeline,
328
+ ),
329
+ },
330
+ )
331
+
332
+ const sliceD = timeline.data.feed.find((f) => f.post.uri === D.ref.uriStr)
333
+
334
+ expect(sliceD).toBeDefined()
335
+ expect(sliceD?.reply).toBeDefined()
336
+
337
+ if (!sliceD || !sliceD.reply) {
338
+ throw new Error('sliceD is undefined')
339
+ }
340
+
341
+ expect(sliceD.reply.parent.uri).toEqual(C.ref.uriStr)
342
+ expect(sliceD.reply.root.uri).toEqual(A.ref.uriStr)
343
+ expect(AppBskyFeedDefs.isPostView(sliceD.reply.parent)).toBe(true)
344
+ /*
345
+ * We don't walk the reply ancestors past whats available in the ReplyRef
346
+ */
347
+ expect(AppBskyFeedDefs.isPostView(sliceD.reply.root)).toBe(true)
348
+
349
+ await pdsAgent.api.app.bsky.graph.block.delete(
350
+ { repo: alice, rkey: new AtUri(block.uri).rkey },
351
+ sc.getHeaders(alice),
352
+ )
353
+ })
354
+
355
+ it(`[A] -> [B] -> [C] -> [D], B blocks C, viewed as D`, async () => {
356
+ const A = await sc.post(alice, `A`)
357
+ await network.processAll()
358
+ const B = await sc.reply(bob, A.ref, A.ref, `B`)
359
+ await network.processAll()
360
+ const C = await sc.reply(carol, A.ref, B.ref, `C`)
361
+ await network.processAll()
362
+ const D = await sc.reply(dan, A.ref, C.ref, `D`)
363
+ const block = await pdsAgent.api.app.bsky.graph.block.create(
364
+ { repo: bob },
365
+ { createdAt: new Date().toISOString(), subject: carol },
366
+ sc.getHeaders(bob),
367
+ )
368
+
369
+ await network.processAll()
370
+
371
+ const timeline = await agent.api.app.bsky.feed.getTimeline(
372
+ { limit: LIMIT },
373
+ {
374
+ headers: await network.serviceHeaders(dan, ids.AppBskyFeedGetTimeline),
375
+ },
376
+ )
377
+
378
+ const sliceD = timeline.data.feed.find((f) => f.post.uri === D.ref.uriStr)
379
+
380
+ expect(sliceD).toBeDefined()
381
+ expect(sliceD?.reply).toBeDefined()
382
+
383
+ if (!sliceD || !sliceD.reply) {
384
+ throw new Error('sliceD is undefined')
385
+ }
386
+
387
+ expect(sliceD.reply.parent.uri).toEqual(C.ref.uriStr)
388
+ expect(sliceD.reply.root.uri).toEqual(A.ref.uriStr)
389
+ expect(AppBskyFeedDefs.isPostView(sliceD.reply.parent)).toBe(true)
390
+ /*
391
+ * We don't walk the reply ancestors past whats available in the ReplyRef
392
+ */
393
+ expect(AppBskyFeedDefs.isPostView(sliceD.reply.root)).toBe(true)
394
+
395
+ await pdsAgent.api.app.bsky.graph.block.delete(
396
+ { repo: bob, rkey: new AtUri(block.uri).rkey },
397
+ sc.getHeaders(bob),
398
+ )
399
+ })
400
+
401
+ it(`[A] -> [B] -> [C] -> [D], A blocks D, viewed as C`, async () => {
402
+ const A = await sc.post(alice, `A`)
403
+ await network.processAll()
404
+ const B = await sc.reply(bob, A.ref, A.ref, `B`)
405
+ await network.processAll()
406
+ const C = await sc.reply(carol, A.ref, B.ref, `C`)
407
+ await network.processAll()
408
+ const D = await sc.reply(dan, A.ref, C.ref, `D`)
409
+ const block = await pdsAgent.api.app.bsky.graph.block.create(
410
+ { repo: alice },
411
+ { createdAt: new Date().toISOString(), subject: dan },
412
+ sc.getHeaders(alice),
413
+ )
414
+
415
+ await network.processAll()
416
+
417
+ const timeline = await agent.api.app.bsky.feed.getTimeline(
418
+ { limit: LIMIT },
419
+ {
420
+ headers: await network.serviceHeaders(
421
+ carol,
422
+ ids.AppBskyFeedGetTimeline,
423
+ ),
424
+ },
425
+ )
426
+
427
+ const sliceD = timeline.data.feed.find((f) => f.post.uri === D.ref.uriStr)
428
+ const sliceC = timeline.data.feed.find((f) => f.post.uri === C.ref.uriStr)
429
+
430
+ expect(sliceD).toBeDefined()
431
+ expect(sliceC).toBeDefined()
432
+
433
+ if (!sliceD || !sliceC) {
434
+ throw new Error('sliceD or sliceC is undefined')
435
+ }
436
+
437
+ expect(AppBskyFeedDefs.isBlockedPost(sliceD.reply?.root)).toBe(true)
438
+ expect(AppBskyFeedDefs.isPostView(sliceC.reply?.parent)).toBe(true)
439
+ expect(AppBskyFeedDefs.isPostView(sliceC.reply?.root)).toBe(true)
440
+
441
+ await pdsAgent.api.app.bsky.graph.block.delete(
442
+ { repo: alice, rkey: new AtUri(block.uri).rkey },
443
+ sc.getHeaders(alice),
444
+ )
445
+ })
446
+
447
+ it(`[A] -> [B] -> [C] -> [D], A blocks C, viewed as D, A/B/C are outside first page`, async () => {
448
+ const A = await sc.post(alice, `A`)
449
+ await network.processAll()
450
+ const B = await sc.reply(bob, A.ref, A.ref, `B`)
451
+ await network.processAll()
452
+ const C = await sc.reply(carol, A.ref, B.ref, `C`)
453
+ await network.processAll()
454
+
455
+ // push A/B/C to send page of results
456
+ await sc.post(alice, `Aa`)
457
+ await sc.post(alice, `Ab`)
458
+ await sc.post(alice, `Ac`)
459
+ await sc.post(alice, `Ad`)
460
+
461
+ await network.processAll()
462
+
463
+ const D = await sc.reply(dan, A.ref, C.ref, `D`)
464
+ const block = await pdsAgent.api.app.bsky.graph.block.create(
465
+ { repo: alice },
466
+ { createdAt: new Date().toISOString(), subject: carol },
467
+ sc.getHeaders(alice),
468
+ )
469
+
470
+ await network.processAll()
471
+
472
+ const timeline = await agent.api.app.bsky.feed.getTimeline(
473
+ { limit: LIMIT },
474
+ {
475
+ headers: await network.serviceHeaders(dan, ids.AppBskyFeedGetTimeline),
476
+ },
477
+ )
478
+
479
+ const sliceD = timeline.data.feed.find((f) => f.post.uri === D.ref.uriStr)
480
+ const sliceA = timeline.data.feed.find((f) => f.post.uri === A.ref.uriStr)
481
+
482
+ expect(sliceD).toBeDefined()
483
+ expect(sliceD?.reply).toBeDefined()
484
+ // not in first page of results
485
+ expect(sliceA).toBeUndefined()
486
+
487
+ if (!sliceD || !sliceD.reply) {
488
+ throw new Error('sliceD is undefined')
489
+ }
490
+
491
+ expect(sliceD.reply.parent.uri).toEqual(C.ref.uriStr)
492
+ expect(sliceD.reply.root.uri).toEqual(A.ref.uriStr)
493
+ expect(AppBskyFeedDefs.isPostView(sliceD.reply.parent)).toBe(true)
494
+ expect(AppBskyFeedDefs.isBlockedPost(sliceD.reply.root)).toBe(true)
495
+
496
+ await pdsAgent.api.app.bsky.graph.block.delete(
497
+ { repo: alice, rkey: new AtUri(block.uri).rkey },
498
+ sc.getHeaders(alice),
499
+ )
500
+ })
501
+ })
@@ -175,4 +175,16 @@ describe('list feed views', () => {
175
175
  recordUri: postRef.uriStr,
176
176
  })
177
177
  })
178
+
179
+ it('does not return posts with creator blocks', async () => {
180
+ await sc.block(bob, alice)
181
+ await network.processAll()
182
+
183
+ const res = await agent.api.app.bsky.feed.getListFeed({
184
+ list: listRef.uriStr,
185
+ })
186
+
187
+ const hasBob = res.data.feed.some((item) => item.post.author.did === bob)
188
+ expect(hasBob).toBe(false)
189
+ })
178
190
  })
@@ -8,7 +8,9 @@ describe('bsky actor likes feed views', () => {
8
8
  let agent: AtpAgent
9
9
  let sc: SeedClient
10
10
 
11
+ let curateList: string
11
12
  let referenceList: string
13
+ let alice: string
12
14
  let eve: string
13
15
  let frankie: string
14
16
  let greta: string
@@ -35,17 +37,32 @@ describe('bsky actor likes feed views', () => {
35
37
  email: 'greta@greta.com',
36
38
  password: 'hunter4real',
37
39
  })
38
- const newList = await sc.createList(
40
+
41
+ const newRefList = await sc.createList(
39
42
  sc.dids.eve,
40
43
  'blah starter pack list!',
41
44
  'reference',
42
45
  )
43
- await sc.addToList(sc.dids.eve, sc.dids.eve, newList)
44
- await sc.addToList(sc.dids.eve, sc.dids.bob, newList)
45
- await sc.addToList(sc.dids.eve, sc.dids.frankie, newList)
46
+ const newCurrList = await sc.createList(
47
+ sc.dids.eve,
48
+ 'blah curate list!',
49
+ 'curate',
50
+ )
51
+
52
+ await sc.addToList(sc.dids.eve, sc.dids.eve, newRefList)
53
+ await sc.addToList(sc.dids.eve, sc.dids.bob, newRefList)
54
+ await sc.addToList(sc.dids.eve, sc.dids.frankie, newRefList)
55
+
56
+ await sc.addToList(sc.dids.eve, sc.dids.eve, newCurrList)
57
+ await sc.addToList(sc.dids.eve, sc.dids.bob, newCurrList)
58
+ await sc.addToList(sc.dids.eve, sc.dids.frankie, newCurrList)
59
+
46
60
  await sc.block(sc.dids.frankie, sc.dids.eve)
61
+
47
62
  await network.processAll()
48
- referenceList = newList.uriStr
63
+ curateList = newCurrList.uriStr
64
+ referenceList = newRefList.uriStr
65
+ alice = sc.dids.alice
49
66
  eve = sc.dids.eve
50
67
  frankie = sc.dids.frankie
51
68
  greta = sc.dids.greta
@@ -61,44 +78,92 @@ describe('bsky actor likes feed views', () => {
61
78
  const view = await agent.api.app.bsky.graph.getLists({
62
79
  actor: eve,
63
80
  })
64
- expect(view.data.lists.length).toBe(1)
81
+ expect(view.data.lists.length).toBe(2)
65
82
  expect(forSnapshot(view.data.lists)).toMatchSnapshot()
66
83
  })
67
84
 
68
85
  it('does not include users with creator block relationship in reference lists for non-creator, in-list viewers', async () => {
69
- const view = await agent.api.app.bsky.graph.getList(
86
+ const curView = await agent.api.app.bsky.graph.getList(
87
+ {
88
+ list: curateList,
89
+ },
90
+ {
91
+ headers: await network.serviceHeaders(frankie, ids.AppBskyGraphGetList),
92
+ },
93
+ )
94
+ expect(curView.data.items.length).toBe(2)
95
+ expect(forSnapshot(curView.data.items)).toMatchSnapshot()
96
+
97
+ const refView = await agent.api.app.bsky.graph.getList(
70
98
  { list: referenceList },
71
99
  {
72
100
  headers: await network.serviceHeaders(frankie, ids.AppBskyGraphGetList),
73
101
  },
74
102
  )
75
- expect(view.data.items.length).toBe(2)
76
- expect(forSnapshot(view.data.items)).toMatchSnapshot()
103
+ expect(refView.data.items.length).toBe(2)
104
+ expect(forSnapshot(refView.data.items)).toMatchSnapshot()
77
105
  })
78
106
 
79
107
  it('does not include users with creator block relationship in reference lists for non-creator, not-in-list viewers', async () => {
80
- const view = await agent.api.app.bsky.graph.getList(
108
+ const curView = await agent.api.app.bsky.graph.getList(
109
+ {
110
+ list: curateList,
111
+ },
112
+ { headers: await network.serviceHeaders(greta, ids.AppBskyGraphGetList) },
113
+ )
114
+ expect(curView.data.items.length).toBe(2)
115
+ expect(forSnapshot(curView.data.items)).toMatchSnapshot()
116
+
117
+ const refView = await agent.api.app.bsky.graph.getList(
81
118
  { list: referenceList },
82
119
  { headers: await network.serviceHeaders(greta, ids.AppBskyGraphGetList) },
83
120
  )
84
- expect(view.data.items.length).toBe(2)
85
- expect(forSnapshot(view.data.items)).toMatchSnapshot()
121
+ expect(refView.data.items.length).toBe(2)
122
+ expect(forSnapshot(refView.data.items)).toMatchSnapshot()
86
123
  })
87
124
 
88
- it('does not include users with creator block relationship in reference lists for signed-out viewers', async () => {
89
- const view = await agent.api.app.bsky.graph.getList({
125
+ it('does not include users with creator block relationship in reference and curate lists for signed-out viewers', async () => {
126
+ const curView = await agent.api.app.bsky.graph.getList({
127
+ list: curateList,
128
+ })
129
+ expect(curView.data.items.length).toBe(2)
130
+ expect(forSnapshot(curView.data.items)).toMatchSnapshot()
131
+
132
+ const refView = await agent.api.app.bsky.graph.getList({
90
133
  list: referenceList,
91
134
  })
92
- expect(view.data.items.length).toBe(2)
93
- expect(forSnapshot(view.data.items)).toMatchSnapshot()
135
+ expect(refView.data.items.length).toBe(2)
136
+ expect(forSnapshot(refView.data.items)).toMatchSnapshot()
94
137
  })
95
138
 
96
139
  it('does include users with creator block relationship in reference lists for creator', async () => {
97
- const view = await agent.api.app.bsky.graph.getList(
140
+ const curView = await agent.api.app.bsky.graph.getList(
141
+ { list: curateList },
142
+ { headers: await network.serviceHeaders(eve, ids.AppBskyGraphGetList) },
143
+ )
144
+ expect(curView.data.items.length).toBe(3)
145
+ expect(forSnapshot(curView.data.items)).toMatchSnapshot()
146
+
147
+ const refView = await agent.api.app.bsky.graph.getList(
98
148
  { list: referenceList },
99
149
  { headers: await network.serviceHeaders(eve, ids.AppBskyGraphGetList) },
100
150
  )
101
- expect(view.data.items.length).toBe(3)
151
+ expect(refView.data.items.length).toBe(3)
152
+ expect(forSnapshot(refView.data.items)).toMatchSnapshot()
153
+ })
154
+
155
+ it('does return all users regardless of creator block relationship in moderation lists', async () => {
156
+ const blockList = await sc.createList(eve, 'block list', 'mod')
157
+ await sc.addToList(eve, frankie, blockList)
158
+ await sc.addToList(eve, greta, blockList)
159
+ await sc.block(frankie, greta)
160
+ await network.processAll()
161
+
162
+ const view = await agent.api.app.bsky.graph.getList(
163
+ { list: blockList.uriStr },
164
+ { headers: await network.serviceHeaders(alice, ids.AppBskyGraphGetList) },
165
+ )
166
+ expect(view.data.items.length).toBe(2)
102
167
  expect(forSnapshot(view.data.items)).toMatchSnapshot()
103
168
  })
104
169
  })