Files
wekan/server/methods/openCardAvailability.js
T
Lauri Ojansivu 7ed3ca7c5c A card opened from its link stays open when the connection drops and comes back while the page loads.
Behind a reverse proxy the DDP connection can drop and come back while a
card's link is still loading (a WebSocket upgrade the proxy refuses,
SockJS falling back). Every subscription re-runs on the way back, one
answers before the resumed login with nothing, and the card leaves
Minimongo for a moment. #3114's close-on-removal took that moment for a
deletion: it closed the card and went to the board's address.

The window now waits while the subscription, the connection or the login
is settling, and when the card looks gone with everything settled, asks
the server (cards.openCardAvailable, the 'card' publication's own rule,
now one function in server/lib/openCardAccess.js) and closes only on its
no, if Minimongo still agrees. A card really deleted, archived or moved
elsewhere still closes. Not reproduced here: no proxy in this
environment; the browser test drops and restores the connection.

Thanks to brlin-tw and xet7 !

Fixes #6808.
2026-10-27 10:05:01 +02:00

20 lines
829 B
JavaScript

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
import { readableCard } from '/server/lib/openCardAccess';
// #6808: before an opened card's window closes because the card left
// Minimongo, the client asks here whether it is really gone - the same rule
// as the 'card' publication, on the board the window was opened on. Only a
// yes or a no: nothing of the card is returned.
Meteor.methods({
async 'cards.openCardAvailable'(cardId, boardId) {
check(cardId, String);
check(boardId, String);
const card = await readableCard(this.userId, cardId);
return Boolean(card && card.boardId === boardId);
},
});
DDPRateLimiter.addRule({ type: 'method', name: 'cards.openCardAvailable', connectionId: () => true }, 30, 10000);