mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 06:28:12 +00:00
feat: enhance booking management with shipping line support and cargo handling improvements
This commit is contained in:
@@ -132,37 +132,33 @@ export class ShippingLineCompaniesService {
|
||||
* Email always goes out — it is required at registration and is the only
|
||||
* channel guaranteed to reach a foreign-registered line. SMS is sent in
|
||||
* addition when the number is domestic, since the gateway silently drops
|
||||
* anything else (see `CustomerResetService`). Two links are two independent
|
||||
* single-use tickets; whichever the line opens first works.
|
||||
* anything else (see `CustomerResetService`). Both carry the SAME single-use
|
||||
* ticket: minting retires earlier tickets, so two mints would kill the email
|
||||
* link the moment the SMS went out.
|
||||
*
|
||||
* Reports the email send, as that is the one that is always attempted.
|
||||
*/
|
||||
async sendActivationLink(shippingLine: ShippingLineCompany) {
|
||||
const scope = `shipping line ${shippingLine.id}`;
|
||||
const channels = [ResetChannel.Email];
|
||||
if (shippingLine.phoneNumber && isDomesticPhone(shippingLine.phoneNumber)) {
|
||||
channels.push(ResetChannel.Phone);
|
||||
}
|
||||
|
||||
const emailed = await this.customerResetService.sendResetLinkToUser(
|
||||
const sent = await this.customerResetService.sendResetLinkToUserOnChannels(
|
||||
shippingLine.userId,
|
||||
ResetChannel.Email,
|
||||
channels,
|
||||
{ scope, allowWithoutCredential: true },
|
||||
);
|
||||
const emailed = sent.find((s) => s.channel === ResetChannel.Email) ?? null;
|
||||
|
||||
if (!emailed) {
|
||||
this.logger.error(
|
||||
`Activation email not sent for shipping line ${shippingLine.id} — no reachable address`,
|
||||
);
|
||||
}
|
||||
|
||||
if (shippingLine.phoneNumber && isDomesticPhone(shippingLine.phoneNumber)) {
|
||||
const texted = await this.customerResetService.sendResetLinkToUser(
|
||||
shippingLine.userId,
|
||||
ResetChannel.Phone,
|
||||
{ scope, allowWithoutCredential: true },
|
||||
);
|
||||
if (!texted) {
|
||||
this.logger.warn(
|
||||
`Activation SMS not sent for shipping line ${shippingLine.id}`,
|
||||
);
|
||||
}
|
||||
if (channels.includes(ResetChannel.Phone) && !sent.some((s) => s.channel === ResetChannel.Phone)) {
|
||||
this.logger.warn(`Activation SMS not sent for shipping line ${shippingLine.id}`);
|
||||
}
|
||||
|
||||
return emailed;
|
||||
|
||||
Reference in New Issue
Block a user