Skip to content

Commit

Permalink
filter posts with an embed block (bluesky-social#2740)
Browse files Browse the repository at this point in the history
* filter posts with an embed block

* log
  • Loading branch information
haileyok authored Aug 23, 2024
1 parent a8e1f90 commit 5af9b82
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/bsky/src/api/app/bsky/feed/getQuotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ const noBlocks = (inputs: {
}) => {
const { ctx, skeleton, hydration } = inputs
skeleton.uris = skeleton.uris.filter((uri) => {
return !ctx.views.viewerBlockExists(uri, hydration)
const embedBlock = hydration.postBlocks?.get(uri)?.embed
return !ctx.views.viewerBlockExists(uri, hydration) && !embedBlock
})
return skeleton
}
Expand Down
14 changes: 14 additions & 0 deletions packages/bsky/tests/views/quotes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('pds quote views', () => {
// account dids, for convenience
let alice: string
let bob: string
let carol: string
let eve: string

beforeAll(async () => {
Expand All @@ -23,6 +24,7 @@ describe('pds quote views', () => {
await network.processAll()
alice = sc.dids.alice
bob = sc.dids.bob
carol = sc.dids.carol
eve = sc.dids.eve
})

Expand Down Expand Up @@ -102,4 +104,16 @@ describe('pds quote views', () => {
expect(bobPost.data.posts[0].quoteCount).toEqual(0)
expect(forSnapshot(bobPost.data)).toMatchSnapshot()
})

it('does not return post in list when the embed is blocked', async () => {
await sc.block(carol, eve)
await network.processAll()

const quotes = await agent.api.app.bsky.feed.getQuotes(
{ uri: sc.posts[carol][1].ref.uriStr },
{ headers: await network.serviceHeaders(bob, ids.AppBskyFeedGetQuotes) },
)

expect(quotes.data.posts.length).toBe(0)
})
})
3 changes: 3 additions & 0 deletions packages/dev-env/src/seed/quotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export default async (sc: SeedClient) => {
sc.replies[sc.dids.bob][0].ref,
)

const carolPost = await sc.post(sc.dids.carol, 'post')
await sc.post(sc.dids.eve, 'qUoTe 4', undefined, undefined, carolPost.ref)

const spamPosts: Promise<any>[] = []
for (let i = 0; i < 5; i++) {
spamPosts.push(
Expand Down

0 comments on commit 5af9b82

Please sign in to comment.