diff --git a/Changelog.md b/Changelog.md index 72f8b56cd..200a6aa65 100644 --- a/Changelog.md +++ b/Changelog.md @@ -53,6 +53,7 @@ Although the chat was never enabled per default and was marked as experimental, * Add blocks to the archive export [#8263](https://github.com/diaspora/diaspora/pull/8263) * Allow points and dashes in the username [#8266](https://github.com/diaspora/diaspora/pull/8266) * Add support for footnotes in markdown [#8277](https://github.com/diaspora/diaspora/pull/8277) +* Send `AccountMigration` if receiving message to a migrated account [#8288](https://github.com/diaspora/diaspora/pull/8288) # 0.7.15.0 diff --git a/config/initializers/diaspora_federation.rb b/config/initializers/diaspora_federation.rb index ca3c9636c..4ce8ac96e 100644 --- a/config/initializers/diaspora_federation.rb +++ b/config/initializers/diaspora_federation.rb @@ -104,6 +104,17 @@ DiasporaFederation.configure do |config| on :receive_entity do |entity, sender, recipient_id| Person.by_account_identifier(sender).pod.try(:schedule_check_if_needed) + unless recipient_id.nil? + User.find_by(id: recipient_id).tap do |user| + next unless user.person.account_migration + + Diaspora::Federation::Dispatcher.build( + user, + user.person.account_migration, + subscribers: [Person.by_account_identifier(sender)] + ).dispatch + end + end case entity when DiasporaFederation::Entities::AccountDeletion diff --git a/spec/federation_callbacks_spec.rb b/spec/federation_callbacks_spec.rb index 923a425d9..346f84d30 100644 --- a/spec/federation_callbacks_spec.rb +++ b/spec/federation_callbacks_spec.rb @@ -354,11 +354,12 @@ describe "diaspora federation callbacks" do it "receives a Retraction" do retraction = Fabricate(:retraction_entity, author: remote_person.diaspora_handle) + recipient_id = FactoryBot.create(:user).id - expect(Diaspora::Federation::Receive).to receive(:retraction).with(retraction, 42) + expect(Diaspora::Federation::Receive).to receive(:retraction).with(retraction, recipient_id) expect(Workers::ReceiveLocal).not_to receive(:perform_async) - DiasporaFederation.callbacks.trigger(:receive_entity, retraction, retraction.author, 42) + DiasporaFederation.callbacks.trigger(:receive_entity, retraction, retraction.author, recipient_id) end it "receives a entity" do @@ -386,11 +387,12 @@ describe "diaspora federation callbacks" do it "receives a entity for a recipient" do received = Fabricate(:status_message_entity, author: remote_person.diaspora_handle) persisted = FactoryBot.create(:status_message) + recipient_id = FactoryBot.create(:user).id expect(Diaspora::Federation::Receive).to receive(:perform).with(received).and_return(persisted) - expect(Workers::ReceiveLocal).to receive(:perform_async).with(persisted.class.to_s, persisted.id, [42]) + expect(Workers::ReceiveLocal).to receive(:perform_async).with(persisted.class.to_s, persisted.id, [recipient_id]) - DiasporaFederation.callbacks.trigger(:receive_entity, received, received.author, 42) + DiasporaFederation.callbacks.trigger(:receive_entity, received, received.author, recipient_id) end it "does not trigger a ReceiveLocal job if Receive.perform returned nil" do