Merge branch 'next-minor' into develop

This commit is contained in:
Dennis Schubert 2018-01-08 21:15:49 +01:00
commit 13d24cc611
No known key found for this signature in database
GPG key ID: 5A0304BEA7966D7E
10 changed files with 110 additions and 14 deletions

View file

@ -9,6 +9,7 @@
# 0.7.3.0 # 0.7.3.0
## Refactor ## 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 ## Bug fixes
* Fix notifications when people remove their birthday date [#7691](https://github.com/diaspora/diaspora/pull/7691) * Fix notifications when people remove their birthday date [#7691](https://github.com/diaspora/diaspora/pull/7691)

View file

@ -36,3 +36,7 @@
max-width: 100%; max-width: 100%;
min-width: 100%; min-width: 100%;
} }
.account-data h6 {
color: $text-grey;
}

View file

@ -539,6 +539,8 @@ class User < ApplicationRecord
:post_default_public].each do |field| :post_default_public].each do |field|
self[field] = false self[field] = false
end end
self.remove_export = true
self.remove_exported_photos_file = true
self[:disable_mail] = true self[:disable_mail] = true
self[:strip_exif] = true self[:strip_exif] = true
self[:email] = "deletedaccount_#{self[:id]}@example.org" 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 attributes.keys - %w(id username encrypted_password created_at updated_at locked_at
serialized_private_key getting_started serialized_private_key getting_started
disable_mail show_community_spotlight_in_stream disable_mail show_community_spotlight_in_stream
strip_exif email remove_after export exporting exported_at strip_exif email remove_after export exporting
exported_photos_file exporting_photos exported_photos_at) exported_photos_file exporting_photos)
end end
end end

View file

@ -181,35 +181,33 @@
%hr %hr
.row .row
.col-md-6#account_data .col-md-6.account-data
%h3= t(".export_data") %h3= t(".export_data")
%h4= t("profile")
.form-group .form-group
- if current_user.exporting - if current_user.exporting
.export-in-progress= t(".export_in_progress") .export-in-progress= t(".export_in_progress")
- elsif current_user.export.present? - elsif current_user.export.present?
= link_to t(".request_export_update"), export_profile_user_path, method: :post,
class: "btn btn-default"
.small-horizontal-spacer
= link_to t(".download_export"), download_profile_user_path, = link_to t(".download_export"), download_profile_user_path,
class: "btn btn-success" class: "btn btn-success"
.small-horizontal-spacer = link_to t(".request_export_update"), export_profile_user_path, method: :post,
class: "btn btn-default"
%h6 %h6
= t(".last_exported_at", timestamp: current_user.exported_at) = t(".last_exported_html", timeago: timeago(current_user.exported_at))
- else - else
= link_to t(".request_export"), export_profile_user_path, method: :post, = link_to t(".request_export"), export_profile_user_path, method: :post,
class: "btn btn-default" class: "btn btn-default"
%h4= t("javascripts.profile.photos")
.form-group .form-group
- if current_user.exporting_photos - if current_user.exporting_photos
.export-in-progress= t(".export_photos_in_progress") .export-in-progress= t(".export_photos_in_progress")
- elsif current_user.exported_photos_file.present? - elsif current_user.exported_photos_file.present?
= link_to t(".download_export_photos"), download_photos_user_path, class: "btn btn-success"
= link_to t(".request_export_photos_update"), export_photos_user_path, method: :post, = link_to t(".request_export_photos_update"), export_photos_user_path, method: :post,
class: "btn btn-default" class: "btn btn-default"
.small-horizontal-spacer
= link_to t(".download_export_photos"), download_photos_user_path, class: "btn btn-success"
.small-horizontal-spacer
%h6 %h6
= t(".last_exported_at", timestamp: current_user.exported_photos_at) = t(".last_exported_html", timeago: timeago(current_user.exported_photos_at))
- else - else
= link_to t(".request_export_photos"), export_photos_user_path, method: :post, = link_to t(".request_export_photos"), export_photos_user_path, method: :post,
class: "btn btn-default" class: "btn btn-default"

