Compare commits
2 commits
31798c60a2
...
da3962b9f1
Author | SHA1 | Date | |
---|---|---|---|
|
da3962b9f1 | ||
|
6c5470e6b1 |
1 changed files with 19 additions and 15 deletions
|
@ -226,21 +226,25 @@ GatewayServer.prototype.eventSetup = function() {
|
|||
|
||||
socket.on('subscribe', async (categories) => {
|
||||
if ( !socket.isConnected || !socket.user || !categories || !Array.isArray(categories) || categories === []) return;
|
||||
for (const v of categories) {
|
||||
if (!v && !(typeof v === 'string')) continue;
|
||||
// TODO: When/if category permissions are added, check if the user has permissions for that category
|
||||
const category = await Category.findById(v);
|
||||
if (category && category.title && category._id) {
|
||||
if (!socket.joinedCategories) socket.joinedCategories = {};
|
||||
if (socket.joinedCategories[v]) continue;
|
||||
socket.joinedCategories[v] = category.title;
|
||||
await socket.join(v);
|
||||
try {
|
||||
for (const v of categories) {
|
||||
if (!v && !(typeof v === 'string')) continue;
|
||||
// TODO: When/if category permissions are added, check if the user has permissions for that category
|
||||
const category = await Category.findById(v);
|
||||
if (category && category.title && category._id) {
|
||||
if (!socket.joinedCategories) socket.joinedCategories = {};
|
||||
if (socket.joinedCategories[v]) continue;
|
||||
socket.joinedCategories[v] = category.title;
|
||||
await socket.join(v);
|
||||
|
||||
console.log(`[*] [gateway] User ${socket.user.username} subscribed to room ${v} (${category.title}), sending updated user list to all members of that room...`);
|
||||
console.log(`[*] [gateway] User ${socket.user.username} subscribed to room ${v} (${category.title}), sending updated user list to all members of that room...`);
|
||||
|
||||
const upd = await this._generateClientListUpdateObject(v, category.title);
|
||||
this._gateway.in(v).emit('clientListUpdate', upd);
|
||||
const upd = await this._generateClientListUpdateObject(v, category.title);
|
||||
this._gateway.in(v).emit('clientListUpdate', upd);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Reference in a new issue