mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
Add priority to channels
This commit is contained in:
parent
f01e21eac7
commit
598e2fff27
@ -602,6 +602,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
|
||||
@ -610,6 +611,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());
|
||||
}
|
||||
@ -653,7 +655,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;
|
||||
@ -664,7 +666,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) => {
|
||||
// Any error but ENOENT: abort
|
||||
// ENOENT is allowed in case we want to create a new pad
|
||||
@ -707,13 +709,13 @@ const handleGetHistory = function (Env, Server, seq, userId, parsed) {
|
||||
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]);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -1803,6 +1803,7 @@ define([
|
||||
};
|
||||
var conf = {
|
||||
Cache: Cache, // ICE pad cache
|
||||
priority: 1,
|
||||
onCacheStart: function () {
|
||||
postMessage(clientId, "PAD_CACHE");
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user