feat: filter SMS routes by channel sensitive words

This commit is contained in:
hectorzhao
2026-09-10 15:50:56 +08:00
parent 86947827cc
commit 8e4bc5a20e
26 changed files with 1615 additions and 41 deletions
+18 -3
View File
@@ -872,10 +872,13 @@ export class SendChainService implements OnModuleInit, OnModuleDestroy {
async recoverDrainageFailureReceipts() {
const messages = await this.prisma.smsMessageRecord.findMany({
where: {
drainageReceiptPending: true,
OR: [
{ drainageReceiptPending: true, batchTask: { sourceType: 'cmpp' } },
{ channelWordFinalizationPending: true },
],
status: { in: ['failed', 'submit_failed'] },
batchTask: { sourceType: 'cmpp' },
},
include: { batchTask: { select: { sourceType: true } } },
orderBy: { updatedAt: 'asc' },
take: 50,
});
@@ -886,9 +889,21 @@ export class SendChainService implements OnModuleInit, OnModuleDestroy {
{ ...message, tenantId: message.tenantId, batchTaskId: message.batchTaskId },
reason,
);
if (message.channelWordFinalizationPending && message.batchTask?.sourceType !== 'cmpp') {
await this.refreshTaskProgress(message.batchTaskId);
await this.prisma.smsMessageRecord.update({
where: { id: message.id },
data: { channelWordFinalizationPending: false },
});
continue;
}
await this.recordCmppFailureReceipt(
message,
message.errorCode?.startsWith('DRN') ? message.errorCode : 'DRN',
message.channelWordFinalizationPending
? 'CSW'
: message.errorCode?.startsWith('DRN')
? message.errorCode
: 'DRN',
reason,
);
}