Allow users to subscribe to community chat topics
Build and Push Docker Images / build-and-push (push) Successful in 1m28s

This commit is contained in:
Bram committed 2026-10-29 10:49:36 +00:00
1 parent 68c7ae67f1
commit baaae2b850
3 files changed
+41 -3

No files matched your search

@@ -203,6 +203,37 @@ test('socket broker', async t => {
socket.close();
});
await t.test('a user can subscribe to their own community topic only', async () => {
const userId = randomUuid();
const otherUserId = randomUuid();
const socket = connect({ token: connectToken(userId) });
await once(socket, 'connect');
socket.emit('subscribe', `community/user/${userId}`);
const subscribed = await once(socket, 'subscribed');
assert.equal(subscribed.topic, `community/user/${userId}`);
socket.emit('subscribe', `community/user/${otherUserId}`);
const error = await once(socket, 'error');
assert.equal(error.code, 'FORBIDDEN_TOPIC');
socket.close();
});
await t.test('invalid community topics are rejected', async () => {
const userId = randomUuid();
const socket = connect({ token: connectToken(userId) });
await once(socket, 'connect');
socket.emit('subscribe', 'community/user/not-a-uuid');
const error = await once(socket, 'error');
assert.equal(error.code, 'INVALID_TOPIC');
socket.close();
});
await t.test('event stats require a matching topic token', async () => {
const userId = randomUuid();
const eventTopic = 'event/test-event/ticket_statistics';