0
0
Fork 0

Mute button progress so far. WIP, doesn't entirely work correctly.

This commit is contained in:
Kit Redgrave 2017-02-05 19:51:56 -06:00
parent 89fc2d7f48
commit 442fdbfc53
26 changed files with 390 additions and 33 deletions

View file

@ -103,7 +103,10 @@ class Status < ApplicationRecord
class << self
def as_home_timeline(account)
where(account: [account] + account.following)
muted = Mute.where(account: account).pluck(:target_account_id)
query = where(account: [account] + account.following)
query = query.where('statuses.account_id NOT IN (?)', muted) unless muted.empty?
query
end
def as_public_timeline(account = nil, local_only = false)
@ -169,8 +172,10 @@ class Status < ApplicationRecord
def filter_timeline(query, account)
blocked = Block.where(account: account).pluck(:target_account_id) + Block.where(target_account: account).pluck(:account_id)
query = query.where('statuses.account_id NOT IN (?)', blocked) unless blocked.empty?
query = query.where('accounts.silenced = TRUE') if account.silenced?
muted = Mute.where(account: account).pluck(:target_account_id)
query = query.where('statuses.account_id NOT IN (?)', blocked) unless blocked.empty? # Only give us statuses from people we haven't blocked
query = query.where('statuses.account_id NOT IN (?)', muted) unless muted.empty? # and out of those, only people we haven't muted
query = query.where('accounts.silenced = TRUE') if account.silenced? # and if we're hellbanned, only people who are also hellbanned
query
end
@ -192,6 +197,6 @@ class Status < ApplicationRecord
private
def filter_from_context?(status, account)
account&.blocking?(status.account_id) || (status.account.silenced? && !account&.following?(status.account_id)) || !status.permitted?(account)
account&.blocking?(status.account_id) || account&.muting?(status.account_id) || (status.account.silenced? && !account&.following?(status.account_id)) || !status.permitted?(account)
end
end