diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 65839290e..4c6df2c0d 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -728,18 +728,26 @@ define([ var optsPut = {}; if (p.type === 'poll') { optsPut.initialState = '{}'; } // PPP: add password as cryptput option - Cryptput(hash, data.toSave, function (e) { - if (e) { throw new Error(e); } - postMessage("ADD_PAD", { - teamId: data.teamId, - href: href, - title: data.title, - path: ['template'] - }, function (obj) { - if (obj && obj.error) { return void cb(obj.error); } - cb(); - }); - }, optsPut); + Nthen(function (w) { + common.getEdPublic(null, w(function (obj) { + if (obj && obj.error) { return; } + optsPut.owners = [obj]; + })); + }).nThen(function () { + Cryptput(hash, data.toSave, function (e) { + if (e) { throw new Error(e); } + postMessage("ADD_PAD", { + teamId: data.teamId, + href: href, + title: data.title, + owners: optsPut.owners, + path: ['template'] + }, function (obj) { + if (obj && obj.error) { return void cb(obj.error); } + cb(); + }); + }, optsPut); + }); }; common.isTemplate = function (href, cb) { diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 08c4c1910..07a45df92 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -222,6 +222,7 @@ define([ // Make sure a former tab on the same worker doesn't have remaining locks var checkClients = function (clients) { + if (!clients) { return; } Object.keys(content.ids).forEach(function (id) { var tabId = Number(id.slice(33)); // remove the netflux ID and the "-" if (clients.indexOf(tabId) === -1) { @@ -389,9 +390,14 @@ define([ }; _content.version = NEW_VERSION; _content.channel = Hash.createChannelId(); + _content.ids = {}; sframeChan.query('Q_SAVE_AS_TEMPLATE', { toSave: JSON.stringify({ - content: _content + content: _content, + metadata: { + title: '', + defaultTitle: ev.title + } }), title: ev.title }, function () {