|
|
|
@ -40,8 +40,6 @@ define([
|
|
|
|
|
obj.ooType = window.location.pathname.replace(/^\//, '').replace(/\/$/, '');
|
|
|
|
|
};
|
|
|
|
|
var addRpc = function (sframeChan, Cryptpad, Utils) {
|
|
|
|
|
var crypto = Utils.Crypto.createEncryptor(Utils.secret.keys);
|
|
|
|
|
|
|
|
|
|
sframeChan.on('Q_OO_SAVE', function (data, cb) {
|
|
|
|
|
var chanId = Utils.Hash.hrefToHexChannelId(data.url);
|
|
|
|
|
Cryptpad.getPadAttribute('lastVersion', function (err, data) {
|
|
|
|
@ -63,11 +61,25 @@ define([
|
|
|
|
|
Cryptpad.setPadAttribute('rtChannel', data.channel, function () {});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
var owners, expire;
|
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
|
if (Utils.rtConfig) {
|
|
|
|
|
owners = Utils.rtConfig.owners;
|
|
|
|
|
expire = Utils.rtConfig.expire;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Cryptpad.getPadAttribute('owners', waitFor(function (err, res) {
|
|
|
|
|
owners = res;
|
|
|
|
|
}));
|
|
|
|
|
Cryptpad.getPadAttribute('expire', waitFor(function (err, res) {
|
|
|
|
|
expire = res;
|
|
|
|
|
}));
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
Cryptpad.onlyoffice.execCommand({
|
|
|
|
|
cmd: 'OPEN_CHANNEL',
|
|
|
|
|
data: {
|
|
|
|
|
// XXX add owners?
|
|
|
|
|
// owners: something...
|
|
|
|
|
owners: owners,
|
|
|
|
|
expire: expire,
|
|
|
|
|
channel: data.channel,
|
|
|
|
|
lastCpHash: data.lastCpHash,
|
|
|
|
|
padChan: Utils.secret.channel,
|
|
|
|
@ -75,9 +87,10 @@ define([
|
|
|
|
|
}
|
|
|
|
|
}, cb);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
sframeChan.on('Q_OO_COMMAND', function (obj, cb) {
|
|
|
|
|
if (obj.cmd === 'SEND_MESSAGE') {
|
|
|
|
|
obj.data.msg = crypto.encrypt(JSON.stringify(obj.data.msg));
|
|
|
|
|
obj.data.msg = Utils.crypto.encrypt(JSON.stringify(obj.data.msg));
|
|
|
|
|
var hash = obj.data.msg.slice(0,64);
|
|
|
|
|
var _cb = cb;
|
|
|
|
|
cb = function () {
|
|
|
|
@ -90,7 +103,7 @@ define([
|
|
|
|
|
if (obj.ev === 'MESSAGE' && !/^cp\|/.test(obj.data)) {
|
|
|
|
|
try {
|
|
|
|
|
obj.data = {
|
|
|
|
|
msg: JSON.parse(crypto.decrypt(obj.data, Utils.secret.keys.validateKey)),
|
|
|
|
|
msg: JSON.parse(Utils.crypto.decrypt(obj.data, Utils.secret.keys.validateKey)),
|
|
|
|
|
hash: obj.data.slice(0,64)
|
|
|
|
|
};
|
|
|
|
|
} catch (e) {
|
|
|
|
@ -102,6 +115,7 @@ define([
|
|
|
|
|
};
|
|
|
|
|
SFCommonO.start({
|
|
|
|
|
type: 'oo',
|
|
|
|
|
useCreationScreen: true,
|
|
|
|
|
addData: addData,
|
|
|
|
|
addRpc: addRpc,
|
|
|
|
|
messaging: true
|
|
|
|
|