Add new error message with deleted template

This commit is contained in:
yflory 2023-09-13 15:43:20 +02:00
parent 91b1af15fd
commit 4d643e51a1
6 changed files with 46 additions and 18 deletions

View File

@ -604,9 +604,6 @@ define([
});
break;
case 'DELETED_USER':
if (result.reason === 'PASSWORD_CHANGE') {
// XXX PLACEHOLDER: account password change login page
}
UI.errorLoadingScreen(UI.getDestroyedPlaceholder(result.reason, true));
break;
case 'INVAL_PASS':

View File

@ -1048,9 +1048,11 @@ define([
if (e.which === 27) {
e.preventDefault();
e.stopPropagation();
// Function: call the function (should be a redirect)
if (typeof(exitable) === "function") { return void exitable(); }
// Otherwise remove the loading screen
$loading.hide();
$('html').toggleClass('cp-loading-noscroll', false);
if (typeof(exitable) === "function") { exitable(); }
}
});
}
@ -1549,18 +1551,29 @@ define([
// XXX
Messages.dph_reason = "Reason: {0}";
Messages.dph_default = "This content is no longer available"; // default key when custom message not found
Messages.dph_account_destroyed = "This account has been deleted by its owner";
Messages.dph_account_inactive = "This account has been deleted for inactivity";
Messages.dph_account_moderated = "This account has been suspended by the moderation team";
Messages.dph_account_pw = "This account's password has been changed";
Messages.dph_pad_destroyed = "This document has been destroyed by its owner";
Messages.dph_pad_inactive = "This document has been deleted for inactivity";
Messages.dph_pad_moderated = "This document has been deleted by the moderation team";
Messages.dph_pad_moderated_account = "This document has deleted with its owner's account"; // Keep this key ???
Messages.dph_pad_moderated_account = "This document has been deleted with its owner's account"; // Keep this key ???
Messages.dph_pad_pw = "The document you are trying to open is protected with a new password. Enter the correct password to access the content.";
Messages.dph_tmp_destroyed = "This template has been destroyed by its owner";
Messages.dph_tmp_moderated = "This template has been deleted by the moderation team";
Messages.dph_tmp_moderated_account = "This template has been deleted with its owner's account"; // Keep this key ???
Messages.dph_tmp_pw = "This template is protected with a new password. Open it from your drive to enter its new password.";
UI.getDestroyedPlaceholderMessage = (code, isAccount) => {
UI.getDestroyedPlaceholderMessage = (code, isAccount, isTemplate) => {
var account = {
ARCHIVE_OWNED: Messages.dph_account_destroyed,
INACTIVE: Messages.dph_account_inactive,
@ -1568,6 +1581,12 @@ define([
MODERATION_BLOCK: Messages.dph_account_moderated,
PASSWORD_CHANGE: Messages.dph_account_pw,
};
var template = {
ARCHIVE_OWNED: Messages.dph_tmp_destroyed,
MODERATION_PAD: Messages.dph_tmp_moderated,
MODERATION_ACCOUNT: Messages.dph_tmp_moderated_account,
PASSWORD_CHANGE: Messages.dph_tmp_pw
};
var pad = {
ARCHIVE_OWNED: Messages.dph_pad_destroyed,
INACTIVE: Messages.dph_pad_inactive,
@ -1576,7 +1595,14 @@ define([
MODERATION_ACCOUNT: Messages.dph_pad_moderated_account,
PASSWORD_CHANGE: Messages.dph_pad_pw
};
return isAccount ? account[code] : pad[code];
var msg = pad[code];
if (isAccount) {
msg = account[code];
} else if (isTemplate) {
msg = template[code];
}
if (!msg) { msg = Messages.dph_default; }
return msg;
};
UI.getDestroyedPlaceholder = function (reason, isAccount) {
if (typeof(reason) !== "string") { return; }

View File

@ -961,9 +961,9 @@ define([
optsPut.accessKeys = keys;
}));
}).nThen(function () {
Crypt.get(parsed.hash, function (err, val) {
Crypt.get(parsed.hash, function (err, val, errData) {
if (err) {
return void cb(err);
return void cb(err, errData);
}
if (!val) {
return void cb('ENOENT');
@ -1005,10 +1005,10 @@ define([
optsGet.accessKeys = keys;
}));
}).nThen(function () {
Crypt.get(parsed.hash, function (err, _val) {
Crypt.get(parsed.hash, function (err, _val, errData) {
if (err) {
_waitFor.abort();
return void cb(err);
return void cb(err, errData);
}
try {
val = JSON.parse(_val);

View File

@ -2264,13 +2264,13 @@ define([
// server
Cryptpad.useTemplate({
href: data.template
}, Cryptget, function (err) {
}, Cryptget, function (err, errData) {
if (err) {
// TODO: better messages in case of expired, deleted, etc.?
if (err === 'ERESTRICTED') {
sframeChan.event('EV_RESTRICTED_ERROR');
} else {
sframeChan.query("EV_LOADING_ERROR", "DELETED");
sframeChan.query("EV_LOADING_ERROR", errData || 'DELETED');
}
return;
}
@ -2281,13 +2281,13 @@ define([
}
// if we open a new code from a file
if (Cryptpad.fromFileData && !isOO) {
Cryptpad.useFile(Cryptget, function (err) {
Cryptpad.useFile(Cryptget, function (err, errData) {
if (err) {
// TODO: better messages in case of expired, deleted, etc.?
if (err === 'ERESTRICTED') {
sframeChan.event('EV_RESTRICTED_ERROR');
} else {
sframeChan.query("EV_LOADING_ERROR", "DELETED");
sframeChan.query("EV_LOADING_ERROR", errData || 'DELETED');
}
return;
}

View File

@ -894,10 +894,15 @@ define([
ctx.sframeChan.on('EV_LOADING_ERROR', function (err) {
var msg = err;
if (err === 'DELETED') {
if (err === 'DELETED' || (err && err.type === 'EDELETED')) {
// XXX You can still use the current version in read-only mode by pressing Esc.
// what if they don't have a keyboard (ie. mobile)
msg = Messages.deletedError + '<br>' + Messages.errorRedirectToHome;
if (err.type && err.message) {
msg = UI.getDestroyedPlaceholderMessage(err.message, false, true);
} else {
msg = Messages.deletedError;
}
msg += '<br>' + Messages.errorRedirectToHome;
} else if (err === "INVALID_HASH") {
msg = Messages.invalidHashError;
} else if (err === 'ACCOUNT') { // block 404 but no placeholder

View File

@ -57,7 +57,7 @@ define([
if (!newObj || !Object.keys(newObj).length) {
// Empty anon drive: deleted
var msg = Messages.deletedError + '<br>' + Messages.errorRedirectToHome;
setTimeout(function () { UI.errorLoadingScreen(msg, false, function () {}); });
setTimeout(function () { UI.errorLoadingScreen(msg, false, true); });
APP.newSharedFolder = null;
}
}