forked from Yara724/api
fix: support user panel base path in SMS links
This commit is contained in:
@@ -38,12 +38,35 @@ export class SmsOrchestrationService implements OnModuleInit {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* `URL` is the public application/API base (and is also used for file URLs).
|
||||
* Some deployments mount the user panel below a separate reverse-proxy path,
|
||||
* e.g. `/car-damage/user`; keep that panel-only segment out of `URL`.
|
||||
*/
|
||||
private userPanelBaseUrl(): string {
|
||||
const applicationUrl = String(process.env.URL ?? "")
|
||||
.trim()
|
||||
.replace(/\/+$/, "");
|
||||
const userBasePath = String(process.env.USER_BASE_PATH ?? "")
|
||||
.trim()
|
||||
.replace(/^\/+|\/+$/g, "");
|
||||
return userBasePath ? `${applicationUrl}/${userBasePath}` : applicationUrl;
|
||||
}
|
||||
|
||||
private buildUserPanelLink(...segments: string[]): string {
|
||||
const path = segments
|
||||
.map((segment) => String(segment).replace(/^\/+|\/+$/g, ""))
|
||||
.filter(Boolean)
|
||||
.join("/");
|
||||
return `${this.userPanelBaseUrl()}/${path}`;
|
||||
}
|
||||
|
||||
buildInviteLink(
|
||||
frontendRoute: string,
|
||||
requestId: string,
|
||||
versionPrefix: string,
|
||||
): string {
|
||||
return `${process.env.URL}/${versionPrefix}/${frontendRoute}?token=${requestId}`;
|
||||
return `${this.buildUserPanelLink(versionPrefix, frontendRoute)}?token=${requestId}`;
|
||||
}
|
||||
|
||||
buildBlamePartyLink(
|
||||
@@ -52,11 +75,11 @@ export class SmsOrchestrationService implements OnModuleInit {
|
||||
versionPrefix: string,
|
||||
): string {
|
||||
const route = partyRole === "SECOND" ? "user2" : "user";
|
||||
return `${process.env.URL}/${versionPrefix}/${route}?token=${requestId}`;
|
||||
return `${this.buildUserPanelLink(versionPrefix, route)}?token=${requestId}`;
|
||||
}
|
||||
|
||||
buildClaimLink(claimRequestId: string, versionPrefix: string): string {
|
||||
return `${process.env.URL}/${versionPrefix}/caseClaim?token=${claimRequestId}`;
|
||||
return `${this.buildUserPanelLink(versionPrefix, "caseClaim")}?token=${claimRequestId}`;
|
||||
}
|
||||
|
||||
async sendInviteLink(
|
||||
|
||||
Reference in New Issue
Block a user