Raise sensible error message when user is missing
That's for the case when podmin has messed up the database
This commit is contained in:
parent
f212b51f7f
commit
973e9d98c6
2 changed files with 11 additions and 0 deletions
|
|
@ -34,6 +34,7 @@ class User
|
||||||
logger.info "event=disconnect user=#{diaspora_handle} target=#{contact.person.diaspora_handle}"
|
logger.info "event=disconnect user=#{diaspora_handle} target=#{contact.person.diaspora_handle}"
|
||||||
|
|
||||||
if contact.person.local?
|
if contact.person.local?
|
||||||
|
raise "FATAL: user entry is missing from the DB. Aborting" if contact.person.owner.nil?
|
||||||
contact.person.owner.disconnected_by(contact.user.person)
|
contact.person.owner.disconnected_by(contact.user.person)
|
||||||
else
|
else
|
||||||
ContactRetraction.for(contact).defer_dispatch(self)
|
ContactRetraction.for(contact).defer_dispatch(self)
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,16 @@ describe User::Connecting, type: :model do
|
||||||
alice.disconnect(contact)
|
alice.disconnect(contact)
|
||||||
}.to change(contact.aspects, :count).from(2).to(0)
|
}.to change(contact.aspects, :count).from(2).to(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "raises when a contact for an improperly deleted user was passed" do
|
||||||
|
contact = alice.contact_for(bob.person)
|
||||||
|
|
||||||
|
bob.delete
|
||||||
|
expect {
|
||||||
|
alice.disconnect(contact)
|
||||||
|
}.to raise_error "FATAL: user entry is missing from the DB. Aborting"
|
||||||
|
expect(Contact.where(id: contact.id)).to exist
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue