forked from Yara724/api
Fixed GET users
This commit is contained in:
@@ -97,6 +97,7 @@ import {
|
||||
normalizeIranMobile,
|
||||
partyPersonMatchesUser,
|
||||
} from "src/helpers/iran-mobile";
|
||||
import { buildBlamePartyAccessOrConditions } from "src/helpers/party-access-queries";
|
||||
|
||||
@Injectable()
|
||||
export class RequestManagementService {
|
||||
@@ -5028,24 +5029,7 @@ export class RequestManagementService {
|
||||
query: ListQueryV2Dto = {},
|
||||
): Promise<GetUserBlameListV2ResponseDto> {
|
||||
try {
|
||||
const userIdFilter =
|
||||
user?.sub && Types.ObjectId.isValid(user.sub)
|
||||
? { "parties.person.userId": new Types.ObjectId(user.sub) }
|
||||
: null;
|
||||
const phoneVariants =
|
||||
user?.role === RoleEnum.USER && user?.username
|
||||
? iranMobileLookupVariants(user.username)
|
||||
: user?.username
|
||||
? [user.username]
|
||||
: [];
|
||||
const phoneFilter =
|
||||
phoneVariants.length > 0
|
||||
? { "parties.person.phoneNumber": { $in: phoneVariants } }
|
||||
: null;
|
||||
|
||||
const orConditions: Record<string, unknown>[] = [];
|
||||
if (userIdFilter) orConditions.push(userIdFilter);
|
||||
if (phoneFilter) orConditions.push(phoneFilter);
|
||||
const orConditions = buildBlamePartyAccessOrConditions(user);
|
||||
|
||||
if (user?.role === RoleEnum.FIELD_EXPERT && user?.sub) {
|
||||
orConditions.push({
|
||||
|
||||
Reference in New Issue
Block a user