mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	closed #2695
This commit is contained in:
		| @@ -19,14 +19,14 @@ module.exports = function(privileges) { | |||||||
| 			labels: function(next) { | 			labels: function(next) { | ||||||
| 				async.parallel({ | 				async.parallel({ | ||||||
| 					users: async.apply(plugins.fireHook, 'filter:privileges.list_human', | 					users: async.apply(plugins.fireHook, 'filter:privileges.list_human', | ||||||
| 						['Find category', 'Access & Read', 'Create Topics', 'Reply to Topics', 'Moderator'].map(function(name) { | 						['Find category', 'Access & Read', 'Create Topics', 'Reply to Topics', 'Moderate'].map(function(name) { | ||||||
| 							return { | 							return { | ||||||
| 								name: name | 								name: name | ||||||
| 							}; | 							}; | ||||||
| 						}) | 						}) | ||||||
| 					), | 					), | ||||||
| 					groups: async.apply(plugins.fireHook, 'filter:privileges.groups.list_human', | 					groups: async.apply(plugins.fireHook, 'filter:privileges.groups.list_human', | ||||||
| 						['Find category', 'Access & Read', 'Create Topics', 'Reply to Topics'].map(function(name) { | 						['Find category', 'Access & Read', 'Create Topics', 'Reply to Topics', 'Moderate'].map(function(name) { | ||||||
| 							return { | 							return { | ||||||
| 								name: name | 								name: name | ||||||
| 							}; | 							}; | ||||||
| @@ -73,7 +73,7 @@ module.exports = function(privileges) { | |||||||
| 				var privileges; | 				var privileges; | ||||||
| 				async.waterfall([ | 				async.waterfall([ | ||||||
| 					async.apply(plugins.fireHook, 'filter:privileges.groups.list', [ | 					async.apply(plugins.fireHook, 'filter:privileges.groups.list', [ | ||||||
| 						'groups:find', 'groups:read', 'groups:topics:create', 'groups:topics:reply' | 						'groups:find', 'groups:read', 'groups:topics:create', 'groups:topics:reply', 'groups:moderate' | ||||||
| 					]), | 					]), | ||||||
| 					function(privs, next) { | 					function(privs, next) { | ||||||
| 						privileges = privs; | 						privileges = privs; | ||||||
|   | |||||||
							
								
								
									
										34
									
								
								src/user.js
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								src/user.js
									
									
									
									
									
								
							| @@ -415,15 +415,25 @@ var	async = require('async'), | |||||||
| 			}); | 			}); | ||||||
|  |  | ||||||
| 			var groupNames = uniqueCids.map(function(cid) { | 			var groupNames = uniqueCids.map(function(cid) { | ||||||
| 				return 'cid:' + cid + ':privileges:mods'; | 					return 'cid:' + cid + ':privileges:mods';	// At some point we should *probably* change this to "moderate" as well | ||||||
|  | 				}), | ||||||
|  | 				groupListNames = uniqueCids.map(function(cid) { | ||||||
|  | 					return 'cid:' + cid + ':privileges:groups:moderate'; | ||||||
| 				}); | 				}); | ||||||
|  |  | ||||||
| 			groups.isMemberOfGroups(uid, groupNames, function(err, isMembers) { | 			async.parallel({ | ||||||
|  | 				user: async.apply(groups.isMemberOfGroups, uid, groupNames), | ||||||
|  | 				group: async.apply(groups.isMemberOfGroupsList, uid, groupListNames) | ||||||
|  | 			}, function(err, checks) { | ||||||
| 				if (err) { | 				if (err) { | ||||||
| 					return callback(err); | 					return callback(err); | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				var map = {}; | 				var isMembers = checks.user.map(function(isMember, idx) { | ||||||
|  | 						return isMember || checks.group[idx] | ||||||
|  | 					}), | ||||||
|  | 					map = {}; | ||||||
|  |  | ||||||
| 				uniqueCids.forEach(function(cid, index) { | 				uniqueCids.forEach(function(cid, index) { | ||||||
| 					map[cid] = isMembers[index]; | 					map[cid] = isMembers[index]; | ||||||
| 				}); | 				}); | ||||||
| @@ -434,9 +444,23 @@ var	async = require('async'), | |||||||
| 			}); | 			}); | ||||||
| 		} else { | 		} else { | ||||||
| 			if (Array.isArray(uid)) { | 			if (Array.isArray(uid)) { | ||||||
| 				groups.isMembers(uid, 'cid:' + cid + ':privileges:mods', filterIsModerator); | 				async.parallel([ | ||||||
|  | 					async.apply(groups.isMembers, uid, 'cid:' + cid + ':privileges:mods'), | ||||||
|  | 					async.apply(groups.isMembers, uid, 'cid:' + cid + ':privileges:groups:moderate') | ||||||
|  | 				], function(err, checks) { | ||||||
|  | 					var isModerator = checks[0].map(function(isMember, idx) { | ||||||
|  | 							return isMember || checks[1][idx] | ||||||
|  | 						}); | ||||||
|  | 					filterIsModerator(null, isModerator); | ||||||
|  | 				}); | ||||||
| 			} else { | 			} else { | ||||||
| 				groups.isMember(uid, 'cid:' + cid + ':privileges:mods', filterIsModerator); | 				async.parallel([ | ||||||
|  | 					async.apply(groups.isMember, uid, 'cid:' + cid + ':privileges:mods'), | ||||||
|  | 					async.apply(groups.isMember, uid, 'cid:' + cid + ':privileges:groups:moderate') | ||||||
|  | 				], function(err, checks) { | ||||||
|  | 					var isModerator = checks[0] || checks[1]; | ||||||
|  | 					filterIsModerator(null, isModerator); | ||||||
|  | 				}); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	}; | 	}; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user