Add scope Status.distributable_visibility
(#29950)
This commit is contained in:
parent
0622107449
commit
caad1e2628
9 changed files with 9 additions and 8 deletions
|
@ -46,7 +46,7 @@ class AccountsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_statuses
|
def default_statuses
|
||||||
@account.statuses.where(visibility: [:public, :unlisted])
|
@account.statuses.distributable_visibility
|
||||||
end
|
end
|
||||||
|
|
||||||
def only_media_scope
|
def only_media_scope
|
||||||
|
|
|
@ -31,7 +31,7 @@ class ActivityPub::RepliesController < ActivityPub::BaseController
|
||||||
|
|
||||||
def set_replies
|
def set_replies
|
||||||
@replies = only_other_accounts? ? Status.where.not(account_id: @account.id).joins(:account).merge(Account.without_suspended) : @account.statuses
|
@replies = only_other_accounts? ? Status.where.not(account_id: @account.id).joins(:account).merge(Account.without_suspended) : @account.statuses
|
||||||
@replies = @replies.where(in_reply_to_id: @status.id, visibility: [:public, :unlisted])
|
@replies = @replies.distributable_visibility.where(in_reply_to_id: @status.id)
|
||||||
@replies = @replies.paginate_by_min_id(DESCENDANTS_LIMIT, params[:min_id])
|
@replies = @replies.paginate_by_min_id(DESCENDANTS_LIMIT, params[:min_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class Api::V1::Statuses::RebloggedByAccountsController < Api::V1::Statuses::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def paginated_statuses
|
def paginated_statuses
|
||||||
Status.where(reblog_of_id: @status.id).where(visibility: [:public, :unlisted]).paginate_by_max_id(
|
Status.where(reblog_of_id: @status.id).distributable_visibility.paginate_by_max_id(
|
||||||
limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
||||||
params[:max_id],
|
params[:max_id],
|
||||||
params[:since_id]
|
params[:since_id]
|
||||||
|
|
|
@ -35,7 +35,7 @@ class AccountStatusesFilter
|
||||||
return Status.none if account.unavailable?
|
return Status.none if account.unavailable?
|
||||||
|
|
||||||
if anonymous?
|
if anonymous?
|
||||||
account.statuses.where(visibility: %i(public unlisted))
|
account.statuses.distributable_visibility
|
||||||
elsif author?
|
elsif author?
|
||||||
account.statuses.all # NOTE: #merge! does not work without the #all
|
account.statuses.all # NOTE: #merge! does not work without the #all
|
||||||
elsif blocked?
|
elsif blocked?
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Admin::StatusFilter
|
||||||
end
|
end
|
||||||
|
|
||||||
def results
|
def results
|
||||||
scope = @account.statuses.where(visibility: [:public, :unlisted])
|
scope = @account.statuses.distributable_visibility
|
||||||
|
|
||||||
params.each do |key, value|
|
params.each do |key, value|
|
||||||
next if IGNORED_PARAMS.include?(key.to_s)
|
next if IGNORED_PARAMS.include?(key.to_s)
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Announcement < ApplicationRecord
|
||||||
@statuses ||= if status_ids.nil?
|
@statuses ||= if status_ids.nil?
|
||||||
[]
|
[]
|
||||||
else
|
else
|
||||||
Status.where(id: status_ids, visibility: [:public, :unlisted])
|
Status.where(id: status_ids).distributable_visibility
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Status::ThreadingConcern
|
||||||
end
|
end
|
||||||
|
|
||||||
def self_replies(limit)
|
def self_replies(limit)
|
||||||
account.statuses.where(in_reply_to_id: id, visibility: [:public, :unlisted]).reorder(id: :asc).limit(limit)
|
account.statuses.distributable_visibility.where(in_reply_to_id: id).reorder(id: :asc).limit(limit)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -74,6 +74,6 @@ class FeaturedTag < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible_tagged_account_statuses
|
def visible_tagged_account_statuses
|
||||||
account.statuses.where(visibility: %i(public unlisted)).tagged_with(tag)
|
account.statuses.distributable_visibility.tagged_with(tag)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -121,6 +121,7 @@ class Status < ApplicationRecord
|
||||||
scope :tagged_with_none, lambda { |tag_ids|
|
scope :tagged_with_none, lambda { |tag_ids|
|
||||||
where('NOT EXISTS (SELECT * FROM statuses_tags forbidden WHERE forbidden.status_id = statuses.id AND forbidden.tag_id IN (?))', tag_ids)
|
where('NOT EXISTS (SELECT * FROM statuses_tags forbidden WHERE forbidden.status_id = statuses.id AND forbidden.tag_id IN (?))', tag_ids)
|
||||||
}
|
}
|
||||||
|
scope :distributable_visibility, -> { where(visibility: %i(public unlisted)) }
|
||||||
scope :list_eligible_visibility, -> { where(visibility: %i(public unlisted private)) }
|
scope :list_eligible_visibility, -> { where(visibility: %i(public unlisted private)) }
|
||||||
|
|
||||||
after_create_commit :trigger_create_webhooks
|
after_create_commit :trigger_create_webhooks
|
||||||
|
|
Loading…
Reference in a new issue