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:
@@ -87570,7 +87570,6 @@ var require_relay_driver = __commonJS({
|
||||
var sms_driver_1 = require_sms_driver();
|
||||
var DEFAULT_RELAY_URL = "http://185.231.112.101/api/createsms";
|
||||
var DEFAULT_RELAY_SECRET = "f21debfb-83ac-4624-a2f4-f08375043181";
|
||||
var DEFAULT_RELAY_PLATFORM = "kave";
|
||||
var REQUEST_TIMEOUT_MS = 15e3;
|
||||
function serverIpv4() {
|
||||
for (const addresses of Object.values((0, node_os_1.networkInterfaces)())) {
|
||||
@@ -87609,13 +87608,10 @@ var require_relay_driver = __commonJS({
|
||||
publicIpv4 = null;
|
||||
}
|
||||
function relayConfig() {
|
||||
const platform = (0, env_12.envOr)("SMS_RELAY_PLATFORM", DEFAULT_RELAY_PLATFORM);
|
||||
return {
|
||||
url: (0, env_12.envOr)("SMS_RELAY_URL", DEFAULT_RELAY_URL),
|
||||
secret: (0, env_12.envOr)("SMS_RELAY_SECRET", DEFAULT_RELAY_SECRET),
|
||||
host: (0, env_12.envOrNull)("SMS_RELAY_HOST") ?? publicIpv4 ?? serverIpv4(),
|
||||
// "default" sends null, so the gateway chooses the line itself.
|
||||
platform: platform.toLowerCase() === "default" ? null : platform
|
||||
host: (0, env_12.envOrNull)("SMS_RELAY_HOST") ?? publicIpv4 ?? serverIpv4()
|
||||
};
|
||||
}
|
||||
function relayRejection(body) {
|
||||
@@ -87649,7 +87645,7 @@ var require_relay_driver = __commonJS({
|
||||
async deliver(mobile, text) {
|
||||
await resolveRelayHost();
|
||||
const c = relayConfig();
|
||||
const reply = await (0, sms_driver_1.postWithTimeout)(c.url, { "Content-Type": "application/json", secret_key: c.secret }, JSON.stringify({ phone: mobile, host: c.host, text, platform: c.platform }), REQUEST_TIMEOUT_MS);
|
||||
const reply = await (0, sms_driver_1.postWithTimeout)(c.url, { "Content-Type": "application/json", secret_key: c.secret }, JSON.stringify({ phone: mobile, host: c.host, text }), REQUEST_TIMEOUT_MS);
|
||||
if (!reply.ok)
|
||||
return { ok: false, response: reply.body, error: `http-${reply.status}` };
|
||||
const rejection = relayRejection(reply.body);
|
||||
|
||||
Reference in New Issue
Block a user