fix: accept partially reported CMPP signatures
This commit is contained in:
@@ -596,6 +596,55 @@ describe('SendChainService', () => {
|
||||
where: { id: 'task-1' },
|
||||
data: expect.objectContaining({ status: 'pending_review', riskTaskId: 'review-task-1', auditStatus: 'pending' }),
|
||||
});
|
||||
expect(prisma.smsSignature.findFirst).toHaveBeenCalledWith({
|
||||
where: {
|
||||
applicationId: 'app-1',
|
||||
name: '【签名】',
|
||||
auditStatus: 'approved',
|
||||
},
|
||||
orderBy: { updatedAt: 'desc' },
|
||||
});
|
||||
expect(prisma.smsReceiptRecord.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('accepts an approved bracketed signature when only part of its channels are reported', async () => {
|
||||
const { service, prisma, riskReview } = createService();
|
||||
prisma.smsApplication.findFirst.mockResolvedValue({
|
||||
id: 'app-1',
|
||||
tenantId: 'tenant-1',
|
||||
cmppAccount: '100001',
|
||||
status: 'active',
|
||||
interfaceEnabled: true,
|
||||
templateMismatchMode: 'manual_review',
|
||||
customerUnitPrice: 3,
|
||||
queuePriority: 'normal',
|
||||
ipAllowlist: [{ ipCidr: '127.0.0.1/32' }],
|
||||
tenant: { id: 'tenant-1', status: 'active', certificationStatus: 'approved' },
|
||||
});
|
||||
prisma.smsTemplate.findFirst.mockResolvedValue(null);
|
||||
prisma.smsSignature.findFirst.mockResolvedValue({
|
||||
id: 'sig-1',
|
||||
name: '【航天信息信诺网】',
|
||||
auditStatus: 'approved',
|
||||
reportStatus: 'reporting',
|
||||
});
|
||||
|
||||
await expect(service.submitInboundMessage({
|
||||
account: '100001',
|
||||
phoneNumber: '18821203795',
|
||||
content: '【航天信息信诺网】您本次操作的验证码是171102,有效时10分钟。',
|
||||
remoteIp: '127.0.0.1',
|
||||
})).resolves.toEqual(expect.objectContaining({ accepted: true, messageRecordId: 'record-1' }));
|
||||
|
||||
expect(prisma.smsSignature.findFirst).toHaveBeenCalledWith({
|
||||
where: {
|
||||
applicationId: 'app-1',
|
||||
name: '【航天信息信诺网】',
|
||||
auditStatus: 'approved',
|
||||
},
|
||||
orderBy: { updatedAt: 'desc' },
|
||||
});
|
||||
expect(riskReview.aggregateTemplateMismatch).toHaveBeenCalledWith(expect.objectContaining({ signatureId: 'sig-1' }));
|
||||
expect(prisma.smsReceiptRecord.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
@@ -1569,7 +1569,7 @@ export class SendChainService implements OnModuleInit, OnModuleDestroy {
|
||||
} else if (!template && application.templateMismatchMode === 'manual_review') {
|
||||
const signature = await this.resolveInboundSignatureCandidate(application.id, data.content);
|
||||
if (!signature) {
|
||||
await reject('SIGNATURE', '短信内容未识别到已审核且已报备的签名');
|
||||
await reject('SIGNATURE', '短信内容未识别到已审核通过的签名');
|
||||
} else {
|
||||
const risk = await this.riskReview.evaluateTask({
|
||||
tenantId: application.tenantId,
|
||||
@@ -2012,14 +2012,13 @@ export class SendChainService implements OnModuleInit, OnModuleDestroy {
|
||||
}
|
||||
|
||||
private resolveInboundSignatureCandidate(applicationId: string, content: string) {
|
||||
const match = content.match(/^【([^】]+)】/);
|
||||
if (!match?.[1]) return null;
|
||||
const match = content.match(/^【[^】]+】/);
|
||||
if (!match?.[0]) return null;
|
||||
return this.prisma.smsSignature.findFirst({
|
||||
where: {
|
||||
applicationId,
|
||||
name: match[1],
|
||||
name: match[0],
|
||||
auditStatus: 'approved',
|
||||
reportStatus: 'approved',
|
||||
},
|
||||
orderBy: { updatedAt: 'desc' },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user