diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-08-17 02:05:55 -0500 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-08-30 05:45:18 -0500 |
commit | 5adfd2fc435469624dd42f0917de7bc9475a1daa (patch) | |
tree | a18b2ecbf463a605b1898248a2ad6217db356a03 | |
parent | 3693792e7653a5e9a4462a55f5d149a4570d18fb (diff) |
[Revise] Clean up feed filter code slightly
-rw-r--r-- | app/lib/feed_manager.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index 88fa592a7..c62f4d82f 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -77,6 +77,7 @@ class FeedManager def push_to_direct(account, status) return false unless add_to_feed(:direct, account.id, status) + trim(:direct, account.id) PushUpdateWorker.perform_async(account.id, status.id, "timeline:direct:#{account.id}") true @@ -84,6 +85,7 @@ class FeedManager def unpush_from_direct(account, status) return false unless remove_from_feed(:direct, account.id, status) + redis.publish("timeline:direct:#{account.id}", Oj.dump(event: :delete, payload: status.id.to_s)) end @@ -224,6 +226,7 @@ class FeedManager statuses.each do |status| next if filter_from_direct?(status, account) + added += 1 if add_to_feed(:direct, account.id, status) end @@ -245,20 +248,25 @@ class FeedManager end def filter_from_home?(status, receiver_id, crutches, filter_options) + conversation = status.conversation + reblog_conversation = status.reblog&.conversation return false if receiver_id == status.account_id - return true unless status.published? && (status.conversation&.public? || status.conversation&.account_id == receiver_id || crutches[:following][status.conversation&.account_id]) + return true if conversation.blank? + return true unless status.published? && (conversation.public? || conversation.account_id == receiver_id || crutches[:following][conversation.account_id]) return true if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?) return true if phrase_filtered?(status, receiver_id, :home) check_for_blocks = crutches[:active_mentions][status.id] || [] check_for_blocks.concat([status.account_id]) - check_for_blocks.concat([status.conversation.account_id]) unless status.conversation&.account_id.nil? + check_for_blocks.concat([conversation.account_id]) unless conversation.account_id.nil? check_for_blocks.concat([status.in_reply_to_account_id]) if status.reply? if status.reblog? + return true if reblog_conversation.blank? + check_for_blocks.concat([status.reblog.account_id]) check_for_blocks.concat(crutches[:active_mentions][status.reblog_of_id] || []) - check_for_blocks.concat([status.reblog.conversation.account_id]) unless status.reblog.conversation&.account_id.nil? + check_for_blocks.concat([reblog_conversation.account_id]) unless reblog_conversation.account_id.nil? check_for_blocks.concat([status.reblog.in_reply_to_account_id]) if status.reblog.reply? end @@ -266,10 +274,10 @@ class FeedManager if status.reply? && !status.in_reply_to_account_id.nil? should_filter = receiver_id != status.in_reply_to_account_id - should_filter &&= receiver_id != status.conversation&.account_id + should_filter &&= receiver_id != conversation.account_id should_filter &&= status.account_id != status.in_reply_to_account_id should_filter &&= if filter_options[:to_unknown] - !(crutches[:following][status.in_reply_to_account_id] && crutches[:following][status.conversation&.account_id]) + !(crutches[:following][status.in_reply_to_account_id] && crutches[:following][conversation.account_id]) else !crutches[:following][status.in_reply_to_account_id] end @@ -279,7 +287,7 @@ class FeedManager should_filter = status.reblog.reply? should_filter &&= status.reblog.account_id != status.reblog.in_reply_to_account_id should_filter &&= if filter_options[:to_unknown] - !(crutches[:following][status.reblog.in_reply_to_account_id] && crutches[:following][status.reblog.conversation&.account_id]) + !(crutches[:following][status.reblog.in_reply_to_account_id] && crutches[:following][reblog_conversation.account_id]) else !crutches[:following][status.reblog.in_reply_to_account_id] end @@ -313,6 +321,7 @@ class FeedManager def filter_from_direct?(status, receiver_id) return false if receiver_id == status.account_id + filter_from_mentions?(status, receiver_id) end |