mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
closed #2321
This commit is contained in:
@@ -292,6 +292,34 @@ var db = require('./database'),
|
||||
}, 1000*60); // wait 60s before sending
|
||||
};
|
||||
|
||||
Messaging.canMessage = function(fromUid, toUid, callback) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
// Check if the sending user is an admin
|
||||
user.isAdministrator(fromUid, function(err, isAdmin) {
|
||||
next(err || isAdmin);
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
// Retrieve the recipient's user setting
|
||||
user.getSettings(toUid, function(err, settings) {
|
||||
next(err || !settings.restrictChat);
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
// Does toUid follow fromUid?
|
||||
user.isFollowing(toUid, fromUid, next);
|
||||
}
|
||||
], function(err, allowed) {
|
||||
// Handle premature returns
|
||||
if (err === true) {
|
||||
return callback(undefined, true);
|
||||
}
|
||||
|
||||
callback.apply(this, arguments);
|
||||
});
|
||||
}
|
||||
|
||||
function sendNotifications(fromuid, touid, messageObj, callback) {
|
||||
// todo #1798 -- this should check if the user is in room `chat_{uidA}_{uidB}` instead, see `Sockets.uidInRoom(uid, room);`
|
||||
if (!websockets.isUserOnline(touid)) {
|
||||
|
||||
Reference in New Issue
Block a user