Move previous suspendUser feature to rejectUsername

This commit is contained in:
Chi Vinh Le
2017-05-18 02:28:01 +07:00
parent 056ff427a5
commit 76e87f4c34
13 changed files with 146 additions and 57 deletions
+11 -2
View File
@@ -5,8 +5,12 @@ const setUserStatus = ({user}, {id, status}) => {
return UsersService.setStatus(id, status);
};
const suspendUser = ({user}, {id, message, mustChangeUsername, until}) => {
return UsersService.suspendUser(id, message, mustChangeUsername, until);
const suspendUser = ({user}, {id, message, until}) => {
return UsersService.suspendUser(id, message, until);
};
const rejectUsername = ({user}, {id, message}) => {
return UsersService.rejectUsername(id, message);
};
const ignoreUser = ({user}, userToIgnore) => {
@@ -22,6 +26,7 @@ module.exports = (context) => {
User: {
setUserStatus: () => Promise.reject(errors.ErrNotAuthorized),
suspendUser: () => Promise.reject(errors.ErrNotAuthorized),
rejectUsername: () => Promise.reject(errors.ErrNotAuthorized),
ignoreUser: (action) => ignoreUser(context, action),
stopIgnoringUser: (action) => stopIgnoringUser(context, action),
}
@@ -35,5 +40,9 @@ module.exports = (context) => {
mutators.User.suspendUser = (action) => suspendUser(context, action);
}
if (context.user && context.user.can('mutation:rejectUsername')) {
mutators.User.rejectUsername = (action) => rejectUsername(context, action);
}
return mutators;
};
+5 -2
View File
@@ -20,8 +20,11 @@ const RootMutation = {
setUserStatus(_, {id, status}, {mutators: {User}}) {
return wrapResponse(null)(User.setUserStatus({id, status}));
},
suspendUser(_, {input: {id, message, mustChangeUsername, until}}, {mutators: {User}}) {
return wrapResponse(null)(User.suspendUser({id, message, mustChangeUsername, until}));
suspendUser(_, {input: {id, message, until}}, {mutators: {User}}) {
return wrapResponse(null)(User.suspendUser({id, message, until}));
},
rejectUsername(_, {input: {id, message}}, {mutators: {User}}) {
return wrapResponse(null)(User.rejectUsername({id, message}));
},
ignoreUser(_, {id}, {mutators: {User}}) {
return wrapResponse(null)(User.ignoreUser({id}));
+22 -3
View File
@@ -679,13 +679,21 @@ input SuspendUserInput {
# TODO: should this be required?
message: String
# If set, the user is requested to change its username.
mustChangeUsername: Boolean
# If set, the suspension lasts at least until specified date.
until: Date
}
# Input for rejectUsername mutation.
input RejectUsernameInput {
# id of target user.
id: ID!
# message to be sent to the user.
# TODO: should this be required?
message: String
}
# DeleteActionResponse is the response returned with possibly some errors
# relating to the delete action attempt.
type DeleteActionResponse implements Response {
@@ -710,6 +718,14 @@ type SuspendUserResponse implements Response {
errors: [UserError]
}
# RejectUsernameResponse is the response returned with possibly some errors
# relating to the reject username action attempt.
type RejectUsernameResponse implements Response {
# An array of errors relating to the mutation that occurred.
errors: [UserError]
}
# SetCommentStatusResponse is the response returned with possibly some errors
# relating to the delete action attempt.
type SetCommentStatusResponse implements Response {
@@ -785,6 +801,9 @@ type RootMutation {
# Suspends a user. Requires the `ADMIN` role.
suspendUser(input: SuspendUserInput!): SuspendUserResponse
# Suspends a user. Requires the `ADMIN` role.
rejectUsername(input: RejectUsernameInput!): RejectUsernameResponse
# Sets Comment status. Requires the `ADMIN` role.
setCommentStatus(id: ID!, status: COMMENT_STATUS!): SetCommentStatusResponse