Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVE] Adds link to download generated user data file #14175

Merged
merged 5 commits into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/ui-account/client/accountPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,15 @@ Template.accountPreferences.onCreated(function() {

if (results.exportOperation) {
if (results.exportOperation.status === 'completed') {
const text = results.url
? TAPi18n.__('UserDataDownload_CompletedRequestExistedWithLink_Text', { download_link: results.url })
: t('UserDataDownload_CompletedRequestExisted_Text');

modal.open({
title: t('UserDataDownload_Requested'),
text: t('UserDataDownload_CompletedRequestExisted_Text'),
text,
type: 'success',
html: true,
});

return true;
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3084,6 +3084,7 @@
"UserData_ProcessingFrequency": "Processing Frequency (Minutes)",
"UserDataDownload": "User Data Download",
"UserDataDownload_CompletedRequestExisted_Text": "Your data file was already generated. Check your email account for the download link.",
"UserDataDownload_CompletedRequestExistedWithLink_Text": "Your data file was already generated. Click <a href=\"__download_link__\" target=\"_blank\">here</a> to download it.",
"UserDataDownload_EmailBody": "Your data file is now ready to download. Click <a href=\"__download_link__\">here</a> to download it.",
"UserDataDownload_EmailSubject": "Your Data File is Ready to Download",
"UserDataDownload_Requested": "Download File Requested",
Expand Down
15 changes: 14 additions & 1 deletion server/methods/requestDataDownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';

import { Meteor } from 'meteor/meteor';

import { ExportOperations } from '../../app/models';
import { ExportOperations, UserDataFiles } from '../../app/models';
import { settings } from '../../app/settings';

let tempFolder = '/tmp/userData';
Expand All @@ -25,9 +25,21 @@ Meteor.methods({
yesterday.setUTCDate(yesterday.getUTCDate() - 1);

if (lastOperation.createdAt > yesterday) {
if (lastOperation.status === 'completed') {
const lastFile = UserDataFiles.findLastFileByUser(userId);
if (lastFile) {
return {
requested: false,
exportOperation: lastOperation,
url: lastFile.url,
};
}
}

return {
requested: false,
exportOperation: lastOperation,
url: null,
};
}
}
Expand Down Expand Up @@ -67,6 +79,7 @@ Meteor.methods({
return {
requested: true,
exportOperation,
url: null,
};
},
});