fix(sms): send form confirmations to the lead number

Lead-only website forms had no person mobile, so the confirmation was marked sent without a number. Use the lead phone and send the full text.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-31 16:41:41 +03:30
co-authored by Cursor
parent 8d01bce0c2
commit 590f8114cc
5 changed files with 91 additions and 19 deletions
+19 -5
View File
@@ -2,12 +2,12 @@ import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import {
MAX_MESSAGE_REPEAT,
MAX_MESSAGE_SMS,
addDelay,
applyMessageTemplate,
buildSendAts,
cancelTriggersFor,
clipSms,
customerPhone,
delayMs,
} from '../src/message-automations/message-automation.util';
@@ -40,14 +40,28 @@ describe('اتوماسیون پیام', () => {
assert.equal(applyMessageTemplate('{ name }', { name: 'x' }), 'x');
});
it('کوتاه کردن پیامک', () => {
it('متن پیامک بریده نمی‌شود', () => {
const long = 'ا'.repeat(200);
const clipped = clipSms(long);
assert.equal(clipped.length, MAX_MESSAGE_SMS);
assert.ok(clipped.endsWith('…'));
assert.equal(clipSms(long), long);
assert.equal(clipSms(' کوتاه '), 'کوتاه');
});
it('شماره سرنخ جای شماره مشتری می‌نشیند', () => {
assert.equal(
customerPhone(null, { mobile: '09120000000' }),
'09120000000',
);
assert.equal(
customerPhone({ mobile: '', phone: null }, { mobile: '09121111111', phone: '021' }),
'09121111111',
);
assert.equal(
customerPhone({ mobile: '09123333333' }, { mobile: '09124444444' }),
'09123333333',
);
assert.equal(customerPhone(null, null), '');
});
it('لغو پیام‌های قبلی', () => {
assert.deepEqual(cancelTriggersFor('invoice_paid'), ['invoice_issued']);
assert.deepEqual(cancelTriggersFor('deal_won'), ['deal_created', 'deal_stage_changed']);