about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-07 23:20:52 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-07 23:20:52 +0100
commitdbe00a4156952cf0288828435ccda6bbba5d7a6f (patch)
treecf2bbd8184db9b47db1aa62cb4b93c49b7aa90a7 /app
parent0400734df7a38f4b100d601eb8cffd7cd9689c76 (diff)
Improved configuration from ENV, cleaned up timeline filter methods
to be more readable, add extra logging to process feed service
Diffstat (limited to 'app')
-rw-r--r--app/lib/feed_manager.rb22
-rw-r--r--app/services/process_feed_service.rb1
2 files changed, 18 insertions, 5 deletions
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index 86f41cfe9..6a4f0edd6 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -12,8 +12,10 @@ class FeedManager
   def filter?(timeline_type, status, receiver)
     if timeline_type == :home
       filter_from_home?(status, receiver)
-    else
+    elsif timeline_type == :mentions
       filter_from_mentions?(status, receiver)
+    else
+      false
     end
   end
 
@@ -59,13 +61,23 @@ class FeedManager
     $redis
   end
 
-  # Filter status out of the home feed if it is a reply to someone the user doesn't follow
   def filter_from_home?(status, receiver)
-    replied_to_user = status.reply? ? status.thread.try(:account) : nil
-    (status.reply? && !(receiver.id == replied_to_user.id || replied_to_user.id == status.account_id || receiver.following?(replied_to_user))) || (status.reblog? && receiver.blocking?(status.reblog.account))
+    should_filter = false
+
+    if status.reply? && !status.thread.account.nil?                                     # Filter out if it's a reply
+      should_filter = !receiver.following?(status.thread.account)                       # and I'm not following the person it's a reply to
+      should_filter = should_filter && !(receiver.id == status.thread.account_id)       # and it's not a reply to me
+      should_filter = should_filter && !(status.account_id == status.thread.account_id) # and it's not a self-reply
+    elsif status.reblog?                                                                # Filter out a reblog
+      should_filter = receiver.blocking?(status.reblog.account)                         # if I'm blocking the reblogged person
+    end
+
+    should_filter
   end
 
   def filter_from_mentions?(status, receiver)
-    receiver.blocking?(status.account)
+    should_filter = false
+    should_filter = receiver.blocking?(status.account) # Filter if it's from someone I blocked
+    should_filter
   end
 end
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
index e60284d8e..e1125cf05 100644
--- a/app/services/process_feed_service.rb
+++ b/app/services/process_feed_service.rb
@@ -56,6 +56,7 @@ class ProcessFeedService < BaseService
       process_attachments(entry, status)
       process_attachments(entry.xpath('./activity:object', activity: ACTIVITY_NS), status.reblog) if status.reblog?
 
+      Rails.logger.debug "Queuing remote status #{status.id} for distribution"
       DistributionWorker.perform_async(status.id)
       return status
     end