Merge pull request #1144 from killpack/local_only_in_cw

Fix posts incorrectly federating when :local_only: emoji is present in spoiler text
This commit is contained in:
Darius Kazemi 2022-05-08 11:01:13 -07:00 committed by GitHub
commit a26084e29c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -91,10 +91,11 @@ class PostStatusService < BaseService
end
end
def local_only_option(local_only, in_reply_to, federation_setting, text)
def local_only_option(local_only, in_reply_to, federation_setting, text, spoiler_text)
# This is intended for third party clients. The admin can set a custom :local_only:
# emoji that users can append to force a post to be local only.
if text.include? ":local_only:"
if text.include?(':local_only:') ||
spoiler_text&.include?(':local_only')
return true
end
if local_only.nil?
@ -189,7 +190,7 @@ class PostStatusService < BaseService
language: valid_locale_cascade(@options[:language], @account.user&.preferred_posting_language, I18n.default_locale),
application: @options[:application],
rate_limit: @options[:with_rate_limit],
local_only: local_only_option(@options[:local_only], @in_reply_to, @account.user&.setting_default_federation, @text),
local_only: local_only_option(@options[:local_only], @in_reply_to, @account.user&.setting_default_federation, @text, @options[:spoiler_text]),
}.compact
end