View file

@ -0,0 +1,21 @@
# frozen_string_literal: true
module Workers
class CleanupOldExports < Base
sidekiq_options queue: :low
def perform
User.where("exported_at < ?", 14.days.ago).each do |user|
user.remove_export = true
user.exported_at = nil
user.save
end
User.where("exported_photos_at < ?", 14.days.ago).each do |user|
user.remove_exported_photos_file = true
user.exported_photos_at = nil
user.save
end
end
end
end

View file

@ -1228,7 +1228,7 @@ en:
request_export_update: "Refresh my profile data" request_export_update: "Refresh my profile data"
export_data: "Export data" export_data: "Export data"
export_in_progress: "We are currently processing your data. Please check back in a few moments." export_in_progress: "We are currently processing your data. Please check back in a few moments."
last_exported_at: "(Last updated at %{timestamp})" last_exported_html: "(Last updated %{timeago})"
download_export_photos: "Download my photos" download_export_photos: "Download my photos"
request_export_photos: "Request my photos" request_export_photos: "Request my photos"
request_export_photos_update: "Refresh my photos" request_export_photos_update: "Refresh my photos"

View file

@ -17,3 +17,7 @@ recheck_scheduled_pods:
check_birthday: check_birthday:
cron: "0 0 * * *" cron: "0 0 * * *"
class: "Workers::CheckBirthday" class: "Workers::CheckBirthday"
cleanup_old_exports:
cron: "0 0 * * *"
class: "Workers::CleanupOldExports"

View file

@ -55,6 +55,6 @@ Feature: Change settings
Then I should see "Public" within ".aspect-dropdown" Then I should see "Public" within ".aspect-dropdown"
Scenario: exporting profile data Scenario: exporting profile data
When I click on the first selector "#account_data a" When I click on the first selector ".account-data a"
Then I should see "Download my profile" Then I should see "Download my profile"
And I should have 1 email delivery And I should have 1 email delivery

View file

@ -944,6 +944,17 @@ describe User, :type => :model do
expect(@user.reload.show_community_spotlight_in_stream).to be false expect(@user.reload.show_community_spotlight_in_stream).to be false
expect(@user.reload.post_default_public).to be false expect(@user.reload.post_default_public).to be false
end 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 end
describe "#clearable_attributes" do describe "#clearable_attributes" do
@ -970,6 +981,8 @@ describe User, :type => :model do
last_seen last_seen
color_theme color_theme
post_default_public post_default_public
exported_at
exported_photos_at
) )
) )
end end

View file

@ -0,0 +1,53 @@
# frozen_string_literal: true
describe Workers::CleanupOldExports do
let(:user) { FactoryGirl.create(:user) }
context "with profile data" do
before do
user.perform_export!
end
it "removes old archives" do
Timecop.travel(Time.zone.today + 15.days) do
Workers::CleanupOldExports.new.perform
user.reload
expect(user.export).not_to be_present
expect(user.exported_at).to be_nil
end
end
it "does not remove new archives" do
Timecop.travel(Time.zone.today + 1.day) do
Workers::CleanupOldExports.new.perform
user.reload
expect(user.export).to be_present
expect(user.exported_at).to be_present
end
end
end
context "with photos" do
before do
user.perform_export_photos!
end
it "removes old archives" do
Timecop.travel(Time.zone.today + 15.days) do
Workers::CleanupOldExports.new.perform
user.reload
expect(user.exported_photos_file).not_to be_present
expect(user.exported_photos_at).to be_nil
end
end
it "does not remove new archives" do
Timecop.travel(Time.zone.today + 1.day) do
Workers::CleanupOldExports.new.perform
user.reload
expect(user.exported_photos_file).to be_present
expect(user.exported_photos_at).to be_present
end
end
end
end