From fc1f2491291095dd0399386abd035bad9ae95d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Mon, 26 May 2014 23:54:40 +0200 Subject: Harden account deletion * Wrap it into a transaction * Use destroy over delete so dependent destroys get triggered and we thus don't fail on the foreign key constraits * Check if a photos status message actually exists before accessing it * Add missing dependent destroys --- lib/account_deleter.rb | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'lib/account_deleter.rb') diff --git a/lib/account_deleter.rb b/lib/account_deleter.rb index 314201f92..3d869ea8a 100644 --- a/lib/account_deleter.rb +++ b/lib/account_deleter.rb @@ -23,20 +23,22 @@ class AccountDeleter end def perform! - #person - delete_standard_person_associations - remove_conversation_visibilities - remove_share_visibilities_on_persons_posts - delete_contacts_of_me - tombstone_person_and_profile - - if self.user - #user deletion methods - remove_share_visibilities_on_contacts_posts - delete_standard_user_associations - disassociate_invitations - disconnect_contacts - tombstone_user + ActiveRecord::Base.transaction do + #person + delete_standard_person_associations + remove_conversation_visibilities + remove_share_visibilities_on_persons_posts + delete_contacts_of_me + tombstone_person_and_profile + + if self.user + #user deletion methods + remove_share_visibilities_on_contacts_posts + delete_standard_user_associations + disassociate_invitations + disconnect_contacts + tombstone_user + end end end @@ -55,13 +57,13 @@ class AccountDeleter def delete_standard_user_associations normal_ar_user_associates_to_delete.each do |asso| - self.user.send(asso).each{|model| model.delete} + self.user.send(asso).each{|model| model.destroy } end end def delete_standard_person_associations normal_ar_person_associates_to_delete.each do |asso| - self.person.send(asso).delete_all + self.person.send(asso).destroy_all end end -- cgit v1.2.3