fix(sms): accept a gateway reply with debug text before its JSON
The relay gateway now prints timing lines before its result, e.g.
"1. Function Start at: ...<br>...572381951{"data":"sent"}". The message
was delivered, but the whole body is not JSON, so it was logged as a failed
SMS. When the body does not parse, the trailing JSON object is read instead.
A body with no JSON at all (the gateway's bare PHP errors) still fails.
Tests: sms.service.spec (relayRejection). 33 SMS tests pass.
پیامکِ ارسالشده دیگر به اشتباه در گزارش سرور «ناموفق» ثبت نمیشود.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -190,6 +190,14 @@ describe('relayRejection', () => {
|
||||
it('rejects a bare-text body — the gateway reports its own PHP errors that way', () => {
|
||||
expect(relayRejection('cURL library is not loaded')).toBe('cURL library is not loaded');
|
||||
});
|
||||
|
||||
it('reads the trailing JSON when the gateway prints debug text before it', () => {
|
||||
const debug =
|
||||
'1. Function Start at: 13:07:25:586<br>2. Request Sending (Standard) at: 13:07:25:586<br>' +
|
||||
'Total Duration: 0.2961 seconds<br>572381951';
|
||||
expect(relayRejection(debug + '{"data":"sent"}')).toBeNull();
|
||||
expect(relayRejection(debug + '{"status":false,"message":"bad phone"}')).toBe('bad phone');
|
||||
});
|
||||
});
|
||||
|
||||
describe('SmsService.send', () => {
|
||||
|
||||
Reference in New Issue
Block a user