forked from Yara724/api
Compare commits
5 Commits
8af152abc0
...
553a34054c
| Author | SHA1 | Date | |
|---|---|---|---|
| 553a34054c | |||
| 0446c83b36 | |||
| 255cfd3eb3 | |||
| 7d3565ec51 | |||
|
|
8d6fa3daac |
@@ -269,8 +269,7 @@ export class RequestManagementService {
|
|||||||
const step = stepByNumber ?? stepByKey;
|
const step = stepByNumber ?? stepByKey;
|
||||||
if (!step) {
|
if (!step) {
|
||||||
throw new InternalServerErrorException(
|
throw new InternalServerErrorException(
|
||||||
`Workflow step not found (${stepNumber ? `stepNumber=${stepNumber}` : ""}${
|
`Workflow step not found (${stepNumber ? `stepNumber=${stepNumber}` : ""}${stepNumber && stepKey ? ", " : ""
|
||||||
stepNumber && stepKey ? ", " : ""
|
|
||||||
}${stepKey ? `stepKey=${stepKey}` : ""})`,
|
}${stepKey ? `stepKey=${stepKey}` : ""})`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -304,7 +303,7 @@ export class RequestManagementService {
|
|||||||
private readonly workflowStepDbService: WorkflowStepDbService,
|
private readonly workflowStepDbService: WorkflowStepDbService,
|
||||||
private readonly hashService: HashService,
|
private readonly hashService: HashService,
|
||||||
private readonly userAuthService: UserAuthService,
|
private readonly userAuthService: UserAuthService,
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
async createRequestV2(user: any, type: BlameRequestType) {
|
async createRequestV2(user: any, type: BlameRequestType) {
|
||||||
const firstStep = await this.getWorkflowStep({ stepNumber: 1 });
|
const firstStep = await this.getWorkflowStep({ stepNumber: 1 });
|
||||||
@@ -768,8 +767,7 @@ export class RequestManagementService {
|
|||||||
);
|
);
|
||||||
if (err?.response) {
|
if (err?.response) {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
`[TEJARAT] block inquiry response for request=${req._id}: status=${
|
`[TEJARAT] block inquiry response for request=${req._id}: status=${err.response.status
|
||||||
err.response.status
|
|
||||||
}, data=${JSON.stringify(err.response.data)}`,
|
}, data=${JSON.stringify(err.response.data)}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1310,9 +1308,9 @@ export class RequestManagementService {
|
|||||||
if (foundRequest.expertInitiated && foundRequest.creationMethod === CreationMethod.LINK) {
|
if (foundRequest.expertInitiated && foundRequest.creationMethod === CreationMethod.LINK) {
|
||||||
// User should already be set in firstPartyDetails or secondPartyDetails
|
// User should already be set in firstPartyDetails or secondPartyDetails
|
||||||
const isFirstParty = foundRequest.firstPartyDetails?.firstPartyId?.toString() === user.sub ||
|
const isFirstParty = foundRequest.firstPartyDetails?.firstPartyId?.toString() === user.sub ||
|
||||||
foundRequest.firstPartyDetails?.firstPartyPhoneNumber === user.username;
|
foundRequest.firstPartyDetails?.firstPartyPhoneNumber === user.username;
|
||||||
const isSecondParty = foundRequest.secondPartyDetails?.secondPartyId?.toString() === user.sub ||
|
const isSecondParty = foundRequest.secondPartyDetails?.secondPartyId?.toString() === user.sub ||
|
||||||
foundRequest.secondPartyDetails?.secondPartyPhoneNumber === user.username;
|
foundRequest.secondPartyDetails?.secondPartyPhoneNumber === user.username;
|
||||||
|
|
||||||
if (!isFirstParty && !isSecondParty) {
|
if (!isFirstParty && !isSecondParty) {
|
||||||
throw new ForbiddenException(
|
throw new ForbiddenException(
|
||||||
@@ -1358,8 +1356,8 @@ export class RequestManagementService {
|
|||||||
} else if (
|
} else if (
|
||||||
foundRequest?.firstPartyDetails?.firstPartyPhoneNumber == user.username ||
|
foundRequest?.firstPartyDetails?.firstPartyPhoneNumber == user.username ||
|
||||||
(foundRequest.expertInitiated &&
|
(foundRequest.expertInitiated &&
|
||||||
foundRequest.creationMethod === CreationMethod.LINK &&
|
foundRequest.creationMethod === CreationMethod.LINK &&
|
||||||
foundRequest.firstPartyDetails?.firstPartyId?.toString() === user.sub)
|
foundRequest.firstPartyDetails?.firstPartyId?.toString() === user.sub)
|
||||||
) {
|
) {
|
||||||
// Normal flow or link-based - set full firstPartyDetails
|
// Normal flow or link-based - set full firstPartyDetails
|
||||||
const updatePayload: any = {
|
const updatePayload: any = {
|
||||||
@@ -1636,7 +1634,7 @@ export class RequestManagementService {
|
|||||||
// Check if nextStep is firstParty-addPlate OR if user is the first party phone number
|
// Check if nextStep is firstParty-addPlate OR if user is the first party phone number
|
||||||
const isFirstParty =
|
const isFirstParty =
|
||||||
(request.nextStep === StepsEnum.F_addPlate ||
|
(request.nextStep === StepsEnum.F_addPlate ||
|
||||||
request.currentStep === StepsEnum.F_addPlate) &&
|
request.currentStep === StepsEnum.F_addPlate) &&
|
||||||
request.firstPartyDetails.firstPartyPhoneNumber === user.username;
|
request.firstPartyDetails.firstPartyPhoneNumber === user.username;
|
||||||
|
|
||||||
if (!isFirstParty) {
|
if (!isFirstParty) {
|
||||||
@@ -3855,6 +3853,25 @@ export class RequestManagementService {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getAllBlameRequestsV2(user: any): Promise<any> {
|
||||||
|
console.log(user)
|
||||||
|
try {
|
||||||
|
const requests = await this.blameRequestDbService.find({
|
||||||
|
parties: {
|
||||||
|
$elemMatch: {
|
||||||
|
'person.userId': new Types.ObjectId(user.sub)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, { select: "requestNo type status blameStatus createdAt updatedAt" });
|
||||||
|
return requests;
|
||||||
|
} catch (err) {
|
||||||
|
this.logger.error("Error: ", err);
|
||||||
|
throw new InternalServerErrorException(
|
||||||
|
"Something Went Wrong",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* V2: Get one blame request by id. Access allowed if current user is a party (by userId or phone)
|
* V2: Get one blame request by id. Access allowed if current user is a party (by userId or phone)
|
||||||
* or the initiating field expert. For expert-initiated LINK, party access by phone is sufficient.
|
* or the initiating field expert. For expert-initiated LINK, party access by phone is sufficient.
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ import { RequestManagementService } from "./request-management.service";
|
|||||||
export class RequestManagementV2Controller {
|
export class RequestManagementV2Controller {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly requestManagementService: RequestManagementService,
|
private readonly requestManagementService: RequestManagementService,
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@UseGuards(GlobalGuard)
|
@UseGuards(GlobalGuard)
|
||||||
@@ -65,6 +65,14 @@ export class RequestManagementV2Controller {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
@Roles(RoleEnum.USER, RoleEnum.FIELD_EXPERT)
|
||||||
|
async getAllBlameRequestsV2(
|
||||||
|
@CurrentUser() user: any,
|
||||||
|
) {
|
||||||
|
return this.requestManagementService.getAllBlameRequestsV2(user);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get one blame request by id. Allowed for the request owner (party) or the initiating field expert.
|
* Get one blame request by id. Allowed for the request owner (party) or the initiating field expert.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user