mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
replaced eslint:recommended with prettier
This commit is contained in:
@@ -1,65 +1,108 @@
|
||||
const RootMutation = {
|
||||
createComment: async (_, {input}, {mutators: {Comment}, loaders: {Actions}}) => {
|
||||
createComment: async (
|
||||
_,
|
||||
{ input },
|
||||
{ mutators: { Comment }, loaders: { Actions } }
|
||||
) => {
|
||||
const comment = await Comment.create(input);
|
||||
|
||||
// Retrieve actions that was assigned to comment.
|
||||
const actions = await Actions.getByID.load(comment.id);
|
||||
|
||||
return {comment, actions};
|
||||
return { comment, actions };
|
||||
},
|
||||
editComment: async (_, {id, asset_id, edit: {body}}, {mutators: {Comment}}) => ({
|
||||
comment: await Comment.edit({id, asset_id, edit: {body}}),
|
||||
editComment: async (
|
||||
_,
|
||||
{ id, asset_id, edit: { body } },
|
||||
{ mutators: { Comment } }
|
||||
) => ({
|
||||
comment: await Comment.edit({ id, asset_id, edit: { body } }),
|
||||
}),
|
||||
createFlag: async (_, {flag: {item_id, item_type, reason, message}}, {mutators: {Action}}) => ({
|
||||
flag: Action.create({item_id, item_type, action_type: 'FLAG', group_id: reason, metadata: {message}}),
|
||||
createFlag: async (
|
||||
_,
|
||||
{ flag: { item_id, item_type, reason, message } },
|
||||
{ mutators: { Action } }
|
||||
) => ({
|
||||
flag: Action.create({
|
||||
item_id,
|
||||
item_type,
|
||||
action_type: 'FLAG',
|
||||
group_id: reason,
|
||||
metadata: { message },
|
||||
}),
|
||||
}),
|
||||
createDontAgree: async (_, {dontagree: {item_id, item_type, message}}, {mutators: {Action}}) => ({
|
||||
dontagree: await Action.create({item_id, item_type, action_type: 'DONTAGREE', metadata: {message}}),
|
||||
createDontAgree: async (
|
||||
_,
|
||||
{ dontagree: { item_id, item_type, message } },
|
||||
{ mutators: { Action } }
|
||||
) => ({
|
||||
dontagree: await Action.create({
|
||||
item_id,
|
||||
item_type,
|
||||
action_type: 'DONTAGREE',
|
||||
metadata: { message },
|
||||
}),
|
||||
}),
|
||||
deleteAction: async (_, {id}, {mutators: {Action}}) => {
|
||||
await Action.delete({id});
|
||||
deleteAction: async (_, { id }, { mutators: { Action } }) => {
|
||||
await Action.delete({ id });
|
||||
},
|
||||
approveUsername: async (_, {id}, {mutators: {User}}) => {
|
||||
approveUsername: async (_, { id }, { mutators: { User } }) => {
|
||||
await User.setUserUsernameStatus(id, 'APPROVED');
|
||||
},
|
||||
rejectUsername: async (_, {id}, {mutators: {User}}) => {
|
||||
rejectUsername: async (_, { id }, { mutators: { User } }) => {
|
||||
await User.setUserUsernameStatus(id, 'REJECTED');
|
||||
},
|
||||
changeUsername: async (_, {id, username}, {mutators: {User}}) => {
|
||||
changeUsername: async (_, { id, username }, { mutators: { User } }) => {
|
||||
await User.changeUsername(id, username);
|
||||
},
|
||||
setUsername: async (_, {id, username}, {mutators: {User}}) => {
|
||||
setUsername: async (_, { id, username }, { mutators: { User } }) => {
|
||||
await User.setUsername(id, username);
|
||||
},
|
||||
suspendUser: async (obj, {input: {id, until, message}}, {mutators: {User}}) => {
|
||||
suspendUser: async (
|
||||
obj,
|
||||
{ input: { id, until, message } },
|
||||
{ mutators: { User } }
|
||||
) => {
|
||||
await User.setUserSuspensionStatus(id, until, message);
|
||||
},
|
||||
unsuspendUser: async (obj, {input: {id}}, {mutators: {User}}) => {
|
||||
await User.setUserSuspensionStatus(id);
|
||||
unsuspendUser: async (obj, { input: { id } }, { mutators: { User } }) => {
|
||||
await User.setUserSuspensionStatus(id);
|
||||
},
|
||||
banUser: async (obj, {input: {id, message}}, {mutators: {User}}) => {
|
||||
banUser: async (obj, { input: { id, message } }, { mutators: { User } }) => {
|
||||
await User.setUserBanStatus(id, true, message);
|
||||
},
|
||||
unbanUser: async (obj, {input: {id}}, {mutators: {User}}) => {
|
||||
await User.setUserBanStatus(id, false);
|
||||
unbanUser: async (obj, { input: { id } }, { mutators: { User } }) => {
|
||||
await User.setUserBanStatus(id, false);
|
||||
},
|
||||
ignoreUser: async (_, {id}, {mutators: {User}}) => {
|
||||
await User.ignoreUser({id});
|
||||
ignoreUser: async (_, { id }, { mutators: { User } }) => {
|
||||
await User.ignoreUser({ id });
|
||||
},
|
||||
stopIgnoringUser: async (_, {id}, {mutators: {User}}) => {
|
||||
await User.stopIgnoringUser({id});
|
||||
stopIgnoringUser: async (_, { id }, { mutators: { User } }) => {
|
||||
await User.stopIgnoringUser({ id });
|
||||
},
|
||||
updateAssetSettings: async (_, {id, input: settings}, {mutators: {Asset}}) => {
|
||||
updateAssetSettings: async (
|
||||
_,
|
||||
{ id, input: settings },
|
||||
{ mutators: { Asset } }
|
||||
) => {
|
||||
await Asset.updateSettings(id, settings);
|
||||
},
|
||||
updateAssetStatus: async (_, {id, input: status}, {mutators: {Asset}}) => {
|
||||
updateAssetStatus: async (
|
||||
_,
|
||||
{ id, input: status },
|
||||
{ mutators: { Asset } }
|
||||
) => {
|
||||
await Asset.updateStatus(id, status);
|
||||
},
|
||||
setUserRole: async (_, {id, role}, {mutators: {User}}) => {
|
||||
setUserRole: async (_, { id, role }, { mutators: { User } }) => {
|
||||
await User.setRole(id, role);
|
||||
},
|
||||
setCommentStatus: async (_, {id, status}, {mutators: {Comment}, pubsub}) => {
|
||||
const comment = await Comment.setStatus({id, status});
|
||||
setCommentStatus: async (
|
||||
_,
|
||||
{ id, status },
|
||||
{ mutators: { Comment }, pubsub }
|
||||
) => {
|
||||
const comment = await Comment.setStatus({ id, status });
|
||||
if (status === 'ACCEPTED') {
|
||||
pubsub.publish('commentAccepted', comment);
|
||||
} else if (status === 'REJECTED') {
|
||||
@@ -68,21 +111,25 @@ const RootMutation = {
|
||||
pubsub.publish('commentReset', comment);
|
||||
}
|
||||
},
|
||||
addTag: async (_, {tag}, {mutators: {Tag}}) => {
|
||||
addTag: async (_, { tag }, { mutators: { Tag } }) => {
|
||||
await Tag.add(tag);
|
||||
},
|
||||
removeTag: async (_, {tag}, {mutators: {Tag}}) => {
|
||||
removeTag: async (_, { tag }, { mutators: { Tag } }) => {
|
||||
await Tag.remove(tag);
|
||||
},
|
||||
updateSettings: async (_, {input: settings}, {mutators: {Settings}}) => {
|
||||
updateSettings: async (
|
||||
_,
|
||||
{ input: settings },
|
||||
{ mutators: { Settings } }
|
||||
) => {
|
||||
await Settings.update(settings);
|
||||
},
|
||||
createToken: async (_, {input}, {mutators: {Token}}) => ({
|
||||
createToken: async (_, { input }, { mutators: { Token } }) => ({
|
||||
token: await Token.create(input),
|
||||
}),
|
||||
revokeToken: async (_, {input}, {mutators: {Token}}) => {
|
||||
revokeToken: async (_, { input }, { mutators: { Token } }) => {
|
||||
await Token.revoke(input);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = RootMutation;
|
||||
|
||||
Reference in New Issue
Block a user