mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
Merge branch 'order' into worker-order
This commit is contained in:
commit
ba2a34f67c
@ -632,6 +632,7 @@ const handleGetHistory = function (Env, Server, seq, userId, parsed) {
|
||||
var metadata = {};
|
||||
var lastKnownHash;
|
||||
var txid;
|
||||
var priority;
|
||||
|
||||
// clients can optionally pass a map of attributes
|
||||
// if the channel already exists this map will be ignored
|
||||
@ -640,6 +641,7 @@ const handleGetHistory = function (Env, Server, seq, userId, parsed) {
|
||||
lastKnownHash = config.lastKnownHash;
|
||||
metadata = config.metadata || {};
|
||||
txid = config.txid;
|
||||
priority = config.priority;
|
||||
if (metadata.expire) {
|
||||
metadata.expire = +metadata.expire * 1000 + (+new Date());
|
||||
}
|
||||
@ -683,7 +685,7 @@ const handleGetHistory = function (Env, Server, seq, userId, parsed) {
|
||||
if (checkExpired(Env, Server, channelName)) { return void waitFor.abort(); }
|
||||
|
||||
// always send metadata with GET_HISTORY requests
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(metadata)], w);
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(metadata), priority], w);
|
||||
}));
|
||||
}).nThen(() => {
|
||||
let msgCount = 0;
|
||||
@ -694,7 +696,7 @@ const handleGetHistory = function (Env, Server, seq, userId, parsed) {
|
||||
// avoid sending the metadata message a second time
|
||||
if (isMetadataMessage(msg) && metadata_cache[channelName]) { return readMore(); }
|
||||
if (txid) { msg[0] = txid; }
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(msg)], readMore);
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(msg), priority], readMore);
|
||||
}, (err, reason) => {
|
||||
// Any error but ENOENT: abort
|
||||
// ENOENT is allowed in case we want to create a new pad
|
||||
@ -714,12 +716,12 @@ const handleGetHistory = function (Env, Server, seq, userId, parsed) {
|
||||
}); }
|
||||
// FIXME err.message isn't useful for users
|
||||
const parsedMsg = {error:err.message, channel: channelName, txid: txid};
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg)]);
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg), priority]);
|
||||
return;
|
||||
}
|
||||
if (err && err.code === 'ENOENT' && reason && !metadata.forcePlaceholder) {
|
||||
const parsedMsg2 = {error:'EDELETED', message: reason, channel: channelName, txid: txid};
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg2)]);
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg2), priority]);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -735,20 +737,20 @@ const handleGetHistory = function (Env, Server, seq, userId, parsed) {
|
||||
to edit it in a broken state.
|
||||
*/
|
||||
const parsedMsg2 = {error:'EDELETED', channel: channelName, txid: txid};
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg2)]);
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg2), priority]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msgCount === 0 && !metadata_cache[channelName] && Server.channelContainsUser(channelName, userId)) {
|
||||
// TODO this might be a good place to reject channel creation by anonymous users
|
||||
handleFirstMessage(Env, channelName, metadata);
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(metadata)]);
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(metadata), priority]);
|
||||
}
|
||||
|
||||
// End of history message:
|
||||
let parsedMsg = {state: 1, channel: channelName, txid: txid};
|
||||
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg)]);
|
||||
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg), priority]);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -16,6 +16,7 @@ const factory = (ApiConfig = {}, Sortify, UserObject, ProxyManager,
|
||||
const Saferphore = Util.Saferphore;
|
||||
var onReadyEvt = Util.mkEvent(true);
|
||||
var onCacheReadyEvt = Util.mkEvent(true);
|
||||
var onJoinedEvt = Util.mkEvent(true);
|
||||
|
||||
const setCustomize = data => {
|
||||
ApiConfig = data.ApiConfig;
|
||||
@ -1797,18 +1798,23 @@ const factory = (ApiConfig = {}, Sortify, UserObject, ProxyManager,
|
||||
};
|
||||
var conf = {
|
||||
Cache: Cache, // ICE pad cache
|
||||
priority: 1,
|
||||
onCacheStart: function () {
|
||||
postMessage(clientId, "PAD_CACHE");
|
||||
},
|
||||
onCacheReady: function () {
|
||||
console.error('PAD CACHE READY');
|
||||
postMessage(clientId, "PAD_CACHE_READY");
|
||||
},
|
||||
onReady: function (pad) {
|
||||
console.error('PAD READY');
|
||||
var padData = pad.metadata || {};
|
||||
channel.data = padData;
|
||||
if (padData && padData.validateKey && store.messenger) {
|
||||
store.messenger.storeValidateKey(data.channel, padData.validateKey);
|
||||
}
|
||||
postMessage(clientId, "PAD_READY", pad.noCache);
|
||||
/*
|
||||
if (!store.proxy) {
|
||||
postMessage(clientId, "PAD_READY", pad.noCache);
|
||||
return;
|
||||
@ -1816,6 +1822,7 @@ const factory = (ApiConfig = {}, Sortify, UserObject, ProxyManager,
|
||||
onReadyEvt.reg(function () {
|
||||
postMessage(clientId, "PAD_READY", pad.noCache);
|
||||
});
|
||||
*/
|
||||
},
|
||||
onMessage: function (m, user, validateKey, isCp, hash) {
|
||||
channel.lastHash = hash;
|
||||
@ -1869,6 +1876,9 @@ const factory = (ApiConfig = {}, Sortify, UserObject, ProxyManager,
|
||||
metadata: data.metadata,
|
||||
network: store.network || store.networkPromise,
|
||||
websocketURL: NetConfig.getWebsocketURL(),
|
||||
onInit: function () {
|
||||
onJoinedEvt.fire();
|
||||
},
|
||||
//readOnly: data.readOnly,
|
||||
onConnect: function (wc, sendMessage) {
|
||||
channel.sendMessage = function (msg, cId, cb) {
|
||||
@ -2715,8 +2725,11 @@ const factory = (ApiConfig = {}, Sortify, UserObject, ProxyManager,
|
||||
postMessage(clientId, 'LOADING_DRIVE', data);
|
||||
}, true);
|
||||
}).nThen(function (waitFor) {
|
||||
console.error('SF CACHE READY');
|
||||
|
||||
loadUniversal(Team, 'team', waitFor, clientId);
|
||||
}).nThen(function (waitFor) {
|
||||
console.error('TEAM CACHE READY');
|
||||
loadUniversal(Calendar, 'calendar', waitFor);
|
||||
}).nThen(function () {
|
||||
cb();
|
||||
@ -2790,6 +2803,7 @@ const factory = (ApiConfig = {}, Sortify, UserObject, ProxyManager,
|
||||
loadUniversal(History, 'history', waitFor);
|
||||
loadUniversal(Support, 'support', waitFor);
|
||||
}).nThen(function () {
|
||||
console.error('SF & TEAM READY');
|
||||
var requestLogin = function () {
|
||||
broadcast([], "REQUEST_LOGIN");
|
||||
};
|
||||
@ -2940,6 +2954,7 @@ const factory = (ApiConfig = {}, Sortify, UserObject, ProxyManager,
|
||||
returned.anonHash = Hash.getEditHashFromKeys(secret);
|
||||
}
|
||||
}).on('cacheready', function (info) {
|
||||
console.error('DRIVE CACHE READY');
|
||||
store.offline = true;
|
||||
store.realtime = info.realtime;
|
||||
store.networkPromise = info.networkPromise;
|
||||
@ -2974,6 +2989,7 @@ const factory = (ApiConfig = {}, Sortify, UserObject, ProxyManager,
|
||||
onCacheReadyEvt.fire();
|
||||
});
|
||||
}).on('ready', function (info) {
|
||||
console.error('DRIVE READY');
|
||||
delete store.networkTimeout;
|
||||
if (store.ready) { return; } // the store is already ready, it is a reconnection
|
||||
store.driveMetadata = info.metadata;
|
||||
@ -3232,6 +3248,30 @@ const factory = (ApiConfig = {}, Sortify, UserObject, ProxyManager,
|
||||
}
|
||||
|
||||
store.data = data;
|
||||
if (data.noDrive) {
|
||||
return void onNoDrive(clientId, function (obj) {
|
||||
if (obj && obj.error) {
|
||||
// if we can't properly initialize the noDrive mode, use normal mode
|
||||
if (obj.error === 'GET_HK') {
|
||||
data.noDrive = false;
|
||||
Store.init(clientId, data, _callback);
|
||||
Feedback.send("NO_DRIVE_ERROR", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
callback(obj);
|
||||
onJoinedEvt.reg(function () {
|
||||
connect(clientId, data, function (ret) {
|
||||
if (Object.keys(store.proxy).length === 1) {
|
||||
Feedback.send("FIRST_APP_USE", true);
|
||||
}
|
||||
if (ret && ret.error) {
|
||||
initialized = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
connect(clientId, data, function (ret) {
|
||||
if (Object.keys(store.proxy).length === 1) {
|
||||
Feedback.send("FIRST_APP_USE", true);
|
||||
|
||||
@ -2376,6 +2376,7 @@ define([
|
||||
$displayName.text(newName);
|
||||
if ((accountName && oldUrl !== url) || !accountName && uid !== oldUid || oldName !== newName) {
|
||||
$avatar.html('');
|
||||
if (newName) { console.error("AVATAR IN TOOLBAR", newName); } // XXX
|
||||
Common.displayAvatar($avatar, url, newName, function ($img) {
|
||||
oldUrl = url;
|
||||
oldUid = uid;
|
||||
|
||||
@ -534,6 +534,7 @@ define([
|
||||
contentUpdate(newContent, function () { return function () {}; });
|
||||
}
|
||||
|
||||
console.error('REMOVE LAODING SCREEN - CACHE');
|
||||
UI.removeLoadingScreen(emitResize);
|
||||
};
|
||||
var onReady = function () {
|
||||
@ -668,6 +669,7 @@ define([
|
||||
|
||||
firstConnection = false;
|
||||
|
||||
console.error('REMOVE LOADING SCREEN - ONLINE'); // XXX ORDER
|
||||
UI.removeLoadingScreen(emitResize);
|
||||
|
||||
if (AppConfig.textAnalyzer && textContentGetter) {
|
||||
|
||||
@ -735,6 +735,7 @@ define([
|
||||
}));
|
||||
}
|
||||
}).nThen(function () {
|
||||
console.info('READY SCO');
|
||||
var readOnly = secret.keys && !secret.keys.editKeyStr;
|
||||
var isNewHash = true;
|
||||
if (!secret.keys) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user