diff --git a/client/coral-admin/src/routes/Community/components/FlaggedUser.js b/client/coral-admin/src/routes/Community/components/FlaggedUser.js index 5f0136367..3526bcc37 100644 --- a/client/coral-admin/src/routes/Community/components/FlaggedUser.js +++ b/client/coral-admin/src/routes/Community/components/FlaggedUser.js @@ -19,7 +19,6 @@ const shortReasons = { // Render a single user for the list const User = (props) => { const {user, modActionButtons} = props; - let userStatus = user.status; const showSuspenUserDialog = () => props.showSuspendUserDialog({ userId: user.id, @@ -31,9 +30,7 @@ const User = (props) => { username: user.username, }); - // Do not display unless the user status is 'pending' or 'banned'. - // This means that they have already been reviewed and approved. - return (userStatus === 'PENDING' || userStatus === 'BANNED') && + return (
  • @@ -111,7 +108,8 @@ const User = (props) => {
    -
  • ; + + ); }; export default User; diff --git a/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js index 29439e362..ad3339bd5 100644 --- a/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js +++ b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js @@ -87,7 +87,7 @@ const LOAD_MORE_QUERY = gql` export const withFlaggedAccountsyQuery = withQuery(gql` query TalkAdmin_FlaggedAccounts { ...${getDefinitionName(FlaggedUser.fragments.root)} - users(query:{action_type: FLAG, limit: 10}){ + users(query:{action_type: FLAG, statuses: [PENDING], limit: 10}){ hasNextPage endCursor nodes { diff --git a/graph/loaders/users.js b/graph/loaders/users.js index 3d48bafd7..8ef8bd6cf 100644 --- a/graph/loaders/users.js +++ b/graph/loaders/users.js @@ -1,6 +1,7 @@ const DataLoader = require('dataloader'); const util = require('./util'); +const union = require('lodash/union'); const UsersService = require('../../services/users'); const UserModel = require('../../models/user'); @@ -26,10 +27,15 @@ const genUserByIDs = async (context, ids) => { * @param {Object} context graph context * @param {Object} query query terms to apply to the users query */ -const getUsersByQuery = async ({user}, {ids, limit, cursor, statuses = null, sortOrder}) => { +const getUsersByQuery = async ({user, loaders: {Actions}}, {ids, limit, cursor, statuses, action_type, sortOrder}) => { let query = UserModel.find(); + if (action_type) { + const userIds = await Actions.getByTypes({action_type, item_type: 'USERS'}); + ids = ids ? union(ids, userIds) : userIds; + } + if (ids) { query = query.find({ id: { @@ -38,7 +44,7 @@ const getUsersByQuery = async ({user}, {ids, limit, cursor, statuses = null, sor }); } - if (statuses != null) { + if (statuses) { query = query.where({ status: { $in: statuses diff --git a/graph/resolvers/root_query.js b/graph/resolvers/root_query.js index 1e34e8ecd..239b052c0 100644 --- a/graph/resolvers/root_query.js +++ b/graph/resolvers/root_query.js @@ -92,17 +92,11 @@ const RootQuery = { // This endpoint is used for loading the user moderation queues (users whose username has been flagged), // so hide it in the event that we aren't an admin. - async users(_, {query}, {user, loaders: {Users, Actions}}) { + async users(_, {query}, {user, loaders: {Users}}) { if (user == null || !user.can(SEARCH_OTHER_USERS)) { return null; } - const {action_type} = query; - if (action_type) { - query.ids = await Actions.getByTypes({action_type, item_type: 'USERS'}); - query.statuses = ['PENDING']; - } - return Users.getByQuery(query); } }; diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index 5bebb7e76..79b0f59c0 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -141,6 +141,9 @@ type UserConnection { input UsersQuery { action_type: ACTION_TYPE + # Current status of a user. Requires the `ADMIN` role. + statuses: [USER_STATUS!] + # Limit the number of results to be returned. limit: Int = 10