mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-01 00:08:53 +02:00
closes #6514
This commit is contained in:
@@ -5,7 +5,7 @@ var async = require('async');
|
||||
var meta = require('../meta');
|
||||
var plugins = require('../plugins');
|
||||
var db = require('../database');
|
||||
|
||||
var user = require('../user');
|
||||
|
||||
module.exports = function (Messaging) {
|
||||
Messaging.sendMessage = function (uid, roomId, content, timestamp, callback) {
|
||||
@@ -73,6 +73,9 @@ module.exports = function (Messaging) {
|
||||
isNewSet = _isNewSet;
|
||||
db.getSortedSetRange('chat:room:' + roomId + ':uids', 0, -1, next);
|
||||
},
|
||||
function (uids, next) {
|
||||
user.blocks.filterUids(fromuid, uids, next);
|
||||
},
|
||||
function (uids, next) {
|
||||
async.parallel([
|
||||
async.apply(Messaging.addRoomToUsers, roomId, uids, timestamp),
|
||||
|
||||
@@ -18,11 +18,7 @@ module.exports = function (Messaging) {
|
||||
Messaging.getUidsInRoom(roomId, 0, -1, next);
|
||||
},
|
||||
function (uids, next) {
|
||||
async.filter(uids, function (uid, next) {
|
||||
user.blocks.is(fromUid, uid, function (err, blocked) {
|
||||
next(err, !blocked);
|
||||
});
|
||||
}, next);
|
||||
user.blocks.filterUids(fromUid, uids, next);
|
||||
},
|
||||
function (uids, next) {
|
||||
var data = {
|
||||
|
||||
@@ -286,16 +286,9 @@ function pushToUids(uids, notification, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
// Remove uid from recipients list if they have blocked the user triggering the notification
|
||||
async.filter(uids, function (uid, next) {
|
||||
User.blocks.is(notification.from, uid, function (err, blocked) {
|
||||
next(err, !blocked);
|
||||
});
|
||||
}, function (err, _uids) {
|
||||
uids = _uids;
|
||||
next(err);
|
||||
});
|
||||
User.blocks.filterUids(notification.from, uids, next);
|
||||
},
|
||||
function (next) {
|
||||
function (uids, next) {
|
||||
plugins.fireHook('filter:notification.push', { notification: notification, uids: uids }, next);
|
||||
},
|
||||
function (data, next) {
|
||||
|
||||
@@ -76,6 +76,14 @@ module.exports = function (User) {
|
||||
});
|
||||
};
|
||||
|
||||
User.blocks.filterUids = function (targetUid, uids, callback) {
|
||||
async.filter(uids, function (uid, next) {
|
||||
User.blocks.is(targetUid, uid, function (err, blocked) {
|
||||
next(err, !blocked);
|
||||
});
|
||||
}, callback);
|
||||
};
|
||||
|
||||
User.blocks.filter = function (uid, property, set, callback) {
|
||||
// Given whatever is passed in, iterates through it, and removes entries made by blocked uids
|
||||
// property is optional
|
||||
|
||||
Reference in New Issue
Block a user