mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +01:00 
			
		
		
		
	allow moderators/admins with 0 rep to still be able to flag a post
This commit is contained in:
		| @@ -471,30 +471,50 @@ SocketPosts.flag = function(socket, pid, callback) { | |||||||
|  |  | ||||||
| 	async.waterfall([ | 	async.waterfall([ | ||||||
| 		function(next) { | 		function(next) { | ||||||
| 			user.getUserFields(socket.uid, ['username', 'reputation'], next); | 			posts.getPostFields(pid, ['pid', 'tid', 'uid', 'content', 'deleted'], function(err, postData) { | ||||||
| 		}, |  | ||||||
| 		function(userData, next) { |  | ||||||
| 			if (parseInt(userData.reputation, 10) < parseInt(meta.config['privileges:flag'] || 1, 10)) { |  | ||||||
| 				return next(new Error('[[error:not-enough-reputation-to-flag]]')); |  | ||||||
| 			} |  | ||||||
| 			flaggingUser = userData; |  | ||||||
| 			flaggingUser.uid = socket.uid; |  | ||||||
|  |  | ||||||
| 			posts.getPostFields(pid, ['pid', 'tid', 'uid', 'content', 'deleted'], next); |  | ||||||
| 		}, |  | ||||||
| 		function(postData, next) { |  | ||||||
| 				if (parseInt(postData.deleted, 10) === 1) { | 				if (parseInt(postData.deleted, 10) === 1) { | ||||||
| 					return next(new Error('[[error:post-deleted]]')); | 					return next(new Error('[[error:post-deleted]]')); | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				post = postData; | 				post = postData; | ||||||
|  | 				next(); | ||||||
|  | 			}); | ||||||
|  | 		}, | ||||||
|  | 		function(next) { | ||||||
|  | 			topics.getTopicFields(post.tid, ['title', 'cid'], function(err, topicData) { | ||||||
|  | 				post.topic = topicData; | ||||||
|  | 				next(); | ||||||
|  | 			}); | ||||||
|  | 		}, | ||||||
|  | 		function(next) { | ||||||
|  | 			async.parallel({ | ||||||
|  | 				isAdmin: function(next) { | ||||||
|  | 					user.isAdministrator(socket.uid, next); | ||||||
|  | 				}, | ||||||
|  | 				isModerator: function(next) { | ||||||
|  | 					user.isModerator(socket.uid, post.topic.cid, next); | ||||||
|  | 				}, | ||||||
|  | 				userData: function(next) { | ||||||
|  | 					user.getUserFields(socket.uid, ['username', 'reputation'], next); | ||||||
|  | 				} | ||||||
|  | 			}, next); | ||||||
|  | 		}, | ||||||
|  | 		function(user, next) { | ||||||
|  | 			if (!user.isAdmin && !user.isModerator && parseInt(user.userData.reputation, 10) < parseInt(meta.config['privileges:flag'] || 1, 10)) { | ||||||
|  | 				return next(new Error('[[error:not-enough-reputation-to-flag]]')); | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			flaggingUser = user.userData; | ||||||
|  | 			flaggingUser.uid = socket.uid; | ||||||
|  |  | ||||||
|  | 			next(); | ||||||
|  | 		}, | ||||||
|  | 		function(next) { | ||||||
|  | 			console.log(post); | ||||||
| 			posts.flag(post, socket.uid, next); | 			posts.flag(post, socket.uid, next); | ||||||
| 		}, | 		}, | ||||||
| 		function(next) { | 		function(next) { | ||||||
| 			topics.getTopicFields(post.tid, ['title', 'cid'], next); | 			message = '[[notifications:user_flagged_post_in, ' + flaggingUser.username + ', ' + post.topic.title + ']]'; | ||||||
| 		}, |  | ||||||
| 		function(topic, next) { |  | ||||||
| 			post.topic = topic; |  | ||||||
| 			message = '[[notifications:user_flagged_post_in, ' + flaggingUser.username + ', ' + topic.title + ']]'; |  | ||||||
| 			posts.parsePost(post, next); | 			posts.parsePost(post, next); | ||||||
| 		}, | 		}, | ||||||
| 		function(post, next) { | 		function(post, next) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user