mirror of
https://github.com/wassname/talk.git
synced 2026-07-20 12:40:47 +08:00
add permission for EDIT_COMMENT
This commit is contained in:
@@ -99,7 +99,7 @@ const resolveNewCommentStatus = async (context, {asset_id, body}, wordlist = {},
|
||||
if (wordlist.banned) {
|
||||
return 'REJECTED';
|
||||
}
|
||||
|
||||
|
||||
if (settings.premodLinksEnable && linkify.test(body)) {
|
||||
return 'PREMOD';
|
||||
}
|
||||
@@ -229,7 +229,7 @@ const edit = async (context, {id, asset_id, edit: {body}}) => {
|
||||
const [wordlist, settings] = await filterNewComment(context, {asset_id, body});
|
||||
|
||||
// Determine the new status of the comment.
|
||||
const status = await resolveNewCommentStatus(context, {asset_id, body}, wordlist, settings);
|
||||
const status = await resolveNewCommentStatus(context, {asset_id, body}, wordlist, settings);
|
||||
|
||||
// Execute the edit.
|
||||
await CommentsService.edit(id, context.user.id, {body, status});
|
||||
@@ -264,7 +264,7 @@ module.exports = (context) => {
|
||||
mutators.Comment.removeCommentTag = (action) => removeCommentTag(context, action);
|
||||
}
|
||||
|
||||
if (context.user && context.user.can('mutation:editComment')) {
|
||||
if (context.user && context.user.can('EDIT_COMMENT')) {
|
||||
mutators.Comment.edit = (action) => edit(context, action);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ module.exports = {
|
||||
CREATE_ACTION: 'CREATE_ACTION',
|
||||
DELETE_ACTION: 'DELETE_ACTION',
|
||||
EDIT_NAME: 'EDIT_NAME',
|
||||
EDIT_COMMENT: 'EDIT_COMMENT',
|
||||
SET_USER_STATUS: 'SET_USER_STATUS',
|
||||
SUSPEND_USER: 'SUSPEND_USER',
|
||||
SET_COMMENT_STATUS: 'SET_COMMENT_STATUS',
|
||||
@@ -25,6 +26,8 @@ module.exports = {
|
||||
return true;
|
||||
case this.EDIT_NAME:
|
||||
return true;
|
||||
case this.EDIT_COMMENT:
|
||||
return true;
|
||||
case this.UPDATE_USER_ROLES:
|
||||
return check(user, ['ADMIN']);
|
||||
case this.SET_USER_STATUS:
|
||||
|
||||
Reference in New Issue
Block a user