|
@@ -1,3 +1,4 @@
|
|
|
|
|
+import Activity from '~/server/models/activity';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
import { apiV3FormValidator } from '../../middlewares/apiv3-form-validator';
|
|
import { apiV3FormValidator } from '../../middlewares/apiv3-form-validator';
|
|
@@ -949,14 +950,21 @@ module.exports = (crowi) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (options.isIncludeInactiveUser) {
|
|
if (options.isIncludeInactiveUser) {
|
|
|
- const inactiveUserStates = [User.STATUS_REGISTERED, User.STATUS_SUSPENDED, User.STATUS_DELETED, User.STATUS_INVITED];
|
|
|
|
|
|
|
+ const inactiveUserStates = [User.STATUS_REGISTERED, User.STATUS_SUSPENDED, User.STATUS_INVITED];
|
|
|
const inactiveUserData = await User.findUserByUsernameRegexWithTotalCount(q, inactiveUserStates, { offset, limit });
|
|
const inactiveUserData = await User.findUserByUsernameRegexWithTotalCount(q, inactiveUserStates, { offset, limit });
|
|
|
const inactiveUsernames = inactiveUserData.users.map(user => user.username);
|
|
const inactiveUsernames = inactiveUserData.users.map(user => user.username);
|
|
|
Object.assign(data, { inactiveUser: { usernames: inactiveUsernames, totalCount: inactiveUserData.totalCount } });
|
|
Object.assign(data, { inactiveUser: { usernames: inactiveUsernames, totalCount: inactiveUserData.totalCount } });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (options.isIncludeMixedUsername) {
|
|
|
|
|
- const allUsernames = [...data.activeUser?.usernames || [], ...data.inactiveUser?.usernames || []];
|
|
|
|
|
|
|
+ if (options.isIncludeActivitySnapshotUser && req.user.admin) {
|
|
|
|
|
+ const activitySnapshotUserData = await Activity.findSnapshotUsernamesByUsernameRegexWithTotalCount(q, { offset, limit });
|
|
|
|
|
+ Object.assign(data, { activitySnapshotUser: activitySnapshotUserData });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // eslint-disable-next-line max-len
|
|
|
|
|
+ const canIncludeMixedUsernames = (options.isIncludeMixedUsernames && req.user.admin) || (options.isIncludeMixedUsernames && !options.isIncludeActivitySnapshotUser);
|
|
|
|
|
+ if (canIncludeMixedUsernames) {
|
|
|
|
|
+ const allUsernames = [...data.activeUser?.usernames || [], ...data.inactiveUser?.usernames || [], ...data?.activitySnapshotUser?.usernames || []];
|
|
|
const distinctUsernames = Array.from(new Set(allUsernames));
|
|
const distinctUsernames = Array.from(new Set(allUsernames));
|
|
|
Object.assign(data, { mixedUsernames: distinctUsernames });
|
|
Object.assign(data, { mixedUsernames: distinctUsernames });
|
|
|
}
|
|
}
|