mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
refactored resolvers, cleaned
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const { SEARCH_OTHER_USERS } = require('../../perms/constants');
|
||||
const { decorateUserField } = require('./util');
|
||||
|
||||
const Action = {
|
||||
__resolveType({ action_type }) {
|
||||
@@ -11,14 +11,8 @@ const Action = {
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
|
||||
// This will load the user for the specific action. We'll limit this to the
|
||||
// admin users only or the current logged in user.
|
||||
user({ user_id }, _, { loaders: { Users }, user }) {
|
||||
if (user && (user.can(SEARCH_OTHER_USERS) || user_id === user.id)) {
|
||||
return Users.getByID.load(user_id);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
decorateUserField(Action, 'user', 'user_id');
|
||||
|
||||
module.exports = Action;
|
||||
|
||||
Reference in New Issue
Block a user