diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 923f2c321..c4ce8f162 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -932,7 +932,6 @@ define([ waitFor.abort(); return; } - console.warn('BAR'); href = url; setTimeout(w); }); @@ -1077,12 +1076,17 @@ define([ var makeBurnAfterReadingUrl = function (common, href, channel, cb) { var keyPair = Hash.generateSignPair(); var parsed = Hash.parsePadUrl(href); - console.error(href, parsed); var newHref = parsed.getUrl({ ownerKey: keyPair.safeSignKey }); var sframeChan = common.getSframeChannel(); + var rtChannel; NThen(function (waitFor) { + if (parsed.type !== "sheet") { return; } + common.getPadAttribute('rtChannel', waitFor(function (err, chan) { + rtChannel = chan; + })); + }).nThen(function (waitFor) { sframeChan.query('Q_SET_PAD_METADATA', { channel: channel, command: 'ADD_OWNERS', @@ -1093,6 +1097,17 @@ define([ UI.warn(Messages.error); } })); + if (rtChannel) { + sframeChan.query('Q_SET_PAD_METADATA', { + channel: rtChannel, + command: 'ADD_OWNERS', + value: [keyPair.validateKey] + }, waitFor(function (err) { + if (err) { + console.error(err); + } + })); + } }).nThen(function () { cb(newHref); }); diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 00431fddb..da596917c 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -1395,6 +1395,10 @@ define([ Title.updateTitle(Title.defaultTitle); } + if (metadataMgr.getPrivateData().burnAfterReading && content && content.channel) { + sframeChan.event('EV_BURN_PAD', content.channel); + } + openRtChannel(function () { setMyId(); oldHashes = JSON.parse(JSON.stringify(content.hashes)); diff --git a/www/common/onlyoffice/main.js b/www/common/onlyoffice/main.js index 71ddfa42d..5a79c94e3 100644 --- a/www/common/onlyoffice/main.js +++ b/www/common/onlyoffice/main.js @@ -64,8 +64,8 @@ define([ var owners, expire; nThen(function (waitFor) { if (Utils.rtConfig) { - owners = Utils.rtConfig.owners; - expire = Utils.rtConfig.expire; + owners = Utils.Util.find(Utils.rtConfig, ['metadata', 'owners']); + expire = Utils.Util.find(Utils.rtConfig, ['metadata', 'expire']); return; } Cryptpad.getPadAttribute('owners', waitFor(function (err, res) { diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index f53a6b496..ca84bc637 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -520,6 +520,33 @@ define([ sframeChan.on('Q_SET_PAD_METADATA', function (data, cb) { Cryptpad.setPadMetadata(data, cb); }); + + sframeChan.on('Q_GET_PAD_ATTRIBUTE', function (data, cb) { + var href; + if (readOnly && hashes.editHash) { + // If we have a stronger hash, use it for pad attributes + href = window.location.pathname + '#' + hashes.editHash; + } + if (data.href) { href = data.href; } + Cryptpad.getPadAttribute(data.key, function (e, data) { + cb({ + error: e, + data: data + }); + }, href); + }); + sframeChan.on('Q_SET_PAD_ATTRIBUTE', function (data, cb) { + var href; + if (readOnly && hashes.editHash) { + // If we have a stronger hash, use it for pad attributes + href = window.location.pathname + '#' + hashes.editHash; + } + if (data.href) { href = data.href; } + Cryptpad.setPadAttribute(data.key, data.value, function (e) { + cb({error:e}); + }, href); + }); + }; addCommonRpc(sframeChan); @@ -749,32 +776,6 @@ define([ }); // Store - sframeChan.on('Q_GET_PAD_ATTRIBUTE', function (data, cb) { - var href; - if (readOnly && hashes.editHash) { - // If we have a stronger hash, use it for pad attributes - href = window.location.pathname + '#' + hashes.editHash; - } - if (data.href) { href = data.href; } - Cryptpad.getPadAttribute(data.key, function (e, data) { - cb({ - error: e, - data: data - }); - }, href); - }); - sframeChan.on('Q_SET_PAD_ATTRIBUTE', function (data, cb) { - var href; - if (readOnly && hashes.editHash) { - // If we have a stronger hash, use it for pad attributes - href = window.location.pathname + '#' + hashes.editHash; - } - if (data.href) { href = data.href; } - Cryptpad.setPadAttribute(data.key, data.value, function (e) { - cb({error:e}); - }, href); - }); - sframeChan.on('Q_DRIVE_GETDELETED', function (data, cb) { Cryptpad.getDeletedPads(data, function (err, obj) { if (err) { return void console.error(err); } @@ -1183,6 +1184,14 @@ define([ }); }); + sframeChan.on('EV_BURN_PAD', function (channel) { + if (!burnAfterReading) { return; } + Cryptpad.burnPad({ + channel: channel, + ownerKey: burnAfterReading + }); + }); + if (cfg.messaging) { Notifier.getPermission(); diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index 9e51d46de..f4bb3106e 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -354,7 +354,7 @@ define([ key: key, href: href }, function (err, res) { - cb (err || res.error, res.data); + cb(err || res.error, res && res.data); }); }; funcs.setPadAttribute = function (key, value, cb, href) {