Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handle 3rd party blocks in feeds #1677

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/bsky/src/services/feed/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ export class FeedViews {
labels,
lists,
)
// skip over not found & blocked posts
if (!post || blocks[post.uri]?.reply) {
// skip over not found post
if (!post) {
continue
}
const feedPost = { post }
Expand All @@ -142,6 +142,7 @@ export class FeedViews {
) {
const replyParent = this.formatMaybePostView(
item.replyParent,
item.uri,
actors,
posts,
threadgates,
Expand All @@ -153,6 +154,7 @@ export class FeedViews {
)
const replyRoot = this.formatMaybePostView(
item.replyRoot,
item.uri,
actors,
posts,
threadgates,
Expand Down Expand Up @@ -219,6 +221,7 @@ export class FeedViews {

formatMaybePostView(
uri: string,
replyUri: string | null,
actors: ActorInfoMap,
posts: PostInfoMap,
threadgates: ThreadgateInfoMap,
Expand Down Expand Up @@ -246,7 +249,7 @@ export class FeedViews {
if (
post.author.viewer?.blockedBy ||
post.author.viewer?.blocking ||
blocks[uri]?.reply
(replyUri !== null && blocks[replyUri]?.reply)
Comment on lines -323 to +326
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to make sure I understand the intended behavior here: replies to block-violating replies are blocked, is that right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so a feed view post includes post views for it's replyParent & replyRoot

this basically says, the reply violates a block, then don't hydrated in the replyParent/Root

another downside of not naming this field replyTo 😅

) {
if (!opts?.usePostViewUnion) return
return this.blockedPost(post)
Expand Down
3 changes: 2 additions & 1 deletion packages/bsky/tests/views/blocks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ describe('pds views with blocking', () => {
const replyBlockedPost = timeline.feed.find(
(item) => item.post.uri === replyBlockedUri,
)
expect(replyBlockedPost).toBeUndefined()
assert(replyBlockedPost)
expect(replyBlockedPost.reply?.parent).toBeUndefined()
const embedBlockedPost = timeline.feed.find(
(item) => item.post.uri === embedBlockedUri,
)
Expand Down