mirror of
https://github.com/wassname/talk.git
synced 2026-08-13 12:40:11 +08:00
banUsers and moderate separate streams, not found assets etc
This commit is contained in:
@@ -2,6 +2,7 @@ const _ = require('lodash');
|
||||
|
||||
const Comment = require('./comment');
|
||||
const Action = require('./action');
|
||||
const User = require('./user');
|
||||
|
||||
module.exports = (context) => {
|
||||
|
||||
@@ -9,6 +10,7 @@ module.exports = (context) => {
|
||||
return _.merge(...[
|
||||
Comment,
|
||||
Action,
|
||||
User,
|
||||
].map((mutators) => {
|
||||
|
||||
// Each set of mutators is a function which takes the context.
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
const UsersService = require('../../services/users');
|
||||
|
||||
const setUserStatus = ({user}, {id, status}) => {
|
||||
console.log('------as-d-asd-a-sads-a-sad-dsa-----');
|
||||
console.log('user', user);
|
||||
console.log('id', id);
|
||||
console.log('status', status);
|
||||
|
||||
return UsersService.setStatus(id, status)
|
||||
.then((user) => {
|
||||
console.log('result', user);
|
||||
return user;
|
||||
});
|
||||
};
|
||||
|
||||
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: {
|
||||
setUserStatus: (action) => setUserStatus(context, action)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
User: {
|
||||
setUserStatus: () => {},
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -8,6 +8,9 @@ const RootMutation = {
|
||||
deleteAction(_, {id}, {mutators: {Action}}) {
|
||||
return Action.delete({id});
|
||||
},
|
||||
setUserStatus(_, {id, status}, {mutators: {User}}) {
|
||||
return User.setUserStatus({id, status});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = RootMutation;
|
||||
|
||||
@@ -61,6 +61,9 @@ type User {
|
||||
|
||||
# returns all comments based on a query.
|
||||
comments(query: CommentsQuery): [Comment]
|
||||
|
||||
# returns user status
|
||||
status: USER_STATUS
|
||||
}
|
||||
|
||||
type Comment {
|
||||
@@ -177,6 +180,13 @@ enum COMMENT_STATUS {
|
||||
PREMOD
|
||||
}
|
||||
|
||||
enum USER_STATUS {
|
||||
ACTIVE
|
||||
BANNED
|
||||
PENDING
|
||||
APPROVED
|
||||
}
|
||||
|
||||
type RootQuery {
|
||||
|
||||
# retrieves site wide settings and defaults.
|
||||
@@ -216,6 +226,8 @@ type RootMutation {
|
||||
# delete an action based on the action id.
|
||||
deleteAction(id: ID!): Boolean
|
||||
|
||||
# sets user status
|
||||
setUserStatus(id: ID!, status: USER_STATUS!): Boolean
|
||||
}
|
||||
|
||||
schema {
|
||||
|
||||
Reference in New Issue
Block a user