mirror of
https://github.com/wassname/talk.git
synced 2026-08-12 12:30:39 +08:00
Merge branch 'next' into user-status-refactor
This commit is contained in:
@@ -52,13 +52,11 @@ const RootMutation = {
|
||||
setCommentStatus: async (_, {id, status}, {mutators: {Comment}, pubsub}) => {
|
||||
const comment = await Comment.setStatus({id, status});
|
||||
if (status === 'ACCEPTED') {
|
||||
|
||||
// Publish the comment status change via the subscription.
|
||||
pubsub.publish('commentAccepted', comment);
|
||||
} else if (status === 'REJECTED') {
|
||||
|
||||
// Publish the comment status change via the subscription.
|
||||
pubsub.publish('commentRejected', comment);
|
||||
} else if (status === 'NONE') {
|
||||
pubsub.publish('commentReset', comment);
|
||||
}
|
||||
},
|
||||
addTag: async (_, {tag}, {mutators: {Tag}}) => {
|
||||
|
||||
@@ -11,6 +11,9 @@ const Subscription = {
|
||||
commentRejected(comment) {
|
||||
return comment;
|
||||
},
|
||||
commentReset(comment) {
|
||||
return comment;
|
||||
},
|
||||
commentFlagged(comment) {
|
||||
return comment;
|
||||
},
|
||||
|
||||
@@ -2,6 +2,7 @@ const {
|
||||
SUBSCRIBE_COMMENT_ACCEPTED,
|
||||
SUBSCRIBE_COMMENT_REJECTED,
|
||||
SUBSCRIBE_COMMENT_FLAGGED,
|
||||
SUBSCRIBE_COMMENT_RESET,
|
||||
SUBSCRIBE_ALL_COMMENT_EDITED,
|
||||
SUBSCRIBE_ALL_COMMENT_ADDED,
|
||||
SUBSCRIBE_ALL_USER_SUSPENDED,
|
||||
@@ -59,12 +60,18 @@ const setupFunctions = {
|
||||
}
|
||||
return !args.asset_id || comment.asset_id === args.asset_id;
|
||||
},
|
||||
commentRejected: (options, args) => (comment, context) => {
|
||||
commentRejected: (options, args, comment, context) => {
|
||||
if (!context.user || !context.user.can(SUBSCRIBE_COMMENT_REJECTED)) {
|
||||
return false;
|
||||
}
|
||||
return !args.asset_id || comment.asset_id === args.asset_id;
|
||||
},
|
||||
commentReset: (options, args, comment, context) => {
|
||||
if (!context.user || !context.user.can(SUBSCRIBE_COMMENT_RESET)) {
|
||||
return false;
|
||||
}
|
||||
return !args.asset_id || comment.asset_id === args.asset_id;
|
||||
},
|
||||
userSuspended: (options, args, user, context) => {
|
||||
if (
|
||||
!context.user
|
||||
|
||||
@@ -1499,6 +1499,10 @@ type Subscription {
|
||||
# Requires the `ADMIN` or `MODERATOR` role.
|
||||
commentRejected(asset_id: ID): Comment
|
||||
|
||||
# Get an update whenever the status of a comment has been reset.
|
||||
# Requires the `ADMIN` or `MODERATOR` role.
|
||||
commentReset(asset_id: ID): Comment
|
||||
|
||||
# Get an update whenever a user has been suspended.
|
||||
# `user_id` must match id of current user except for
|
||||
# users with the `ADMIN` or `MODERATOR` role.
|
||||
|
||||
Reference in New Issue
Block a user