mirror of
https://github.com/wassname/talk.git
synced 2026-07-05 21:24:47 +08:00
Merge branch 'master' into update-on-post-comment
This commit is contained in:
@@ -45,10 +45,6 @@ const deleteAction = ({user}, {id}) => {
|
||||
};
|
||||
|
||||
module.exports = (context) => {
|
||||
|
||||
// TODO: refactor to something that'll return an error in the event an attempt
|
||||
// is made to mutate state while not logged in. There's got to be a better way
|
||||
// to do this.
|
||||
if (context.user && context.user.can('mutation:createAction', 'mutation:deleteAction')) {
|
||||
return {
|
||||
Action: {
|
||||
|
||||
@@ -169,16 +169,26 @@ const createPublicComment = (context, commentInput) => {
|
||||
* @param {String} status the new status of the comment
|
||||
*/
|
||||
|
||||
const setCommentStatus = ({comment}, {id, status}) => {
|
||||
return CommentsService.setStatus(id, status)
|
||||
.then(res => res);
|
||||
const setCommentStatus = ({loaders: {Comments}}, {id, status}) => {
|
||||
return CommentsService
|
||||
.setStatus(id, status)
|
||||
.then((comment) => {
|
||||
|
||||
// If the loaders are present, clear the caches for these values because we
|
||||
// just added a new comment, hence the counts should be updated.
|
||||
if (Comments && Comments.countByAssetID && Comments.countByParentID) {
|
||||
if (comment.parent_id != null) {
|
||||
Comments.countByParentID.clear(comment.parent_id);
|
||||
} else {
|
||||
Comments.countByAssetID.clear(comment.asset_id);
|
||||
}
|
||||
}
|
||||
|
||||
return comment;
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = (context) => {
|
||||
|
||||
// TODO: refactor to something that'll return an error in the event an attempt
|
||||
// is made to mutate state while not logged in. There's got to be a better way
|
||||
// to do this.
|
||||
let mutators = {
|
||||
Comment: {
|
||||
create: () => Promise.reject(errors.ErrNotAuthorized),
|
||||
|
||||
@@ -7,10 +7,6 @@ const setUserStatus = ({user}, {id, status}) => {
|
||||
};
|
||||
|
||||
module.exports = (context) => {
|
||||
|
||||
// TODO: refactor to something that'll return an error in the event an attempt
|
||||
// is made to mutate state while not logged in. There's got to be a better way
|
||||
// to do this.
|
||||
if (context.user && context.user.can('mutation:setUserStatus')) {
|
||||
return {
|
||||
User: {
|
||||
|
||||
@@ -273,7 +273,7 @@ module.exports = class CommentsService {
|
||||
return Promise.reject(new Error(`status ${status} is not supported`));
|
||||
}
|
||||
|
||||
return CommentModel.update({id}, {
|
||||
return CommentModel.findOneAndUpdate({id}, {
|
||||
$set: {status}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user