mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
leaveRoom method, small fixes
This commit is contained in:
@@ -261,6 +261,13 @@ app.cacheBuster = null;
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
app.newChat = function (touid) {
|
||||||
|
if (!app.user.uid) {
|
||||||
|
return app.alertError('[[error:not-logged-in]]');
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
var titleObj = {
|
var titleObj = {
|
||||||
active: false,
|
active: false,
|
||||||
interval: undefined,
|
interval: undefined,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ chatsController.get = function(req, res, callback) {
|
|||||||
since: 'recent',
|
since: 'recent',
|
||||||
isNew: false
|
isNew: false
|
||||||
}),
|
}),
|
||||||
allowed: async.apply(messaging.canMessage, req.user.uid, req.params.roomid)
|
allowed: async.apply(messaging.canMessageRoom, req.user.uid, req.params.roomid)
|
||||||
}, next);
|
}, next);
|
||||||
}
|
}
|
||||||
], function(err, data) {
|
], function(err, data) {
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ var async = require('async'),
|
|||||||
require('./messaging/unread')(Messaging);
|
require('./messaging/unread')(Messaging);
|
||||||
require('./messaging/notifications')(Messaging);
|
require('./messaging/notifications')(Messaging);
|
||||||
|
|
||||||
Messaging.notifyQueue = {}; // Only used to notify a user of a new chat message, see Messaging.notifyUser
|
|
||||||
|
|
||||||
var terms = {
|
var terms = {
|
||||||
day: 86400000,
|
day: 86400000,
|
||||||
week: 604800000,
|
week: 604800000,
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ var sockets = require('../socket.io');
|
|||||||
|
|
||||||
module.exports = function(Messaging) {
|
module.exports = function(Messaging) {
|
||||||
|
|
||||||
|
Messaging.notifyQueue = {}; // Only used to notify a user of a new chat message, see Messaging.notifyUser
|
||||||
|
|
||||||
Messaging.notifyUsersInRoom = function(fromUid, roomId, messageObj) {
|
Messaging.notifyUsersInRoom = function(fromUid, roomId, messageObj) {
|
||||||
Messaging.getUidsInRoom(roomId, 0, -1, function(err, uids) {
|
Messaging.getUidsInRoom(roomId, 0, -1, function(err, uids) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -45,6 +45,17 @@ module.exports = function(Messaging) {
|
|||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Messaging.leaveRoom = function(uid, roomId, callback) {
|
||||||
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
db.sortedSetRemove('chat:room:' + roomId + ':uids', uid, next);
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
|
db.sortedSetRemove('uid:' + uid + ':chat:rooms', roomId, next);
|
||||||
|
}
|
||||||
|
], callback);
|
||||||
|
};
|
||||||
|
|
||||||
Messaging.getUidsInRoom = function(roomId, start, stop, callback) {
|
Messaging.getUidsInRoom = function(roomId, start, stop, callback) {
|
||||||
db.getSortedSetRange('chat:room:' + roomId + ':uids', start, stop, callback);
|
db.getSortedSetRange('chat:room:' + roomId + ':uids', start, stop, callback);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ SocketModules.chats.delete = function(socket, data, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SocketModules.chats.canMessage = function(socket, roomId, callback) {
|
SocketModules.chats.canMessage = function(socket, roomId, callback) {
|
||||||
Messaging.canMessage(socket.uid, roomId, function(err, allowed) {
|
Messaging.canMessageRoom(socket.uid, roomId, function(err, allowed) {
|
||||||
callback(!allowed ? new Error('[[error:chat-restricted]]') : undefined);
|
callback(!allowed ? new Error('[[error:chat-restricted]]') : undefined);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user