Skip to content

Commit 5f752d4

Browse files
committed
fix: missing institution fields from feedbacks
Institution fields are missing for feedbacks other than the first one submitted in a session. That is caused by cleaning session info from Redis earlier than necessary (after the first feedback for a meeting is submitted). Only clear Redis info for a session once the session ends via a meeting-ended webhook event. This fix includes a refactor in the Redis cleanup util so that user/session entries can be removed separately.
1 parent cee4e32 commit 5f752d4

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
### UNRELEASED
6+
7+
* fix: missing institution fields from feedbacks
8+
59
### v1.7.0
610

711
* feat: add support for 'ask_for_feedback_on_logout' parameter

backend/server.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ app.post('/feedback/webhook', async (req, res) => {
182182
`${KEY_PREFIX}:session:${meeting['internal-meeting-id']}`,
183183
sessionData,
184184
);
185+
} else if (eventType === 'meeting-ended') {
186+
const meeting = evt.data.attributes.meeting;
187+
const sessionId = meeting['internal-meeting-id'];
188+
189+
await Utils.redisStaleKeysCleanup(redisClient, sessionId);
185190
} else if (eventType === 'user-joined') {
186191
const user = evt.data.attributes.user;
187192
const userRedirectUrl = user.userdata?.['bbb_feedback_redirect_url'];
@@ -306,11 +311,11 @@ app.post('/feedback/submit', async (req, res) => {
306311
logger.debug('No FEEDBACK_URL set, logging feedback to syslog only.');
307312
}
308313

309-
await Utils.redisStaleKeysCleanup(redisClient, user.userId, session.sessionId);
314+
await Utils.redisStaleKeysCleanup(redisClient, user.userId);
310315
res.json({ status: 'success', data: completeFeedback });
311316
} catch (error) {
312317
logger.error('Error submitting feedback:', error);
313-
await Utils.redisStaleKeysCleanup(redisClient, user.userId, session.sessionId);
318+
await Utils.redisStaleKeysCleanup(redisClient, user.userId);
314319
res.status(500).send();
315320
}
316321
});

backend/utils.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,20 @@ const hSetWithExpiration = async (redisClient, key, field, expire_seconds=REDIS_
183183
}
184184

185185
/**
186-
* redisStaleKeysCleanup - Removes keys from the hash table for that given userId and sessionId.
186+
* redisStaleKeysCleanup - Removes keys from the hash table for a given keyId.
187187
* @param {import("redis").RedisClientType} redisClient - A connected Redis client instance
188-
* @param {string} userId - the userId present on the stale keys to be removed
189-
* @param {string} sessionId - the sessionId on the stale keys to be removed
188+
* @param {string} keyId - The keyId to be removed. A keyId is a unique identifier
189+
* present at the end of keys (e.g. `feedback:<key>:<keyId>`).
190190
*/
191-
const redisStaleKeysCleanup = async (redisClient, userId, sessionId) => {
191+
const redisStaleKeysCleanup = async (redisClient, keyId) => {
192+
if (!keyId) return;
193+
192194
const { keysToDelete, keysToKeep } = activeKeys.reduce((acc, key) => {
193-
// searches for the keys containing userId or sessionId
195+
// searches for the keys containing the keyId
194196
// Keys have the following format:
195-
// - feedback:session:<sessionId>
196-
// - feedback:user:<userId>
197-
if (key.includes(userId) || key.includes(sessionId)) {
197+
// - feedback:session:<keyId>
198+
// - feedback:user:<keyId>
199+
if (key.includes(keyId)) {
198200
acc.keysToDelete.push(key);
199201
} else {
200202
acc.keysToKeep.push(key);
@@ -215,4 +217,4 @@ export default {
215217
sortBy,
216218
hSetWithExpiration,
217219
redisStaleKeysCleanup,
218-
};
220+
};

0 commit comments

Comments
 (0)