Skip to content

Fix threaded replies to non-federated statuses not being filtered from the timeline#4177

Closed
nightpool wants to merge 4 commits intomastodon:masterfrom
nightpool:fix_reply_to_nil
Closed

Fix threaded replies to non-federated statuses not being filtered from the timeline#4177
nightpool wants to merge 4 commits intomastodon:masterfrom
nightpool:fix_reply_to_nil

Conversation

@nightpool
Copy link
Copy Markdown
Member

bug discovered by @vahnj. If someone you follow replies to a status your instance doesn't know about, it gets filtered. but if they continue replying in that thread, further replies don't get filtered. This adds logic to cover that edge case.

This also refactors the feed manager code because it's super out of date, and doens't use the account interaction maps. (lots of Follow.where(target_id: blah, account_id: blah))

@nightpool
Copy link
Copy Markdown
Member Author

codeclimate won't let me dismiss false positives, but in order:

  • empty line at beginning of method is for docs (not sure if they're useful now that the code is more readable, but they're there)
  • = operator spacing is to align with the +=/||= on the next line

@akihikodaki akihikodaki added the bug Something isn't working label Jul 13, 2017
@akihikodaki
Copy link
Copy Markdown
Contributor

rubocop says line 120, around which there is no +=, has an extra space.

@nightpool
Copy link
Copy Markdown
Member Author

nightpool commented Jul 13, 2017

@akihikodaki fixed

@Gargron
Copy link
Copy Markdown
Member

Gargron commented Jul 13, 2017

See 6fd865c

You're reverting deliberate optimizations - this code is a performance hot spot and we want it to handle as little information as possible, thus passing it an integer and not a full account, and using batched checks for mutes, blocks etc.

If I'm reading correctly the actual fix is the line return true if status.in_reply_to_account.nil? || status.in_reply_to_id.nil?, which in old code would be return true if status.reply? && (status.in_reply_to_account.nil? || status.in_reply_to_id.nil?)

@nightpool
Copy link
Copy Markdown
Member Author

nightpool commented Jul 13, 2017

@Gargron Since that code was written, the performance of muting?, blocking?, and following? have all been changed, and now the two alternatives create identical SQL queries, but one is much more readable and maintainable.

I'm not sure how passing an integer vs. a full account would change the performance in this case at all, seeing as everywhere we call it we are explicitly taking an id from a full activerecord object, and everywhere we compare it we're still using the ID—the only difference is the muting? and blocking? calls.

I also moved the blocking calls to after the "reply?" check for performance reasons (do the easy checks first) but i'm down to revert that if you think it's a bad idea.

Gargron added a commit that referenced this pull request Jul 14, 2017
Gargron added a commit that referenced this pull request Jul 14, 2017
Gargron added a commit that referenced this pull request Jul 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants