From 023df213f761f3494fe3107f9b3774213d931dc8 Mon Sep 17 00:00:00 2001 From: Jordan Killpack Date: Tue, 9 Nov 2021 15:33:17 -0500 Subject: [PATCH] Defederate post when :local_only: emoji is present in its spoiler text --- app/services/post_status_service.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 76cc9241b..cfcfcb87f 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -87,10 +87,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? @@ -184,7 +185,7 @@ class PostStatusService < BaseService language: language_from_option(@options[:language]) || @account.user&.setting_default_language&.presence || LanguageDetector.instance.detect(@text, @account), 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