banUsers and moderate separate streams, not found assets etc

This commit is contained in:
Belen Curcio
2017-02-10 17:15:26 -03:00
parent 9320ece35b
commit bc14b908eb
23 changed files with 310 additions and 105 deletions
+2
View File
@@ -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.
+34
View File
@@ -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: () => {},
}
};
};
+3
View File
@@ -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;
+12
View File
@@ -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 {