feat: add carrier-aware signature retirement alerts
This commit is contained in:
@@ -2,6 +2,7 @@ import { BadRequestException, ConflictException, Injectable, NotFoundException }
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { summarizeReportStatuses } from '../common/report-status';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { normalizeChannelCarriers } from '../channels/channels.helpers';
|
||||
|
||||
export type DeletionTargetType = 'channel' | 'signature' | 'template';
|
||||
export type DeletionResolutionAction = 'delete_associated_templates' | 'delete_associated_drainage' | 'abandon_associated_report_tasks';
|
||||
@@ -334,8 +335,12 @@ export class DeletionGovernanceService {
|
||||
const configuredChannels = routes.flatMap((route) => route.group.items.map((item) => item.channel)).filter((channel) => channel.status !== 'deleted');
|
||||
const fallbackChannels = tasks.map((task) => task.channel).filter((channel) => channel.status !== 'deleted');
|
||||
const uniqueChannels = [...new Map((configuredChannels.length ? configuredChannels : fallbackChannels).map((channel) => [channel.id, channel])).values()];
|
||||
const taskByChannel = new Map(tasks.map((task) => [task.channelId, task]));
|
||||
const reportStatus = summarizeReportStatuses(uniqueChannels.map((channel) => taskByChannel.get(channel.id)?.status ?? 'pending')).status;
|
||||
const statuses = uniqueChannels.flatMap((channel) => normalizeChannelCarriers(channel.carriers, channel.carrier).map((carrier) => (
|
||||
tasks.find((task) => task.channelId === channel.id && task.carrier === carrier)?.status
|
||||
?? tasks.find((task) => task.channelId === channel.id && task.carrier === null && task.approvalScope === 'legacy_channel')?.status
|
||||
?? 'pending'
|
||||
)));
|
||||
const reportStatus = summarizeReportStatuses(statuses).status;
|
||||
await tx.smsSignature.update({ where: { id: signatureId }, data: { reportStatus } });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user