bouncer: paused subs: even without filter.since, Pass any events that are new since the REQ command was taken

Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
Yonle 2024-02-27 18:00:19 +07:00
parent 114125242a
commit 3572a4b54b
2 changed files with 3 additions and 1 deletions

View File

@ -132,6 +132,7 @@ module.exports = (ws, req, onClose) => {
ws.pause_subs.delete(origID);
ws.subalias.set(faked, origID);
ws.fakesubalias.set(origID, faked);
if (!filter.since) filter.since = Math.floor(Date.now() / 1000); // Will not impact everything. Only used for handling passing pause_on_limit (or save mode)
ws.mergedFilters.set(origID, filter);
data[1] = faked;
bc(data, ws);
@ -245,7 +246,7 @@ function newConn(addr, client, reconn_t = 0) {
if (!client.subalias.has(data[1])) return;
data[1] = client.subalias.get(data[1]);
const filter = client.mergedFilters.get(data[1]);
if (client.pause_subs.has(data[1]) && (!filter.since || filter.since < data[2].created_at)) return;
if (client.pause_subs.has(data[1]) && (filter.since < data[2].created_at)) return;
if (client.rejectKinds && client.rejectKinds.includes(data[2]?.id)) return;

View File

@ -47,6 +47,7 @@ module.exports = {
// Pause an subscription from receiving further events after reached to <filter.limit>
// Could save client's bandwidth. Disable this if you need to get more events.
// This is also known as save mode.
//
// You may also need to adjust <max_eose_score>.
pause_on_limit: true,