mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: #8475, allow flagging self posts
dont count flags towards self posts dont allow flagging your own account
This commit is contained in:
@@ -67,7 +67,7 @@
|
|||||||
"sort-upvotes": "Most upvotes",
|
"sort-upvotes": "Most upvotes",
|
||||||
"sort-replies": "Most replies",
|
"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-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-spam": "Spam",
|
||||||
"modal-reason-offensive": "Offensive",
|
"modal-reason-offensive": "Offensive",
|
||||||
|
|||||||
@@ -257,6 +257,9 @@ Flags.validate = async function (payload) {
|
|||||||
throw new Error('[[error:not-enough-reputation-to-flag]]');
|
throw new Error('[[error:not-enough-reputation-to-flag]]');
|
||||||
}
|
}
|
||||||
} else if (payload.type === 'user') {
|
} 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);
|
const editable = await privileges.users.canEdit(payload.uid, payload.id);
|
||||||
if (!editable && !meta.config['reputation:disabled'] && reporter.reputation < meta.config['min:rep:flag']) {
|
if (!editable && !meta.config['reputation:disabled'] && reporter.reputation < meta.config['min:rep:flag']) {
|
||||||
throw new Error('[[error:not-enough-reputation-to-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)
|
posts.setPostField(id, 'flagId', flagId)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (targetUid) {
|
if (targetUid && parseInt(targetUid, 10) !== parseInt(uid, 10)) {
|
||||||
batched.push(user.incrementUserFlagsBy(targetUid, 1));
|
batched.push(user.incrementUserFlagsBy(targetUid, 1));
|
||||||
}
|
}
|
||||||
} else if (type === 'user') {
|
} else if (type === 'user') {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ module.exports = function (SocketPosts) {
|
|||||||
postData.display_edit_tools = results.canEdit.flag;
|
postData.display_edit_tools = results.canEdit.flag;
|
||||||
postData.display_delete_tools = results.canDelete.flag;
|
postData.display_delete_tools = results.canDelete.flag;
|
||||||
postData.display_purge_tools = results.canPurge;
|
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_moderator_tools = postData.display_edit_tools || postData.display_delete_tools;
|
||||||
postData.display_move_tools = results.isAdmin || results.isModerator;
|
postData.display_move_tools = results.isAdmin || results.isModerator;
|
||||||
postData.display_change_owner_tools = results.isAdmin || results.isModerator;
|
postData.display_change_owner_tools = results.isAdmin || results.isModerator;
|
||||||
|
|||||||
Reference in New Issue
Block a user