From b655e18cee09acdf70470a790a081c7e20a93dfe Mon Sep 17 00:00:00 2001
From: psychobunny <psycho.bunny@hotmail.com>
Date: Fri, 19 Jun 2015 17:10:18 -0400
Subject: [PATCH] action:posts.flag

---
 src/socket.io/posts.js | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js
index ad3da08ddd..93886291bb 100644
--- a/src/socket.io/posts.js
+++ b/src/socket.io/posts.js
@@ -466,7 +466,7 @@ SocketPosts.flag = function(socket, pid, callback) {
 	}
 
 	var message = '',
-		userName = '',
+		flaggingUser = {},
 		post;
 
 	async.waterfall([
@@ -477,7 +477,9 @@ SocketPosts.flag = function(socket, pid, callback) {
 			if (parseInt(userData.reputation, 10) < parseInt(meta.config['privileges:flag'] || 1, 10)) {
 				return next(new Error('[[error:not-enough-reputation-to-flag]]'));
 			}
-			userName = userData.username;
+			flaggingUser = userData;
+			flaggingUser.uid = socket.uid;
+
 			posts.getPostFields(pid, ['pid', 'tid', 'uid', 'content', 'deleted'], next);
 		},
 		function(postData, next) {
@@ -492,7 +494,7 @@ SocketPosts.flag = function(socket, pid, callback) {
 		},
 		function(topic, next) {
 			post.topic = topic;
-			message = '[[notifications:user_flagged_post_in, ' + userName + ', ' + topic.title + ']]';
+			message = '[[notifications:user_flagged_post_in, ' + flaggingUser.username + ', ' + topic.title + ']]';
 			posts.parsePost(post, next);
 		},
 		function(post, next) {
@@ -516,6 +518,8 @@ SocketPosts.flag = function(socket, pid, callback) {
 				if (err || !notification) {
 					return next(err);
 				}
+
+				plugins.fireHook('action:posts.flag', {post: post, flaggingUser: flaggingUser});
 				notifications.push(notification, results.admins.concat(results.moderators), next);
 			});
 		}