Add support for tagID in GET /Users.
MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -1316,6 +1316,7 @@ export default class UserService {
issuer: filteredRequest.Issuer,
siteIDs: (filteredRequest.SiteID ? filteredRequest.SiteID.split('|') : null),
userIDs: (filteredRequest.UserID ? filteredRequest.UserID.split('|') : null),
+ tagID: (filteredRequest.TagID ? filteredRequest.TagID : null),
roles: (filteredRequest.Role ? filteredRequest.Role.split('|') : null),
statuses: (filteredRequest.Status ? filteredRequest.Status.split('|') : null),
excludeSiteID: filteredRequest.ExcludeSiteID,

MODIFY
src/storage/mongodb/UserStorage.ts
src/storage/mongodb/UserStorage.ts
@@ -532,7 +532,7 @@ export default class UserStorage {
includeCarUserIDs?: string[]; excludeUserIDs?: string[]; notAssignedToCarID?: string;
userIDs?: string[]; email?: string; issuer?: boolean; passwordResetHash?: string; roles?: string[];
statuses?: string[]; withImage?: boolean; billingUserID?: string; notSynchronizedBillingData?: boolean;
- notifications?: any; noLoginSince?: Date;
+ notifications?: any; noLoginSince?: Date; tagID?: string;
},
dbParams: DbParams, projectFields?: string[]): Promise<DataResult<User>> {
// Debug
@@ -640,6 +640,15 @@ export default class UserStorage {
$match: notAssignedToCarIDFilter
});
}
+ // Add Tags
+ if (params.tagID) {
+ DatabaseUtils.pushTagLookupInAggregation({
+ tenantID, aggregation, localField: '_id', foreignField: 'userID', asField: 'tag'
+ });
+ aggregation.push({
+ $match: { 'tag.id': { $eq: params.tagID } }
+ });
+ }
// Add Site
if (params.siteIDs || params.excludeSiteID) {
DatabaseUtils.pushSiteUserLookupInAggregation({

Add support for tagID in GET /Users.