From 277f3cc338cfd4ef4e2d665a39adb221f5284455 Mon Sep 17 00:00:00 2001 From: terrisse-po Date: Wed, 10 Jul 2024 17:20:57 +0200 Subject: [PATCH] More flexible sms configuration with body and headers More flexible sms configuration with body and headers --- transports/sms.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/transports/sms.js b/transports/sms.js index d71ddee..7f65cef 100644 --- a/transports/sms.js +++ b/transports/sms.js @@ -34,7 +34,22 @@ export async function send_message(req, opts, res) { const num = opts.userTransport || await userDb_controller.get_phone_number(req); if (utils.check_transport_validity('sms', num)) { const url = urlBroker(num, opts.message); - + if (properties.getEsupProperty('sms').method) { + requestOpts.method = properties.getEsupProperty('sms').method; + } + if (properties.getEsupProperty('sms').body) { + const body = properties.getEsupProperty('sms').body.replace('$phoneNumber$', encodeURIComponent(num)).replace('$message$', encodeURIComponent(opts.message)); + requestOpts.body = body; + } + if (properties.getEsupProperty('sms').headers) { + if (! requestOpts.headers) { + requestOpts.headers = {}; + } + for (const k in properties.getEsupProperty('sms').headers) { + requestOpts.headers[k] = properties.getEsupProperty('sms').headers[k]; + } + } + let sms_response; try { sms_response = await request(url, requestOpts);