Add public_unlisted scope as status privacy

This commit is contained in:
KMY 2023-03-05 13:24:31 +09:00
parent b049e7c502
commit ed3abf4f2a
35 changed files with 64 additions and 39 deletions

View file

@ -3,7 +3,7 @@
module AccountLimitable
def scope_status(status)
case status.visibility.to_sym
when :public, :unlisted
when :public, :unlisted, :public_unlisted
#scope_local.merge(scope_list_following_account(status.account))
scope_local
when :private

View file

@ -41,7 +41,7 @@ class FanOutOnWriteService < BaseService
notify_about_update! if update?
case @status.visibility.to_sym
when :public, :unlisted, :private
when :public, :unlisted, :public_unlisted, :private
deliver_to_all_followers!
deliver_to_lists!
when :limited

View file

@ -65,7 +65,7 @@ class PostStatusService < BaseService
@sensitive = (@options[:sensitive].nil? ? @account.user&.setting_default_sensitive : @options[:sensitive]) || @options[:spoiler_text].present?
@text = @options.delete(:spoiler_text) if @text.blank? && @options[:spoiler_text].present?
@visibility = @options[:visibility] || @account.user&.setting_default_privacy
@visibility = :unlisted if @visibility&.to_sym == :public && @account.silenced?
@visibility = :unlisted if (@visibility&.to_sym == :public || @visibility&.to_sym == :public_unlisted) && @account.silenced?
@scheduled_at = @options[:scheduled_at]&.to_datetime
@scheduled_at = nil if scheduled_in_the_past?
rescue ArgumentError

View file

@ -62,7 +62,7 @@ class ReportService < BaseService
# If the account making reports is remote, it is likely anonymized so we have to relax the requirements for attaching statuses.
domain = @source_account.domain.to_s.downcase
has_followers = @target_account.followers.where(Account.arel_table[:domain].lower.eq(domain)).exists?
visibility = has_followers ? %i(public unlisted private) : %i(public unlisted)
visibility = has_followers ? %i(public unlisted public_unlisted private) : %i(public unlisted public_unlisted)
scope = @target_account.statuses.with_discarded
scope.merge!(scope.where(visibility: visibility).or(scope.where('EXISTS (SELECT 1 FROM mentions m JOIN accounts a ON m.account_id = a.id WHERE lower(a.domain) = ?)', domain)))
# Allow missing posts to not drop reports that include e.g. a deleted post

View file

@ -6,7 +6,7 @@ class TranslateStatusService < BaseService
include FormattingHelper
def call(status, target_language)
raise Mastodon::NotPermittedError unless status.public_visibility? || status.unlisted_visibility?
raise Mastodon::NotPermittedError unless status.public_visibility? || status.unlisted_visibility? || status.public_unlisted_visibility?
@status = status
@content = status_content_format(@status)