diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index f8a3711c0..fefbba6e1 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -803,6 +803,17 @@ define([ var chan = [data.channel]; if (data.rtChannel) { chan.push(data.rtChannel); } if (data.lastVersion) { chan.push(Hash.hrefToHexChannelId(data.lastVersion)); } + var channels = chan.filter(function (c) { return c.length === 32; }).map(function (id) { + if (id === data.rtChannel && data.lastVersion && data.lastCpHash) { + return { + channel: id, + lastKnownHash: data.lastCpHash + }; + } + return { + channel: id + }; + }); var history = common.makeUniversal('history'); var trimChannels = []; NThen(function (waitFor) { @@ -819,7 +830,7 @@ define([ if (!owned) { return; } history.execCommand('GET_HISTORY_SIZE', { pad: true, - channels: chan.filter(function (c) { return c.length === 32; }), + channels: channels, teamId: typeof(owned) === "number" && owned }, waitFor(function (obj) { if (obj && obj.error) { return; } diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index 21e51510e..c039a86e3 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -3867,6 +3867,7 @@ define([ var opts = {}; opts.href = Hash.getRelativeHref(data.href || data.roHref); + opts.channel = data.channel; if (manager.isSharedFolder(el)) { var ro = folders[el] && folders[el].version >= 2; diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 0ad29df6c..f9ed15f60 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -325,6 +325,7 @@ define([ body: $('body'), onUploaded: function (ev, data) { if (!data || !data.url) { return; } + data.hash = ev.hash; sframeChan.query('Q_OO_SAVE', data, function (err) { onUploaded(ev, data, err); }); @@ -1556,6 +1557,7 @@ define([ content = hjson.content || content; var newLatest = getLastCp(); sframeChan.query('Q_OO_SAVE', { + hash: newLatest.hash, url: newLatest.file }, function () { }); newDoc = !content.hashes || Object.keys(content.hashes).length === 0; @@ -1649,6 +1651,7 @@ define([ var newLatest = getLastCp(); if (newLatest.index > latest.index) { sframeChan.query('Q_OO_SAVE', { + hash: newLatest.hash, url: newLatest.file }, function () { }); } diff --git a/www/common/onlyoffice/main.js b/www/common/onlyoffice/main.js index 7007bd360..9096cd730 100644 --- a/www/common/onlyoffice/main.js +++ b/www/common/onlyoffice/main.js @@ -61,6 +61,7 @@ define([ if (e) { return void cb(e); } Cryptpad.setPadAttribute('lastVersion', data.url, cb); }); + Cryptpad.setPadAttribute('lastCpHash', data.hash, cb); }); sframeChan.on('Q_OO_OPENCHANNEL', function (data, cb) { Cryptpad.getPadAttribute('rtChannel', function (err, res) { diff --git a/www/common/outer/onlyoffice.js b/www/common/outer/onlyoffice.js index 968ea12c3..567bc180b 100644 --- a/www/common/outer/onlyoffice.js +++ b/www/common/outer/onlyoffice.js @@ -36,6 +36,7 @@ define([ return void cb(); } + var txid = Math.floor(Math.random() * 1000000); var onOpen = function (wc) { ctx.channels[channel] = ctx.channels[channel] || { @@ -91,6 +92,7 @@ define([ var hk = network.historyKeeper; var cfg = { + txid: txid, lastKnownHash: chan.lastKnownHash || chan.lastCpHash, metadata: { validateKey: obj.validateKey, @@ -121,6 +123,8 @@ define([ } catch (e) {} if (!parsed) { return; } + // If there is a txid, make sure it's ours or abort + if (parsed.txid && parsed.txid !== txid) { return; } // Keep only metadata messages for the current channel if (parsed.channel && parsed.channel !== channel) { return; } @@ -138,6 +142,11 @@ define([ } if (parsed.error && parsed.channel) { return; } + // If there is a txid, make sure it's ours or abort + if (Array.isArray(parsed) && parsed[0] && parsed[0] !== txid) { + return; + } + msg = parsed[4]; // Keep only the history for our channel