From 71b1d4c694bf9fed1ca6afd3a7561b486f8ef241 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Mon, 21 May 2018 20:21:52 +0200 Subject: [PATCH 1/4] Backend changes to allow handling local-only toots not based on emoji --- app/controllers/api/v1/statuses_controller.rb | 4 +++- app/services/post_status_service.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index 4e7476a848..33b36873c9 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -45,7 +45,8 @@ class Api::V1::StatusesController < Api::BaseController application: doorkeeper_token.application, poll: status_params[:poll], content_type: status_params[:content_type], - idempotency: request.headers['Idempotency-Key']) + idempotency: request.headers['Idempotency-Key'], + local_only: status_params[:local_only]) render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer end @@ -77,6 +78,7 @@ class Api::V1::StatusesController < Api::BaseController :visibility, :scheduled_at, :content_type, + :local_only, media_ids: [], poll: [ :multiple, diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index b364713394..1c151052e8 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -164,6 +164,7 @@ class PostStatusService < BaseService language: language_from_option(@options[:language]) || @account.user&.setting_default_language&.presence || LanguageDetector.instance.detect(@text, @account), application: @options[:application], content_type: @options[:content_type] || @account.user&.setting_default_content_type, + local_only: @options[:local_only], }.compact end From 92109c2cbe6d2a073a871572720d58dec70a0416 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Mon, 21 May 2018 20:33:58 +0200 Subject: [PATCH 2/4] Redesign local-only toots in glitch flavour --- app/javascript/flavours/glitch/actions/compose.js | 4 +--- .../glitch/features/compose/components/compose_form.js | 2 +- app/javascript/flavours/glitch/reducers/compose.js | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js index 2312bae634..27e85f000a 100644 --- a/app/javascript/flavours/glitch/actions/compose.js +++ b/app/javascript/flavours/glitch/actions/compose.js @@ -146,9 +146,6 @@ export function submitCompose(routerHistory) { } dispatch(submitComposeRequest()); - if (getState().getIn(['compose', 'advanced_options', 'do_not_federate'])) { - status = status + ' 👁️'; - } api(getState).post('/api/v1/statuses', { status, content_type: getState().getIn(['compose', 'content_type']), @@ -158,6 +155,7 @@ export function submitCompose(routerHistory) { spoiler_text: spoilerText, visibility: getState().getIn(['compose', 'privacy']), poll: getState().getIn(['compose', 'poll'], null), + local_only: getState().getIn(['compose', 'advanced_options', 'do_not_federate']), }, { headers: { 'Idempotency-Key': getState().getIn(['compose', 'idempotencyKey']), diff --git a/app/javascript/flavours/glitch/features/compose/components/compose_form.js b/app/javascript/flavours/glitch/features/compose/components/compose_form.js index 6e07998ec2..5f0e19e985 100644 --- a/app/javascript/flavours/glitch/features/compose/components/compose_form.js +++ b/app/javascript/flavours/glitch/features/compose/components/compose_form.js @@ -294,7 +294,7 @@ class ComposeForm extends ImmutablePureComponent { let disabledButton = isSubmitting || isUploading || isChangingUpload || (!text.trim().length && !anyMedia); - const countText = `${spoilerText}${countableText(text)}${advancedOptions && advancedOptions.get('do_not_federate') ? ' 👁️' : ''}`; + const countText = `${spoilerText}${countableText(text)}`; return (
diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index 5f176b8325..50174a6e47 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -177,7 +177,7 @@ function continueThread (state, status) { map.set('in_reply_to', status.id); map.update( 'advanced_options', - map => map.merge(new ImmutableMap({ do_not_federate: /👁\ufe0f?\u200b?(?:<\/p>)?$/.test(status.content) })) + map => map.merge(new ImmutableMap({ do_not_federate: !!status.local_only })) ); map.set('privacy', status.visibility); map.set('sensitive', false); @@ -338,7 +338,7 @@ export default function compose(state = initialState, action) { map.set('privacy', privacyPreference(action.status.get('visibility'), state.get('default_privacy'))); map.update( 'advanced_options', - map => map.merge(new ImmutableMap({ do_not_federate: /👁\ufe0f?\u200b?(?:<\/p>)?$/.test(action.status.get('content')) })) + map => map.merge(new ImmutableMap({ do_not_federate: !!action.status.get('local_only') })) ); map.set('focusDate', new Date()); map.set('caretPosition', null); From e9a8bb3d30a28b9906b5c57a438a41d51fddfc24 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 22 May 2018 11:32:21 +0200 Subject: [PATCH 3/4] Don't leak reblogs of local-only toots --- app/models/status.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/status.rb b/app/models/status.rb index de790027d5..c8e01d776a 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -494,6 +494,7 @@ class Status < ApplicationRecord if account.domain.nil? && !attribute_changed?(:local_only) self.local_only = marked_local_only? end + self.local_only = reblog.local_only if reblog? end def set_conversation From 0898ff9c14e6b049bfe081926233c7e03f6e41c3 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Mon, 26 Aug 2019 19:33:00 +0200 Subject: [PATCH 4/4] Set replies to local-only toots as local-only unless explicitly specified otherwise --- app/models/status.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/status.rb b/app/models/status.rb index c8e01d776a..10a1b59a1c 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -492,8 +492,9 @@ class Status < ApplicationRecord def set_locality if account.domain.nil? && !attribute_changed?(:local_only) - self.local_only = marked_local_only? + self.local_only = true if marked_local_only? end + self.local_only = true if thread&.local_only? && self.local_only.nil? self.local_only = reblog.local_only if reblog? end