Appview: remove replies to blocked posts from feeds ()

appview: remove replies to blocked posts from feeds
This commit is contained in:
devin ivy 2024-04-19 19:07:01 -04:00 committed by GitHub
parent 1faf634dda
commit b07950682c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 25 additions and 5 deletions
packages/bsky

@ -111,7 +111,8 @@ const noBlocksOrMutes = (inputs: RulesFnInput<Context, Params, Skeleton>) => {
!bam.authorBlocked &&
!bam.authorMuted &&
!bam.originatorBlocked &&
!bam.originatorMuted
!bam.originatorMuted &&
!bam.parentAuthorBlocked
)
})
return skeleton

@ -86,7 +86,8 @@ const noBlocksOrMutes = (inputs: {
!bam.authorBlocked &&
!bam.authorMuted &&
!bam.originatorBlocked &&
!bam.originatorMuted
!bam.originatorMuted &&
!bam.parentAuthorBlocked
)
})
return skeleton

@ -89,7 +89,8 @@ const noBlocksOrMutes = (inputs: {
!bam.authorBlocked &&
!bam.authorMuted &&
!bam.originatorBlocked &&
!bam.originatorMuted
!bam.originatorMuted &&
!bam.parentAuthorBlocked
)
})
return skeleton

@ -334,16 +334,23 @@ export class Views {
originatorBlocked: boolean
authorMuted: boolean
authorBlocked: boolean
parentAuthorBlocked: boolean
} {
const authorDid = creatorFromUri(item.post.uri)
const originatorDid = item.repost
? creatorFromUri(item.repost.uri)
: authorDid
const post = state.posts?.get(item.post.uri)
const parentUri = post?.record.reply?.parent.uri
const parentAuthorDid = parentUri && creatorFromUri(parentUri)
return {
originatorMuted: this.viewerMuteExists(originatorDid, state),
originatorBlocked: this.viewerBlockExists(originatorDid, state),
authorMuted: this.viewerMuteExists(authorDid, state),
authorBlocked: this.viewerBlockExists(authorDid, state),
parentAuthorBlocked: parentAuthorDid
? this.viewerBlockExists(parentAuthorDid, state)
: false,
}
}

@ -160,8 +160,14 @@ describe('pds views with blocking', () => {
{ limit: 100 },
{ headers: await network.serviceHeaders(carol) },
)
// dan's posts don't appear, nor alice's reply to dan.
expect(
resCarol.data.feed.some((post) => post.post.author.did === dan),
resCarol.data.feed.some(
(post) =>
post.post.author.did === dan ||
post.reply?.parent.author?.['did'] === dan,
),
).toBeFalsy()
const resDan = await agent.api.app.bsky.feed.getTimeline(
@ -169,7 +175,11 @@ describe('pds views with blocking', () => {
{ headers: await network.serviceHeaders(dan) },
)
expect(
resDan.data.feed.some((post) => post.post.author.did === carol),
resDan.data.feed.some(
(post) =>
post.post.author.did === carol ||
post.reply?.parent.author?.['did'] === carol,
),
).toBeFalsy()
})