forked from hippoz/brainlet
maybe fix weird crash
This commit is contained in:
parent
fd7489976d
commit
de6a66a877
1 changed files with 3 additions and 3 deletions
|
@ -81,7 +81,7 @@ GatewayServer.prototype.eventSetup = function() {
|
||||||
socket.isConnected = true;
|
socket.isConnected = true;
|
||||||
|
|
||||||
socket.on('message', ({ category, content }) => {
|
socket.on('message', ({ category, content }) => {
|
||||||
if (!category || !content) return;
|
if (!category || !content || !socket.joinedCategories || !socket.isConnected || !socket.user) return;
|
||||||
content = content.trim();
|
content = content.trim();
|
||||||
if (!content || content === '' || content === ' ') return;
|
if (!content || content === '' || content === ' ') return;
|
||||||
|
|
||||||
|
@ -102,12 +102,12 @@ GatewayServer.prototype.eventSetup = function() {
|
||||||
_id: uuid.v4()
|
_id: uuid.v4()
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.to(category._id).emit('message', messageObject);
|
socket.broadcast.to(category._id).emit('message', messageObject);
|
||||||
socket.emit('message', messageObject);
|
socket.emit('message', messageObject);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('subscribe', async (categories) => {
|
socket.on('subscribe', async (categories) => {
|
||||||
if (!categories || !Array.isArray(categories) || categories === []) return;
|
if ( !socket.isConnected || !socket.user || !categories || !Array.isArray(categories) || categories === []) return;
|
||||||
for (const v of categories) {
|
for (const v of categories) {
|
||||||
if (!v) continue;
|
if (!v) continue;
|
||||||
// TODO: When/if category permissions are added, check if the user has permissions for that category
|
// TODO: When/if category permissions are added, check if the user has permissions for that category
|
||||||
|
|
Loading…
Reference in a new issue