mirror of
https://github.com/wassname/talk.git
synced 2026-08-12 12:30:39 +08:00
addCommentTag mutation works
This commit is contained in:
@@ -187,11 +187,20 @@ const setCommentStatus = ({loaders: {Comments}}, {id, status}) => {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a tag to a Comment
|
||||
*/
|
||||
const addCommentTag = ({user, loaders: {Comments}}, {id, tag}) => {
|
||||
return CommentsService.addTag(id, tag, user.id)
|
||||
.then(() => CommentsService.findById( id ));
|
||||
};
|
||||
|
||||
module.exports = (context) => {
|
||||
let mutators = {
|
||||
Comment: {
|
||||
create: () => Promise.reject(errors.ErrNotAuthorized),
|
||||
setCommentStatus: () => Promise.reject(errors.ErrNotAuthorized)
|
||||
setCommentStatus: () => Promise.reject(errors.ErrNotAuthorized),
|
||||
addCommentTag: () => Promise.reject(errors.ErrNotAuthorized),
|
||||
}
|
||||
};
|
||||
|
||||
@@ -203,5 +212,9 @@ module.exports = (context) => {
|
||||
mutators.Comment.setCommentStatus = (action) => setCommentStatus(context, action);
|
||||
}
|
||||
|
||||
if (context.user && context.user.can('mutation:addCommentTag')) {
|
||||
mutators.Comment.addCommentTag = (action) => addCommentTag(context, action);
|
||||
}
|
||||
|
||||
return mutators;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user