about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-10-02 15:28:47 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-10-02 15:28:47 +0200
commitbe86d4e0a3c40e95648971bc9b0fe58c58cbc5da (patch)
treef00b24db4b12d8e5254d71a0b5734008916c0d53 /app
parent1fce687f8e03d78b4b842422fc6621bba439e1cd (diff)
Preparing feeds for better filtering
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/components.scss1
-rw-r--r--app/lib/feed_manager.rb20
-rw-r--r--app/services/fan_out_on_write_service.rb4
-rw-r--r--app/services/precompute_feed_service.rb2
4 files changed, 20 insertions, 7 deletions
diff --git a/app/assets/stylesheets/components.scss b/app/assets/stylesheets/components.scss
index fa11f94ab..7c111e04a 100644
--- a/app/assets/stylesheets/components.scss
+++ b/app/assets/stylesheets/components.scss
@@ -24,6 +24,7 @@
 
   &:disabled {
     background-color: #9baec8;
+    cursor: default;
   }
 
   &.button-secondary {
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index 6e6df0359..779a31f0b 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -9,10 +9,12 @@ class FeedManager
     "feed:#{type}:#{id}"
   end
 
-  # Filter status out of the home feed if it is a reply to someone the user doesn't follow
-  def filter_status?(status, follower)
-    replied_to_user = status.reply? ? status.thread.account : nil
-    (status.reply? && !(follower.id == replied_to_user.id || replied_to_user.id == status.account_id || follower.following?(replied_to_user)))
+  def filter?(timeline_type, status, receiver)
+    if timeline_type == :home
+      filter_from_home?(status, receiver)
+    else
+      filter_from_mentions?(status, receiver)
+    end
   end
 
   def push(timeline_type, account, status)
@@ -37,6 +39,16 @@ 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, follower)
+    replied_to_user = status.reply? ? status.thread.account : nil
+    (status.reply? && !(follower.id == replied_to_user.id || replied_to_user.id == status.account_id || follower.following?(replied_to_user)))
+  end
+
+  def filter_from_mentions?(status, follower)
+    false
+  end
+
   def inline_render(target_account, status)
     rabl_scope = Class.new do
       include RoutingHelper
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb
index 2d18709d6..29b093ef8 100644
--- a/app/services/fan_out_on_write_service.rb
+++ b/app/services/fan_out_on_write_service.rb
@@ -15,7 +15,7 @@ class FanOutOnWriteService < BaseService
 
   def deliver_to_followers(status)
     status.account.followers.each do |follower|
-      next if !follower.local? || FeedManager.instance.filter_status?(status, follower)
+      next if !follower.local? || FeedManager.instance.filter?(:home, status, follower)
       FeedManager.instance.push(:home, follower, status)
     end
   end
@@ -23,7 +23,7 @@ class FanOutOnWriteService < BaseService
   def deliver_to_mentioned(status)
     status.mentions.each do |mention|
       mentioned_account = mention.account
-      next if !mentioned_account.local? || mentioned_account.id == status.account_id
+      next if !mentioned_account.local? || mentioned_account.id == status.account_id || FeedManager.instance.filter?(:mentions, status, mentioned_account)
       FeedManager.instance.push(:mentions, mentioned_account, status)
     end
   end
diff --git a/app/services/precompute_feed_service.rb b/app/services/precompute_feed_service.rb
index 84d655437..cdeb4a92f 100644
--- a/app/services/precompute_feed_service.rb
+++ b/app/services/precompute_feed_service.rb
@@ -7,7 +7,7 @@ class PrecomputeFeedService < BaseService
     instant_return = []
 
     Status.send("as_#{type}_timeline", account).order('created_at desc').limit(FeedManager::MAX_ITEMS).find_each do |status|
-      next if type == :home && FeedManager.instance.filter_status?(status, account)
+      next FeedManager.instance.filter?(type, status, account)
       redis.zadd(FeedManager.instance.key(type, account.id), status.id, status.id)
       instant_return << status unless instant_return.size > limit
     end