feat: enforce signature-scoped drainage authorization before SMS submission

This commit is contained in:
hectorzhao
2026-09-10 13:29:04 +08:00
parent 5bcdbb2a03
commit 0c3f820cc9
35 changed files with 2769 additions and 791 deletions
@@ -0,0 +1,29 @@
import { Injectable, Logger, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
import { SendChainService } from './send-chain.service';
@Injectable()
export class DrainageReceiptRecoveryService implements OnModuleInit, OnModuleDestroy {
private timer?: ReturnType<typeof setInterval>;
private running = false;
private readonly logger = new Logger(DrainageReceiptRecoveryService.name);
constructor(private readonly sendChain: SendChainService) {}
onModuleInit() {
if (['api', 'callback', 'outbox'].includes(process.env.CMPP_PROCESS_ROLE ?? 'all')) return;
this.timer = setInterval(() => void this.scan(), 10000);
this.timer.unref?.();
}
async scan() {
if (this.running) return;
this.running = true;
try {
await this.sendChain.recoverDrainageFailureReceipts();
} catch (error) {
this.logger.error(`引流拦截回执恢复失败: ${String(error)}`);
} finally {
this.running = false;
}
}
onModuleDestroy() {
if (this.timer) clearInterval(this.timer);
}
}