fix(sms): stop sending platform to the relay gateway

With platform "kave" (Kavenegar) the gateway answered "cURL library is not
loaded" and nothing was delivered. The body is now { phone, host, text } and
the gateway picks the line itself. SMS_RELAY_PLATFORM is removed from the
driver, docker-compose and the env examples.

Tests: sms.service.spec updated. 150 tests pass.

پیامک بدون انتخاب خط کاوه‌نگار فرستاده می‌شود و سرویس پیامک خودش خط را انتخاب می‌کند.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
s.esmaeili
2026-10-10 16:34:57 +03:30
co-authored by Cursor
parent c34bf80e6f
commit 797d030e67
7 changed files with 10 additions and 30 deletions
@@ -9,11 +9,12 @@ import { SmsDriver, postWithTimeout } from './sms-driver';
*
* Shape, from the owner's PHP client:
* * POST JSON, 15s timeout, auth header `secret_key`
* * body: { phone, host, text, platform }
* * body: { phone, host, text }
* * `host` identifies the sending server: a configured value, else the
* server's own IP (`gethostbyname(gethostname())`)
* * `platform: "kave"` routes through Kavenegar; null lets the gateway pick.
* The owner wants every message through Kavenegar.
* * no `platform`: the gateway picks the line itself. Sending
* `platform: "kave"` (Kavenegar) failed on the gateway with
* "cURL library is not loaded".
*
* The secret is in source on the owner's decision (D26): the gateway has a
* second verification factor held elsewhere. `SMS_RELAY_SECRET` overrides it.
@@ -24,8 +25,6 @@ import { SmsDriver, postWithTimeout } from './sms-driver';
const DEFAULT_RELAY_URL = 'http://185.231.112.101/api/createsms';
const DEFAULT_RELAY_SECRET = 'f21debfb-83ac-4624-a2f4-f08375043181';
const DEFAULT_RELAY_PLATFORM = 'kave';
/** `Http::timeout(15)` in the owner's client. */
const REQUEST_TIMEOUT_MS = 15_000;
@@ -79,13 +78,10 @@ export function resetRelayHostCache() {
}
export function relayConfig() {
const platform = envOr('SMS_RELAY_PLATFORM', DEFAULT_RELAY_PLATFORM);
return {
url: envOr('SMS_RELAY_URL', DEFAULT_RELAY_URL),
secret: envOr('SMS_RELAY_SECRET', DEFAULT_RELAY_SECRET),
host: envOrNull('SMS_RELAY_HOST') ?? publicIpv4 ?? serverIpv4(),
// "default" sends null, so the gateway chooses the line itself.
platform: platform.toLowerCase() === 'default' ? null : platform,
};
}
@@ -137,7 +133,7 @@ export const relayDriver: SmsDriver = {
const reply = await postWithTimeout(
c.url,
{ 'Content-Type': 'application/json', secret_key: c.secret },
JSON.stringify({ phone: mobile, host: c.host, text, platform: c.platform }),
JSON.stringify({ phone: mobile, host: c.host, text }),
REQUEST_TIMEOUT_MS,
);