|
|
|
@ -1458,37 +1458,27 @@ define([
|
|
|
|
|
var getVersionHash = function (clientId, data) {
|
|
|
|
|
var validateKey;
|
|
|
|
|
var fakeNetflux = Hash.createChannelId();
|
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
|
Store.getPadMetadata(null, {
|
|
|
|
|
channel: data.channel
|
|
|
|
|
}, function (md) {
|
|
|
|
|
// XXX not needed? we don't need to validate messages coming from history keeper
|
|
|
|
|
validateKey = md.validateKey;
|
|
|
|
|
Store.getHistoryRange(clientId, {
|
|
|
|
|
cpCount: 1,
|
|
|
|
|
channel: data.channel,
|
|
|
|
|
lastKnownHash: data.versionHash
|
|
|
|
|
}, function (obj) {
|
|
|
|
|
if (obj && obj.error) {
|
|
|
|
|
postMessage(clientId, "PAD_ERROR", obj.error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
postMessage(clientId, "PAD_CONNECT", {
|
|
|
|
|
myID: fakeNetflux,
|
|
|
|
|
id: data.channel,
|
|
|
|
|
members: [fakeNetflux]
|
|
|
|
|
});
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
Store.getHistoryRange(clientId, {
|
|
|
|
|
cpCount: 1,
|
|
|
|
|
channel: data.channel,
|
|
|
|
|
lastKnownHash: data.versionHash
|
|
|
|
|
}, function (obj) {
|
|
|
|
|
if (obj && obj.error) {
|
|
|
|
|
postMessage(clientId, "PAD_ERROR", obj.error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
postMessage(clientId, "PAD_CONNECT", {
|
|
|
|
|
myID: fakeNetflux,
|
|
|
|
|
id: data.channel,
|
|
|
|
|
members: [fakeNetflux]
|
|
|
|
|
});
|
|
|
|
|
(obj.messages || []).forEach(function (data) {
|
|
|
|
|
postMessage(clientId, "PAD_MESSAGE", {
|
|
|
|
|
msg: data.msg,
|
|
|
|
|
user: fakeNetflux.slice(0,16), // fake history keeper to avoid validate
|
|
|
|
|
validateKey: validateKey
|
|
|
|
|
});
|
|
|
|
|
(obj.messages || []).forEach(function (data) {
|
|
|
|
|
postMessage(clientId, "PAD_MESSAGE", {
|
|
|
|
|
msg: data.msg,
|
|
|
|
|
user: fakeNetflux.slice(0,16), // fake history keeper to avoid validate
|
|
|
|
|
});
|
|
|
|
|
postMessage(clientId, "PAD_READY");
|
|
|
|
|
});
|
|
|
|
|
postMessage(clientId, "PAD_READY");
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|