From 0347507b2030e17889f90c810c3e224487beb9ef Mon Sep 17 00:00:00 2001 From: Janakas Date: Thu, 28 Dec 2017 23:04:06 +0100 Subject: [PATCH] Delete archive files when closing an account closes #7684 --- Changelog.md | 1 + app/models/user.rb | 6 ++++-- spec/models/user_spec.rb | 13 +++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 5703fe50b..60c8b62f1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ # 0.7.3.0 ## Refactor +* Work on the data downloads: Fixed general layout of buttons, added a timestamp and implemented auto-deletion of old exports [#7684](https://github.com/diaspora/diaspora/pull/7684) ## Bug fixes * Fix notifications when people remove their birthday date [#7691](https://github.com/diaspora/diaspora/pull/7691) diff --git a/app/models/user.rb b/app/models/user.rb index ac16de682..e6fa252be 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -539,6 +539,8 @@ class User < ApplicationRecord :post_default_public].each do |field| self[field] = false end + self.remove_export = true + self.remove_exported_photos_file = true self[:disable_mail] = true self[:strip_exif] = true self[:email] = "deletedaccount_#{self[:id]}@example.org" @@ -579,7 +581,7 @@ class User < ApplicationRecord attributes.keys - %w(id username encrypted_password created_at updated_at locked_at serialized_private_key getting_started disable_mail show_community_spotlight_in_stream - strip_exif email remove_after export exporting exported_at - exported_photos_file exporting_photos exported_photos_at) + strip_exif email remove_after export exporting + exported_photos_file exporting_photos) end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 913e3c735..d264493a8 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -944,6 +944,17 @@ describe User, :type => :model do expect(@user.reload.show_community_spotlight_in_stream).to be false expect(@user.reload.post_default_public).to be false end + + it "removes export archives" do + @user.perform_export! + @user.perform_export_photos! + @user.clear_account! + @user.reload + expect(@user.export).not_to be_present + expect(@user.exported_at).to be_nil + expect(@user.exported_photos_file).not_to be_present + expect(@user.exported_photos_at).to be_nil + end end describe "#clearable_attributes" do @@ -970,6 +981,8 @@ describe User, :type => :model do last_seen color_theme post_default_public + exported_at + exported_photos_at ) ) end