Merge branch 'soon' into staging
This commit is contained in:
commit
c42a79991c
@ -162,7 +162,7 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
var parsed = Hash.parsePadUrl(data.href || data.roHref);
|
var parsed = Hash.parsePadUrl(data.href || data.roHref);
|
||||||
if (!data.noEditPassword && owned && parsed.hashData.type === 'pad') {
|
if (!data.noEditPassword && owned && parsed.hashData.type === 'pad' && parsed.type !== "sheet") { // FIXME SHEET fix password change for sheets
|
||||||
var sframeChan = common.getSframeChannel();
|
var sframeChan = common.getSframeChannel();
|
||||||
var changePwTitle = Messages.properties_changePassword;
|
var changePwTitle = Messages.properties_changePassword;
|
||||||
var changePwConfirm = Messages.properties_confirmChange;
|
var changePwConfirm = Messages.properties_confirmChange;
|
||||||
|
|||||||
@ -102,9 +102,12 @@ define([
|
|||||||
Cryptpad.onlyoffice.onEvent.reg(function (obj) {
|
Cryptpad.onlyoffice.onEvent.reg(function (obj) {
|
||||||
if (obj.ev === 'MESSAGE' && !/^cp\|/.test(obj.data)) {
|
if (obj.ev === 'MESSAGE' && !/^cp\|/.test(obj.data)) {
|
||||||
try {
|
try {
|
||||||
|
var validateKey = obj.data.validateKey || true;
|
||||||
|
var skipCheck = validateKey === true;
|
||||||
|
var msg = obj.data.msg;
|
||||||
obj.data = {
|
obj.data = {
|
||||||
msg: JSON.parse(Utils.crypto.decrypt(obj.data, Utils.secret.keys.validateKey)),
|
msg: JSON.parse(Utils.crypto.decrypt(msg, validateKey, skipCheck)),
|
||||||
hash: obj.data.slice(0,64)
|
hash: msg.slice(0,64)
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|||||||
@ -26,7 +26,10 @@ define([
|
|||||||
if (!c.id) { c.id = chan.wc.myID + '-' + client; }
|
if (!c.id) { c.id = chan.wc.myID + '-' + client; }
|
||||||
|
|
||||||
chan.history.forEach(function (msg) {
|
chan.history.forEach(function (msg) {
|
||||||
ctx.emit('MESSAGE', msg, [client]);
|
ctx.emit('MESSAGE', {
|
||||||
|
msg: msg,
|
||||||
|
validateKey: chan.validateKey
|
||||||
|
}, [client]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ==> And push the new tab to the list
|
// ==> And push the new tab to the list
|
||||||
@ -37,7 +40,8 @@ define([
|
|||||||
var onOpen = function (wc) {
|
var onOpen = function (wc) {
|
||||||
|
|
||||||
ctx.channels[channel] = ctx.channels[channel] || {
|
ctx.channels[channel] = ctx.channels[channel] || {
|
||||||
history: []
|
history: [],
|
||||||
|
validateKey: obj.validateKey
|
||||||
};
|
};
|
||||||
|
|
||||||
chan = ctx.channels[channel];
|
chan = ctx.channels[channel];
|
||||||
@ -61,7 +65,10 @@ define([
|
|||||||
});
|
});
|
||||||
wc.on('message', function (msg) {
|
wc.on('message', function (msg) {
|
||||||
chan.history.push(msg);
|
chan.history.push(msg);
|
||||||
ctx.emit('MESSAGE', msg, chan.clients);
|
ctx.emit('MESSAGE', {
|
||||||
|
msg: msg,
|
||||||
|
validateKey: chan.validateKey
|
||||||
|
}, chan.clients);
|
||||||
});
|
});
|
||||||
|
|
||||||
chan.wc = wc;
|
chan.wc = wc;
|
||||||
@ -101,6 +108,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
network.on('message', function (msg, sender) {
|
network.on('message', function (msg, sender) {
|
||||||
|
if (!ctx.channels[channel]) { return; }
|
||||||
var hk = network.historyKeeper;
|
var hk = network.historyKeeper;
|
||||||
if (sender !== hk) { return; }
|
if (sender !== hk) { return; }
|
||||||
|
|
||||||
@ -115,7 +123,12 @@ define([
|
|||||||
// Keep only metadata messages for the current channel
|
// Keep only metadata messages for the current channel
|
||||||
if (parsed.channel && parsed.channel !== channel) { return; }
|
if (parsed.channel && parsed.channel !== channel) { return; }
|
||||||
// Ignore the metadata message
|
// Ignore the metadata message
|
||||||
if (parsed.validateKey && parsed.channel) { return; }
|
if (parsed.validateKey && parsed.channel) {
|
||||||
|
if (!chan.validateKey) {
|
||||||
|
chan.validateKey = parsed.validateKey;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
// End of history: emit READY
|
// End of history: emit READY
|
||||||
if (parsed.state && parsed.state === 1 && parsed.channel) {
|
if (parsed.state && parsed.state === 1 && parsed.channel) {
|
||||||
ctx.emit('READY', '', chan.clients);
|
ctx.emit('READY', '', chan.clients);
|
||||||
@ -132,7 +145,9 @@ define([
|
|||||||
if (hash === chan.lastKnownHash || hash === chan.lastCpHash) { return; }
|
if (hash === chan.lastKnownHash || hash === chan.lastCpHash) { return; }
|
||||||
|
|
||||||
chan.lastKnownHash = hash;
|
chan.lastKnownHash = hash;
|
||||||
ctx.emit('MESSAGE', msg, chan.clients);
|
ctx.emit('MESSAGE', {
|
||||||
|
msg: msg,
|
||||||
|
}, chan.clients);
|
||||||
chan.history.push(msg);
|
chan.history.push(msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -176,7 +191,9 @@ define([
|
|||||||
return void chan.sendMsg(data.isCp, cb);
|
return void chan.sendMsg(data.isCp, cb);
|
||||||
}
|
}
|
||||||
chan.sendMsg(data.msg, cb);
|
chan.sendMsg(data.msg, cb);
|
||||||
ctx.emit('MESSAGE', data.msg, chan.clients.filter(function (cl) {
|
ctx.emit('MESSAGE', {
|
||||||
|
msg: data.msg
|
||||||
|
}, chan.clients.filter(function (cl) {
|
||||||
return cl !== clientId;
|
return cl !== clientId;
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|||||||
@ -625,6 +625,11 @@ define([
|
|||||||
var root = exp.find([ROOT]);
|
var root = exp.find([ROOT]);
|
||||||
var toClean = [];
|
var toClean = [];
|
||||||
for (var id in fd) {
|
for (var id in fd) {
|
||||||
|
if (String(id) !== String(Number(id))) {
|
||||||
|
debug("Invalid file ID in filesData.", id);
|
||||||
|
toClean.push(id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
id = Number(id);
|
id = Number(id);
|
||||||
var el = fd[id];
|
var el = fd[id];
|
||||||
|
|
||||||
|
|||||||
@ -342,7 +342,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Remove the elements from the old location (without unpinning)
|
// Remove the elements from the old location (without unpinning)
|
||||||
Env.user.userObject.delete(resolved.main, waitFor());
|
Env.user.userObject.delete(resolved.main, waitFor()); // FIXME waitFor() is called synchronously
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -369,7 +369,7 @@ define([
|
|||||||
if (copy) { return; }
|
if (copy) { return; }
|
||||||
|
|
||||||
// Remove the elements from the old location (without unpinning)
|
// Remove the elements from the old location (without unpinning)
|
||||||
uoFrom.delete(paths, waitFor());
|
uoFrom.delete(paths, waitFor()); // FIXME waitFor() is called synchronously
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -707,6 +707,7 @@ define([
|
|||||||
if (type === 'expirable') {
|
if (type === 'expirable') {
|
||||||
return function (fileId) {
|
return function (fileId) {
|
||||||
var data = userObject.getFileData(fileId);
|
var data = userObject.getFileData(fileId);
|
||||||
|
if (!data) { return; }
|
||||||
// Don't push duplicates
|
// Don't push duplicates
|
||||||
if (result.indexOf(data.channel) !== -1) { return; }
|
if (result.indexOf(data.channel) !== -1) { return; }
|
||||||
// Return pads owned by someone else or expired by time
|
// Return pads owned by someone else or expired by time
|
||||||
@ -718,6 +719,7 @@ define([
|
|||||||
if (type === 'owned') {
|
if (type === 'owned') {
|
||||||
return function (fileId) {
|
return function (fileId) {
|
||||||
var data = userObject.getFileData(fileId);
|
var data = userObject.getFileData(fileId);
|
||||||
|
if (!data) { return; }
|
||||||
// Don't push duplicates
|
// Don't push duplicates
|
||||||
if (result.indexOf(data.channel) !== -1) { return; }
|
if (result.indexOf(data.channel) !== -1) { return; }
|
||||||
// Return owned pads
|
// Return owned pads
|
||||||
@ -729,6 +731,7 @@ define([
|
|||||||
if (type === "pin") {
|
if (type === "pin") {
|
||||||
return function (fileId) {
|
return function (fileId) {
|
||||||
var data = userObject.getFileData(fileId);
|
var data = userObject.getFileData(fileId);
|
||||||
|
if (!data) { return; }
|
||||||
// Don't pin pads owned by someone else
|
// Don't pin pads owned by someone else
|
||||||
if (_ownedByOther(Env, data.owners)) { return; }
|
if (_ownedByOther(Env, data.owners)) { return; }
|
||||||
// Don't push duplicates
|
// Don't push duplicates
|
||||||
|
|||||||
@ -832,11 +832,17 @@ MessengerUI, Messages) {
|
|||||||
return $spin;
|
return $spin;
|
||||||
};
|
};
|
||||||
|
|
||||||
var createLimit = function (toolbar) {
|
var createLimit = function (toolbar, config) {
|
||||||
var $limitIcon = $('<span>', {'class': 'fa fa-exclamation-triangle'});
|
var $limitIcon = $('<span>', {'class': 'fa fa-exclamation-triangle'});
|
||||||
var $limit = toolbar.$userAdmin.find('.'+LIMIT_CLS).attr({
|
var $limit = toolbar.$userAdmin.find('.'+LIMIT_CLS).attr({
|
||||||
'title': Messages.pinLimitReached
|
'title': Messages.pinLimitReached
|
||||||
}).append($limitIcon).hide();
|
}).append($limitIcon).hide();
|
||||||
|
|
||||||
|
var priv = config.metadataMgr.getPrivateData();
|
||||||
|
var origin = priv.origin;
|
||||||
|
var l = document.createElement("a");
|
||||||
|
l.href = origin;
|
||||||
|
|
||||||
var todo = function (e, overLimit) {
|
var todo = function (e, overLimit) {
|
||||||
if (e) { return void console.error("Unable to get the pinned usage", e); }
|
if (e) { return void console.error("Unable to get the pinned usage", e); }
|
||||||
if (overLimit) {
|
if (overLimit) {
|
||||||
@ -845,7 +851,7 @@ MessengerUI, Messages) {
|
|||||||
key = 'pinLimitReachedAlertNoAccounts';
|
key = 'pinLimitReachedAlertNoAccounts';
|
||||||
}
|
}
|
||||||
$limit.show().click(function () {
|
$limit.show().click(function () {
|
||||||
UI.alert(Messages._getKey(key, [encodeURIComponent(window.location.hostname)]), null, true);
|
UI.alert(Messages._getKey(key, [encodeURIComponent(l.hostname)]), null, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -311,12 +311,12 @@ define([
|
|||||||
_getFiles[FILES_DATA] = function () {
|
_getFiles[FILES_DATA] = function () {
|
||||||
var ret = [];
|
var ret = [];
|
||||||
if (!files[FILES_DATA]) { return ret; }
|
if (!files[FILES_DATA]) { return ret; }
|
||||||
return Object.keys(files[FILES_DATA]).map(Number);
|
return Object.keys(files[FILES_DATA]).map(Number).filter(Boolean);
|
||||||
};
|
};
|
||||||
_getFiles[SHARED_FOLDERS] = function () {
|
_getFiles[SHARED_FOLDERS] = function () {
|
||||||
var ret = [];
|
var ret = [];
|
||||||
if (!files[SHARED_FOLDERS]) { return ret; }
|
if (!files[SHARED_FOLDERS]) { return ret; }
|
||||||
return Object.keys(files[SHARED_FOLDERS]).map(Number);
|
return Object.keys(files[SHARED_FOLDERS]).map(Number).filter(Boolean);
|
||||||
};
|
};
|
||||||
var getFiles = exp.getFiles = function (categories) {
|
var getFiles = exp.getFiles = function (categories) {
|
||||||
var ret = [];
|
var ret = [];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user