Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJonne Haß <me@mrzyx.de>2014-05-27 01:54:40 +0400
committerJonne Haß <me@mrzyx.de>2014-05-27 02:15:15 +0400
commitfc1f2491291095dd0399386abd035bad9ae95d6a (patch)
tree1841390573725d1c59a745efcfc67ef37ea98a97 /lib
parent1e09814b13e8145d6df897fca5383e35f14a2727 (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/account_deleter.rb34
-rw-r--r--lib/tasks/accounts.rake4
2 files changed, 20 insertions, 18 deletions
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
diff --git a/lib/tasks/accounts.rake b/lib/tasks/accounts.rake
index 1fcfbb553..91bfd7a02 100644
--- a/lib/tasks/accounts.rake
+++ b/lib/tasks/accounts.rake
@@ -7,9 +7,9 @@ namespace :accounts do
account_delete.perform!
end
puts "OK."
+ else
+ puts "No acccount deletions to run."
end
-
- puts "No acccount deletions to run."
end
end