From 1a6e1dd8046c72054426de52491a4b70f1fd4719 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Wed, 12 Aug 2020 10:34:35 -0700 Subject: [PATCH] Custom emoji forces a post to be local-only This is to better support third-party clients. Appending the :local_only: emoji (or just the text `:local_only:` if that emoji is not set on the server) will make any post into a local-only, unfederated post. Admins are encouraged to pick something fun and/or unintrusive (think a nearly-transparent png) as the emoji. --- app/services/post_status_service.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 0fd68ebc7..c9ed8aede 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -87,7 +87,12 @@ class PostStatusService < BaseService end end - def local_only_option(local_only, in_reply_to, federation_setting) + def local_only_option(local_only, in_reply_to, federation_setting, 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:" + return true + end if local_only.nil? if in_reply_to && in_reply_to.local_only return true @@ -178,7 +183,7 @@ class PostStatusService < BaseService visibility: @visibility, language: language_from_option(@options[:language]) || @account.user&.setting_default_language&.presence || LanguageDetector.instance.detect(@text, @account), application: @options[:application], - local_only: local_only_option(@options[:local_only], @in_reply_to, @account.user&.setting_default_federation), + local_only: local_only_option(@options[:local_only], @in_reply_to, @account.user&.setting_default_federation, @text), rate_limit: @options[:with_rate_limit], }.compact end