0
0
Fork 0

Remove unfollowed hashtag posts from home feed (#26028)

This commit is contained in:
Claire 2023-07-17 13:56:28 +02:00 committed by GitHub
parent f18618d7f9
commit 943f27f437
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 81 additions and 0 deletions

View file

@ -180,6 +180,26 @@ class FeedManager
end
end
# Remove a tag's statuses from a home feed
# @param [Tag] from_tag
# @param [Account] into_account
# @return [void]
def unmerge_tag_from_home(from_tag, into_account)
timeline_key = key(:home, into_account.id)
timeline_status_ids = redis.zrange(timeline_key, 0, -1)
# This is a bit tricky because we need posts tagged with this hashtag that are not
# also tagged with another followed hashtag or from a followed user
scope = from_tag.statuses
.where(id: timeline_status_ids)
.where.not(account: into_account.following)
.tagged_with_none(TagFollow.where(account: into_account).pluck(:tag_id))
scope.select('id, reblog_of_id').reorder(nil).find_each do |status|
remove_from_feed(:home, into_account.id, status, aggregate_reblogs: into_account.user&.aggregates_reblogs?)
end
end
# Clear all statuses from or mentioning target_account from a home feed
# @param [Account] account
# @param [Account] target_account