diaspora should send AccountMigration message back when a federation message received for a moved account

I use Senya's Patch for this
The extra check is for satisfying tests, which don't create real database objects.

fixes #7902
closes #8288
This commit is contained in:
Thorsten Claus 2021-09-04 19:20:29 +02:00 committed by Benjamin Neff
parent 8f9ac33649
commit 2a99cc93ba
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
3 changed files with 18 additions and 4 deletions

View file

@ -15,6 +15,7 @@
* 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

View file

@ -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

View file

@ -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 = FactoryGirl.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 = FactoryGirl.create(:status_message)
recipient_id = FactoryGirl.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