Skip to content

Node.js based forum software built for the modern web

feat: #8475, allow flagging self posts

Barış Soner Uşaklıa6afcfd53104
diff --git a/public/language/en-GB/flags.json b/public/language/en-GB/flags.json
index 10698842cc..13b3567bc9 100644
--- a/public/language/en-GB/flags.json
+++ b/public/language/en-GB/flags.json
@@ -67,7 +67,7 @@
"sort-upvotes": "Most upvotes",
"sort-replies": "Most replies",
- "modal-title": "Report Inappropriate Content",
+ "modal-title": "Report Content",
"modal-body": "Please specify your reason for flagging %1 %2 for review. Alternatively, use one of the quick report buttons if applicable.",
"modal-reason-spam": "Spam",
"modal-reason-offensive": "Offensive",
diff --git a/src/flags.js b/src/flags.js
index 3292cdd946..98ecfb2251 100644
--- a/src/flags.js
+++ b/src/flags.js
@@ -257,6 +257,9 @@ Flags.validate = async function (payload) {
throw new Error('[[error:not-enough-reputation-to-flag]]');
}
} else if (payload.type === 'user') {
+ if (parseInt(payload.id, 10) === parseInt(payload.uid, 10)) {
+ throw new Error('[[error:cant-flag-self]]');
+ }
const editable = await privileges.users.canEdit(payload.uid, payload.id);
if (!editable && !meta.config['reputation:disabled'] && reporter.reputation < meta.config['min:rep:flag']) {
throw new Error('[[error:not-enough-reputation-to-flag]]');
@@ -395,7 +398,7 @@ Flags.create = async function (type, id, uid, reason, timestamp) {
posts.setPostField(id, 'flagId', flagId)
);
- if (targetUid) {
+ if (targetUid && parseInt(targetUid, 10) !== parseInt(uid, 10)) {
batched.push(user.incrementUserFlagsBy(targetUid, 1));
}
} else if (type === 'user') {
diff --git a/src/socket.io/posts/tools.js b/src/socket.io/posts/tools.js
index a0e4ae4715..b62f651e7a 100644
--- a/src/socket.io/posts/tools.js
+++ b/src/socket.io/posts/tools.js
@@ -42,7 +42,7 @@ module.exports = function (SocketPosts) {
postData.display_edit_tools = results.canEdit.flag;
postData.display_delete_tools = results.canDelete.flag;
postData.display_purge_tools = results.canPurge;
- postData.display_flag_tools = socket.uid && !postData.selfPost && results.canFlag.flag;
+ postData.display_flag_tools = socket.uid && results.canFlag.flag;
postData.display_moderator_tools = postData.display_edit_tools || postData.display_delete_tools;
postData.display_move_tools = results.isAdmin || results.isModerator;
postData.display_change_owner_tools = results.isAdmin || results.isModerator;