diff --git a/sms/README.md b/sms/README.md
old mode 100644
new mode 100755
diff --git a/sms/app_config.php b/sms/app_config.php
old mode 100644
new mode 100755
index 91647046..aab2e21e
--- a/sms/app_config.php
+++ b/sms/app_config.php
@@ -39,7 +39,7 @@
$apps[$x]['permissions'][$y]['name'] = "sms_enabled";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
-
+
//default settings
$y = 0;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = '67511e2d-35e1-4f70-80ac-4265ec39d2fe';
@@ -90,15 +90,15 @@
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'true';
$apps[$x]['default_settings'][$y]['default_setting_description'] = '';
$y++;
- $apps[$x]['default_settings'][$y]['default_setting_uuid'] = '9b36edac-eeac-4a3e-b8d4-664962e3f78c';
- $apps[$x]['default_settings'][$y]['default_setting_category'] = 'sms';
- $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = 'carriers';
- $apps[$x]['default_settings'][$y]['default_setting_name'] = 'array';
- $apps[$x]['default_settings'][$y]['default_setting_value'] = 'telnyx';
- $apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'true';
- $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
- $y++;
-
+ $apps[$x]['default_settings'][$y]['default_setting_uuid'] = '9b36edac-eeac-4a3e-b8d4-664962e3f78c';
+ $apps[$x]['default_settings'][$y]['default_setting_category'] = 'sms';
+ $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = 'carriers';
+ $apps[$x]['default_settings'][$y]['default_setting_name'] = 'array';
+ $apps[$x]['default_settings'][$y]['default_setting_value'] = 'telnyx';
+ $apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'true';
+ $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
+ $y++;
+
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = 'e997203c-ca48-45b4-828d-e347ff66fa7c';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'sms';
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = 'twilio_api_url';
@@ -145,16 +145,16 @@
$apps[$x]['default_settings'][$y]['default_setting_name'] = 'text';
$apps[$x]['default_settings'][$y]['default_setting_value'] = 'https://api.thinq.com/account/{ACCOUNT}/product/origination/sms/send';
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'false';
- $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
- $y++;
+ $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
+ $y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = '2f246db7-eb07-4c2c-a752-e81466276c89';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'sms';
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = 'telnyx_api_url';
$apps[$x]['default_settings'][$y]['default_setting_name'] = 'text';
$apps[$x]['default_settings'][$y]['default_setting_value'] = 'https://sms.telnyx.com/messages';
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'false';
- $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
- $y++;
+ $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
+ $y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = '14101c26-c3f9-46aa-a67a-3642752e56f4';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'sms';
@@ -172,7 +172,7 @@
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'false';
$apps[$x]['default_settings'][$y]['default_setting_description'] = '';
$y++;
-
+
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = '551b3948-8328-42be-a873-9a32f8b49463';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'sms';
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = 'teli_access_key';
@@ -189,7 +189,7 @@
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'false';
$apps[$x]['default_settings'][$y]['default_setting_description'] = '';
$y++;
-
+
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = 'c56042fc-4cd4-425b-a39a-9297aaed7743';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'sms';
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = 'twilio_access_key';
@@ -206,7 +206,7 @@
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'false';
$apps[$x]['default_settings'][$y]['default_setting_description'] = '';
$y++;
-
+
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = '4a86c939-9d80-4da7-bbda-49d6bf1c3882';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'sms';
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = 'bandwidth_access_key';
@@ -229,7 +229,7 @@
$apps[$x]['default_settings'][$y]['default_setting_name'] = 'text';
$apps[$x]['default_settings'][$y]['default_setting_value'] = '';
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'false';
- $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
+ $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = 'cc4725d7-66e4-4ee8-ae95-475b8903ba91';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'sms';
@@ -237,7 +237,7 @@
$apps[$x]['default_settings'][$y]['default_setting_name'] = 'text';
$apps[$x]['default_settings'][$y]['default_setting_value'] = '';
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'false';
- $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
+ $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = '604c1f7c-e830-441d-9596-31c8d091f8c2';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'sms';
@@ -245,7 +245,7 @@
$apps[$x]['default_settings'][$y]['default_setting_name'] = 'text';
$apps[$x]['default_settings'][$y]['default_setting_value'] = '';
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'false';
- $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
+ $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = 'abcd3f80-71c2-4b58-ae9d-3a37cb503faf';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'sms';
@@ -253,7 +253,7 @@
$apps[$x]['default_settings'][$y]['default_setting_name'] = 'text';
$apps[$x]['default_settings'][$y]['default_setting_value'] = '';
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'false';
- $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
+ $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = 'cede4bca-e855-4191-a14c-6f69b3aefb2e';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'sms';
@@ -261,12 +261,13 @@
$apps[$x]['default_settings'][$y]['default_setting_name'] = 'text';
$apps[$x]['default_settings'][$y]['default_setting_value'] = '';
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'false';
- $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
+ $apps[$x]['default_settings'][$y]['default_setting_description'] = '';
$y++;
- //schema details
+ //schema details
$y=0;
- $apps[$x]['db'][$y]['table'] = "v_sms_messages";
+ $apps[$x]['db'][$y]['table']['name'] = "v_sms_messages";
+ $apps[$x]['db'][$y]['table']['parent'] = "";
$z=0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "sms_message_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
@@ -321,7 +322,8 @@
$z++;
$y=1;
- $apps[$x]['db'][$y]['table'] = "v_sms_destinations";
+ $apps[$x]['db'][$y]['table']['name'] = "v_sms_destinations";
+ $apps[$x]['db'][$y]['table']['parent'] = "";
$z=0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "sms_destination_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
@@ -354,5 +356,9 @@
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
+ $apps[$x]['db'][$y]['fields'][$z]['name'] = "chatplan_detail_data";
+ $apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+ $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+ $z++;
?>
diff --git a/sms/app_defaults.php b/sms/app_defaults.php
old mode 100644
new mode 100755
diff --git a/sms/app_languages.php b/sms/app_languages.php
old mode 100644
new mode 100755
index 93cf2efb..c0df13db
--- a/sms/app_languages.php
+++ b/sms/app_languages.php
@@ -130,6 +130,32 @@
$text['label-message']['ar-eg'] = "";
$text['label-message']['he'] = "";
+$text['label-chatplan_detail_data']['en-us'] = "Extension or Ring Group";
+$text['label-chatplan_detail_data']['es-cl'] = "";
+$text['label-chatplan_detail_data']['pt-pt'] = "";
+$text['label-chatplan_detail_data']['fr-fr'] = "";
+$text['label-chatplan_detail_data']['pt-br'] = "";
+$text['label-chatplan_detail_data']['pl'] = " ";
+$text['label-chatplan_detail_data']['uk'] = "";
+$text['label-chatplan_detail_data']['sv-se'] = "";
+$text['label-chatplan_detail_data']['ro'] = "";
+$text['label-chatplan_detail_data']['de-at'] = "";
+$text['label-chatplan_detail_data']['ar-eg'] = "";
+$text['label-chatplan_detail_data']['he'] = "";
+
+$text['description-chatplan_detail_data']['en-us'] = "Routing extension or ring group for inbound SMS messages";
+$text['description-chatplan_detail_data']['es-cl'] = "";
+$text['description-chatplan_detail_data']['pt-pt'] = "";
+$text['description-chatplan_detail_data']['fr-fr'] = "";
+$text['description-chatplan_detail_data']['pt-br'] = "";
+$text['description-chatplan_detail_data']['pl'] = " ";
+$text['description-chatplan_detail_data']['uk'] = "";
+$text['description-chatplan_detail_data']['sv-se'] = "";
+$text['description-chatplan_detail_data']['ro'] = "";
+$text['description-chatplan_detail_data']['de-at'] = "";
+$text['description-chatplan_detail_data']['ar-eg'] = "";
+$text['description-chatplan_detail_data']['he'] = "";
+
$text['button-mdr']['en-us'] = "MDRs";
$text['button-mdr']['es-cl'] = "";
$text['button-mdr']['pt-pt'] = "";
diff --git a/sms/app_menu.php b/sms/app_menu.php
old mode 100644
new mode 100755
diff --git a/sms/hook/sms_hook_bandwidth.php b/sms/hook/sms_hook_bandwidth.php
old mode 100644
new mode 100755
diff --git a/sms/hook/sms_hook_flowroute.php b/sms/hook/sms_hook_flowroute.php
old mode 100644
new mode 100755
diff --git a/sms/hook/sms_hook_plivo.php b/sms/hook/sms_hook_plivo.php
old mode 100644
new mode 100755
diff --git a/sms/hook/sms_hook_teli.php b/sms/hook/sms_hook_teli.php
old mode 100644
new mode 100755
diff --git a/sms/hook/sms_hook_telnyx.php b/sms/hook/sms_hook_telnyx.php
old mode 100644
new mode 100755
index fb64745a..b655d390
--- a/sms/hook/sms_hook_telnyx.php
+++ b/sms/hook/sms_hook_telnyx.php
@@ -20,4 +20,4 @@
error_log('ACCESS DENIED [SMS]: ' . print_r($_SERVER['REMOTE_ADDR'], true));
die("access denied");
}
-?>
+?>
\ No newline at end of file
diff --git a/sms/hook/sms_hook_thinq.php b/sms/hook/sms_hook_thinq.php
old mode 100644
new mode 100755
diff --git a/sms/hook/sms_hook_twilio.php b/sms/hook/sms_hook_twilio.php
old mode 100644
new mode 100755
diff --git a/sms/resources/install/scripts/app/sms/index.lua b/sms/resources/install/scripts/app/sms/index.lua
old mode 100644
new mode 100755
index d201fa76..02fb69b8
--- a/sms/resources/install/scripts/app/sms/index.lua
+++ b/sms/resources/install/scripts/app/sms/index.lua
@@ -107,7 +107,76 @@
end
event:fire();
to = extension;
- elseif direction == "outbound" then
+
+ --Send inbound SMS via email delivery
+ if (domain_uuid == nil) then
+ --get the domain_uuid using the domain name required for multi-tenant
+ if (domain_name ~= nil) then
+ sql = "SELECT domain_uuid FROM v_domains ";
+ sql = sql .. "WHERE domain_name = :domain_name and domain_enabled = 'true' ";
+ local params = {domain_name = domain_name}
+
+ if (debug["sql"]) then
+ freeswitch.consoleLog("notice", "[sms] SQL: "..sql.."; params:" .. json.encode(params) .. "\n");
+ end
+ status = dbh:query(sql, params, function(rows)
+ domain_uuid = rows["domain_uuid"];
+ end);
+ end
+ end
+ if (domain_uuid == nil) then
+ freeswitch.consoleLog("notice", "[sms] domain_uuid is nill, cannot send sms to email.");
+ else
+ sql = "SELECT v_contact_emails.email_address ";
+ sql = sql .. "from v_extensions, v_extension_users, v_users, v_contact_emails ";
+ sql = sql .. "where v_extensions.extension = :toext and v_extensions.domain_uuid = :domain_uuid and v_extensions.extension_uuid = v_extension_users.extension_uuid ";
+ sql = sql .. "and v_extension_users.user_uuid = v_users.user_uuid and v_users.contact_uuid = v_contact_emails.contact_uuid ";
+ sql = sql .. "and (v_contact_emails.email_label = 'sms' or v_contact_emails.email_label = 'SMS')";
+ local params = {toext = extension, domain_uuid = domain_uuid}
+
+ if (debug["sql"]) then
+ freeswitch.consoleLog("notice", "[sms] SQL: "..sql.."; params:" .. json.encode(params) .. "\n");
+ end
+ status = dbh:query(sql, params, function(rows)
+ send_to_email_address = rows["email_address"];
+ end);
+
+ --sql = "SELECT domain_setting_value FROM v_domain_settings ";
+ --sql = sql .. "where domain_setting_category = 'sms' and domain_setting_subcategory = 'send_from_email_address' and domain_setting_enabled = 'true' and domain_uuid = :domain_uuid";
+ --local params = {domain_uuid = domain_uuid}
+
+ --if (debug["sql"]) then
+ -- freeswitch.consoleLog("notice", "[sms] SQL: "..sql.."; params:" .. json.encode(params) .. "\n");
+ --end
+ --status = dbh:query(sql, params, function(rows)
+ -- send_from_email_address = rows["domain_setting_value"];
+ --end);
+ -- Tried setting the "from" address, above, but default email facility is overriding with global/domain-level default settings.
+ send_from_email_address = 'noreply@example.com' -- this gets overridden if using v_mailto.php
+
+ if (send_to_email_address ~= nill and send_from_email_address ~= nill) then
+ subject = 'Text Message from: ' .. from;
+ emailbody = 'To: ' .. to .. '
Msg:' .. body;
+ if (debug["info"]) then
+ freeswitch.consoleLog("info", emailbody);
+ end
+ --luarun email.lua send_to_email_address send_from_email_address '' subject emailbody;
+ --replace the ' with a single quote
+ emailbody = emailbody:gsub("'", "'");
+
+ --replace the " with double quote
+ emailbody = emailbody:gsub(""", [["]]);
+
+ --send the email
+ freeswitch.email(send_to_email_address,
+ send_from_email_address,
+ "To: "..send_to_email_address.."\nFrom: "..send_from_email_address.."\nX-Headers: \nSubject: "..subject,
+ emailbody
+ );
+ end
+ end
+
+ elseif direction == "outbound" then
if (argv[3] ~= nil) then
to_user = argv[3];
to_user = to_user:gsub("^+?sip%%3A%%40","");
@@ -137,7 +206,7 @@
end
--Clean body up for Groundwire send
smsraw = body;
- smstempst, smstempend = string.find(smsraw, 'Content%-lenght:');
+ smstempst, smstempend = string.find(smsraw, 'Content%-length:');
if (smstempend == nil) then
body = smsraw;
else
@@ -148,7 +217,8 @@
body = string.sub(smsraw, smst2end + 1);
end
end
-
+ body = body:gsub('%"','');
+ --body = body:gsub('\r\n',' ');
if (debug["info"]) then
if (message ~= nil) then
@@ -246,77 +316,87 @@
api_url = rows["default_setting_value"];
end);
- if (carrier == "flowroute") then
- cmd = "curl -u ".. access_key ..":" .. secret_key .. " -H \"Content-Type: application/json\" -X POST -d '{\"to\":\"" .. to .. "\",\"from\":\"" .. outbound_caller_id_number .."\",\"body\":\"" .. body .. "\"}' " .. api_url;
- elseif (carrier == "twilio") then
- if to:len() < 11 then
- to = "1" .. to;
- end
- if outbound_caller_id_number:len() < 11 then
- outbound_caller_id_number = "1" .. outbound_caller_id_number;
- end
- -- Can be either +1NANNNNXXXX or NANNNNXXXX
- api_url = string.gsub(api_url, "{ACCOUNTSID}", access_key);
- cmd ="curl -X POST '" .. api_url .."' --data-urlencode 'To=+" .. to .."' --data-urlencode 'From=+" .. outbound_caller_id_number .. "' --data-urlencode 'Body=" .. body .. "' -u ".. access_key ..":" .. secret_key .. " --insecure";
- elseif (carrier == "teli") then
- cmd ="curl -X POST '" .. api_url .."' --data-urlencode 'destination=" .. to .."' --data-urlencode 'source=" .. outbound_caller_id_number .. "' --data-urlencode 'message=" .. body .. "' --data-urlencode 'token=" .. access_key .. "' --insecure";
- elseif (carrier == "plivo") then
- if to:len() <11 then
- to = "1"..to;
- end
- cmd="curl -i --user " .. access_key .. ":" .. secret_key .. " -H \"Content-Type: application/json\" -d '{\"src\": \"" .. outbound_caller_id_number .. "\",\"dst\": \"" .. to .."\", \"text\": \"" .. body .. "\"}' " .. api_url;
- elseif (carrier == "bandwidth") then
- if to:len() <11 then
- to = "1"..to;
- end
- if outbound_caller_id_number:len() < 11 then
- outbound_caller_id_number = "1" .. outbound_caller_id_number;
- end
- cmd="curl -v -X POST " .. api_url .." -u " .. access_key .. ":" .. secret_key .. " -H \"Content-type: application/json\" -d '{\"from\": \"+" .. outbound_caller_id_number .. "\", \"to\": \"+" .. to .."\", \"text\": \"" .. body .."\"}'"
- elseif (carrier == "thinq") then
- if to:len() < 11 then
- to = "1" .. to;
- end
- if outbound_caller_id_number:len() < 11 then
- outbound_caller_id_number = "1" .. outbound_caller_id_number;
- end
- --Get User_name
- sql = "SELECT default_setting_value FROM v_default_settings ";
- sql = sql .. "where default_setting_category = 'sms' and default_setting_subcategory = '" .. carrier .. "_username' and default_setting_enabled = 'true'";
- if (debug["sql"]) then
- freeswitch.consoleLog("notice", "[sms] SQL: "..sql.."; params:" .. json.encode(params) .. "\n");
- end
- status = dbh:query(sql, function(rows)
- username = rows["default_setting_value"];
- end);
- cmd = "curl -X POST '" .. api_url .."' -H \"Content-Type:multipart/form-data\" -F 'message=" .. body .. "' -F 'to_did=" .. to .."' -F 'from_did=" .. outbound_caller_id_number .. "' -u '".. username ..":".. access_key .."'"
- elseif (carrier == "telnyx") then
- if to:len() < 11 then
- to = "1" .. to;
+ --Check for xml content
+ smstempst, smstempend = string.find(body, '<%?xml');
+ if (smstempst ~= nil) then freeswitch.consoleLog("notice", "[sms] smstempst = '" .. smstempst .. "\n") end;
+ if (smstempend ~= nil) then freeswitch.consoleLog("notice", "[sms] smstempend = '" .. smstempend .. "\n") end;
+ if (smstempst == nil) then
+ -- No XML content, continue processing
+ if (carrier == "flowroute") then
+ cmd = "curl -u ".. access_key ..":" .. secret_key .. " -H \"Content-Type: application/json\" -X POST -d '{\"to\":\"" .. to .. "\",\"from\":\"" .. outbound_caller_id_number .."\",\"body\":\"" .. body .. "\"}' " .. api_url;
+ elseif (carrier == "twilio") then
+ if to:len() < 11 then
+ to = "1" .. to;
+ end
+ if outbound_caller_id_number:len() < 11 then
+ outbound_caller_id_number = "1" .. outbound_caller_id_number;
+ end
+ -- Can be either +1NANNNNXXXX or NANNNNXXXX
+ api_url = string.gsub(api_url, "{ACCOUNTSID}", access_key);
+ cmd ="curl -X POST '" .. api_url .."' --data-urlencode 'To=+" .. to .."' --data-urlencode 'From=+" .. outbound_caller_id_number .. "' --data-urlencode 'Body=" .. body .. "' -u ".. access_key ..":" .. secret_key .. " --insecure";
+ elseif (carrier == "teli") then
+ cmd ="curl -X POST '" .. api_url .."' --data-urlencode 'destination=" .. to .."' --data-urlencode 'source=" .. outbound_caller_id_number .. "' --data-urlencode 'message=" .. body .. "' --data-urlencode 'token=" .. access_key .. "' --insecure";
+ elseif (carrier == "plivo") then
+ if to:len() <11 then
+ to = "1"..to;
+ end
+ cmd="curl -i --user " .. access_key .. ":" .. secret_key .. " -H \"Content-Type: application/json\" -d '{\"src\": \"" .. outbound_caller_id_number .. "\",\"dst\": \"" .. to .."\", \"text\": \"" .. body .. "\"}' " .. api_url;
+ elseif (carrier == "bandwidth") then
+ if to:len() <11 then
+ to = "1"..to;
+ end
+ if outbound_caller_id_number:len() < 11 then
+ outbound_caller_id_number = "1" .. outbound_caller_id_number;
+ end
+ cmd="curl -v -X POST " .. api_url .." -u " .. access_key .. ":" .. secret_key .. " -H \"Content-type: application/json\" -d '{\"from\": \"+" .. outbound_caller_id_number .. "\", \"to\": \"+" .. to .."\", \"text\": \"" .. body .."\"}'"
+ elseif (carrier == "thinq") then
+ if to:len() < 11 then
+ to = "1" .. to;
+ end
+ if outbound_caller_id_number:len() < 11 then
+ outbound_caller_id_number = "1" .. outbound_caller_id_number;
+ end
+ --Get User_name
+ sql = "SELECT default_setting_value FROM v_default_settings ";
+ sql = sql .. "where default_setting_category = 'sms' and default_setting_subcategory = '" .. carrier .. "_username' and default_setting_enabled = 'true'";
+ if (debug["sql"]) then
+ freeswitch.consoleLog("notice", "[sms] SQL: "..sql.."; params:" .. json.encode(params) .. "\n");
+ end
+ status = dbh:query(sql, function(rows)
+ username = rows["default_setting_value"];
+ end);
+ cmd = "curl -X POST '" .. api_url .."' -H \"Content-Type:multipart/form-data\" -F 'message=" .. body .. "' -F 'to_did=" .. to .."' -F 'from_did=" .. outbound_caller_id_number .. "' -u '".. username ..":".. access_key .."'"
+ elseif (carrier == "telnyx") then
+ if to:len() < 11 then
+ to = "1" .. to;
+ end
+ if outbound_caller_id_number:len() < 11 then
+ outbound_caller_id_number = "1" .. outbound_caller_id_number;
+ end
+ --Get delivery_status_webhook_url
+ sql = "SELECT default_setting_value FROM v_default_settings ";
+ sql = sql .. "where default_setting_category = 'sms' and default_setting_subcategory = '" .. carrier .. "_delivery_status_webhook_url' and default_setting_enabled = 'true'";
+ if (debug["sql"]) then
+ freeswitch.consoleLog("notice", "[sms] SQL: "..sql.."; params:" .. json.encode(params) .. "\n");
+ end
+ status = dbh:query(sql, function(rows)
+ delivery_status_webhook_url = rows["default_setting_value"];
+ end);
+ cmd ="curl -X POST \"" .. api_url .."\" -H \"Content-Type: application/json\" -H \"x-profile-secret: " .. secret_key .. "\" -d '{\"from\": \"+" .. outbound_caller_id_number .. "\", \"to\": \"+" .. to .. "\", \"body\": \"" .. body .. "\", \"delivery_status_webhook_url\": \"" .. delivery_status_webhook_url .. "\"}'";
end
- if outbound_caller_id_number:len() < 11 then
- outbound_caller_id_number = "1" .. outbound_caller_id_number;
+ if (debug["info"]) then
+ freeswitch.consoleLog("notice", "[sms] CMD: " .. cmd .. "\n");
end
- --Get delivery_status_webhook_url
- sql = "SELECT default_setting_value FROM v_default_settings ";
- sql = sql .. "where default_setting_category = 'sms' and default_setting_subcategory = '" .. carrier .. "_delivery_status_webhook_url' and default_setting_enabled = 'true'";
- if (debug["sql"]) then
- freeswitch.consoleLog("notice", "[sms] SQL: "..sql.."; params:" .. json.encode(params) .. "\n");
+ local handle = io.popen(cmd)
+ local result = handle:read("*a")
+ handle:close()
+ if (debug["info"]) then
+ freeswitch.consoleLog("notice", "[sms] CURL Returns: " .. result .. "\n");
end
- status = dbh:query(sql, function(rows)
- delivery_status_webhook_url = rows["default_setting_value"];
- end);
- cmd ="curl -X POST \"" .. api_url .."\" -H \"Content-Type: application/json\" -H \"x-profile-secret: " .. secret_key .. "\" -d '{\"from\": \"+" .. outbound_caller_id_number .. "\", \"to\": \"+" .. to .. "\", \"body\": \"" .. body .. "\", \"delivery_status_webhook_url\": \"" .. delivery_status_webhook_url .. "\"}'";
- end
- if (debug["info"]) then
- freeswitch.consoleLog("notice", "[sms] CMD: " .. cmd .. "\n");
- end
- local handle = io.popen(cmd)
- local result = handle:read("*a")
- handle:close()
- if (debug["info"]) then
- freeswitch.consoleLog("notice", "[sms] CURL Returns: " .. result .. "\n");
- end
+ else
+ -- XML content
+ freeswitch.consoleLog("notice", "[sms] Body contains XML content, not sending\n");
+ end
-- os.execute(cmd)
end
diff --git a/sms/resources/templates/conf/chatplan/default.xml b/sms/resources/templates/conf/chatplan/default.xml
old mode 100644
new mode 100755
index 586e9f53..766a2ab5
--- a/sms/resources/templates/conf/chatplan/default.xml
+++ b/sms/resources/templates/conf/chatplan/default.xml
@@ -7,12 +7,19 @@
-
-
\n"; + echo " ".$text['label-chatplan_detail_data']."\n"; + echo " | \n"; + echo "\n";
+ echo " \n";
+ echo " \n"; + echo $text['description-chatplan_detail_data']."\n"; + echo " | \n";
+ echo "
\n"; echo " ".$text['label-description']."\n"; @@ -217,9 +228,9 @@ if ($action == "update") { echo " \n"; - echo " "; + echo " "; } - + echo " |