From 1550d43afd871049e8173966a3103fc3225645f9 Mon Sep 17 00:00:00 2001 From: CSDUMMI Date: Sun, 24 Nov 2024 21:48:34 +0100 Subject: [PATCH] Turn local-only threads into a one-way street, making it impossible to reply to a local-only post with a federated status (by accident) --- app/models/status.rb | 2 +- spec/models/status_spec.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/models/status.rb b/app/models/status.rb index 2825ade5247786..13cfc6d3181d7d 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -496,7 +496,7 @@ def set_visibility def set_local_only return unless account.domain.nil? && !attribute_changed?(:local_only) - self.local_only = marked_local_only? + self.local_only = marked_local_only? || thread&.local_only end def set_conversation diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index cd0d32b56ba096..1ee5e199df286c 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -290,6 +290,23 @@ end end end + + describe 'on a status in a local-only thread' do + subject { described_class.new } + + context 'when a status does not contain the local-only emoji' do + let(:thread) { Fabricate(:Status, local_only: true) } + + before do + subject.thread = thread + end + + it 'is marked local-only' do + subject.save! + + expect(subject).to be_local_only + end + end end describe '#reported?' do