diff options
author | Kit Redgrave <qwertyitis@gmail.com> | 2017-02-05 19:51:56 -0600 |
---|---|---|
committer | Kit Redgrave <qwertyitis@gmail.com> | 2017-03-01 22:31:21 -0600 |
commit | 442fdbfc5309f46c23a073829e5fe16d10c7c6ca (patch) | |
tree | ee8195e874e83722990cfaca7b65fc54383caaf9 /app/lib | |
parent | 89fc2d7f4810ecdf66b17543f4603c1089a0c3f5 (diff) |
Mute button progress so far. WIP, doesn't entirely work correctly.
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/feed_manager.rb | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index 016ef0235..d52260713 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -22,18 +22,8 @@ class FeedManager end def push(timeline_type, account, status) - timeline_key = key(timeline_type, account.id) - - if status.reblog? - # If the original status is within 40 statuses from top, do not re-insert it into the feed - rank = redis.zrevrank(timeline_key, status.reblog_of_id) - return if !rank.nil? && rank < 40 - redis.zadd(timeline_key, status.id, status.reblog_of_id) - else - redis.zadd(timeline_key, status.id, status.id) - trim(timeline_type, account.id) - end - + redis.zadd(key(timeline_type, account.id), status.id, status.reblog? ? status.reblog_of_id : status.id) + trim(timeline_type, account.id) broadcast(account.id, event: 'update', payload: inline_render(account, 'api/v1/statuses/show', status)) end @@ -95,31 +85,47 @@ class FeedManager end def filter_from_home?(status, receiver) - should_filter = false + should_filter = receiver.muting?(status.account_id) # Filter if I'm muting this person - if status.reply? && status.in_reply_to_id.nil? + if status.reply? && status.in_reply_to_id.nil? # Filter out replies to nobody should_filter = true - elsif status.reply? && !status.in_reply_to_account_id.nil? # Filter out if it's a reply - should_filter = !receiver.following?(status.in_reply_to_account) # and I'm not following the person it's a reply to + elsif status.reply? && !status.in_reply_to_account_id.nil? # If it's a reply + should_filter = !receiver.following?(status.in_reply_to_account) # filter if I'm not following the person it's a reply to should_filter &&= !(receiver.id == status.in_reply_to_account_id) # and it's not a reply to me should_filter &&= !(status.account_id == status.in_reply_to_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 + elsif status.reblog? # If it's a reblog + should_filter = receiver.blocking?(status.reblog.account) # filter if I'm blocking the reblogged person + should_filter ||= receiver.muting?(status.reblog.account) # or if I'm muting the reblogged person end - should_filter ||= receiver.blocking?(status.mentions.map(&:account_id)) # or if it mentions someone I blocked - + should_filter ||= receiver.blocking?(status.mentions.map(&:account_id)) # Filter if it mentions someone I blocked should_filter end def filter_from_mentions?(status, receiver) - should_filter = receiver.id == status.account_id # Filter if I'm mentioning myself + should_filter = receiver.id == status.account_id # Filter out if I'm mentioning myself should_filter ||= receiver.blocking?(status.account) # or it's from someone I blocked should_filter ||= receiver.blocking?(status.mentions.includes(:account).map(&:account)) # or if it mentions someone I blocked should_filter ||= (status.account.silenced? && !receiver.following?(status.account)) # of if the account is silenced and I'm not following them + if status.reply? && !status.in_reply_to_account_id.nil? + should_filter ||= receiver.blocking?(status.in_reply_to_account) # or if it's a reply to a user I blocked + end + + should_filter + end + + def filter_from_public?(status, receiver) + should_filter = receiver.blocking?(status.account) # Filter out if I'm blocking that account + should_filter ||= receiver.muting?(status.account_id) # or if I'm muting this person + should_filter ||= receiver.blocking?(status.mentions.includes(:account).map(&:account)) # or if it mentions someone I blocked + if status.reply? && !status.in_reply_to_account_id.nil? # or it's a reply - should_filter ||= receiver.blocking?(status.in_reply_to_account) # to a user I blocked + should_filter ||= receiver.blocking?(status.in_reply_to_account) # to somebody I've blocked + should_filter ||= receiver.muting?(status.in_reply_to_account) # or to somebody I'm muting + elsif status.reblog? # or if it's a reblog + should_filter ||= receiver.blocking?(status.reblog.account) # if I'm blocking the reblogged person + should_filter ||= receiver.muting?(status.reblog.account) # or if I'm muting the reblogged person end should_filter |