FIX: deleting staged user of rejected email shouldn't delete incoming email
This commit is contained in:
parent
8c27f28dcb
commit
880d154381
|
@ -756,7 +756,13 @@ module Email
|
|||
|
||||
def delete_staged_users
|
||||
@staged_users.each do |user|
|
||||
UserDestroyer.new(Discourse.system_user).destroy(user, quiet: true) if user.posts.count == 0
|
||||
if @incoming_email.user.id == user.id
|
||||
@incoming_email.update_columns(user_id: nil)
|
||||
end
|
||||
|
||||
if user.posts.count == 0
|
||||
UserDestroyer.new(Discourse.system_user).destroy(user, quiet: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -760,6 +760,11 @@ describe Email::Receiver do
|
|||
end
|
||||
end
|
||||
|
||||
it "does not remove the incoming email record when staged users are deleted" do
|
||||
expect { process(:bad_destinations) }.to change { IncomingEmail.count }
|
||||
.and raise_error(Email::Receiver::BadDestinationAddress)
|
||||
expect(IncomingEmail.last.message_id).to eq("9@foo.bar.mail")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue