From ed93aae1c2109c5b14061c567598d62a3bcb67e0 Mon Sep 17 00:00:00 2001
From: Alexandre Gagner
Date: Thu, 12 Aug 2021 00:15:53 +0200
Subject: [PATCH 1/2] add octopush notification service
---
server/notification.js | 27 ++++++++++++++++++++++
src/components/NotificationDialog.vue | 32 +++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/server/notification.js b/server/notification.js
index 05dae8ad1..1f13ad496 100644
--- a/server/notification.js
+++ b/server/notification.js
@@ -193,6 +193,33 @@ class Notification {
console.log(error)
return false;
}
+ } else if (notification.type === "octopush") {
+ try {
+ let config = {
+ headers: {
+ 'api-key': notification.octopushAPIKey,
+ 'api-login': notification.octopushLogin,
+ 'cache-control': 'no-cache'
+ }
+ };
+ let data = {
+ "recipients": [
+ {
+ "phone_number": notification.octopushPhoneNumber
+ }
+ ],
+ "text": msg,
+ "type": notification.octopushSMSType,
+ "purpose": "alert",
+ "sender": notification.octopushSenderName
+ };
+
+ await axios.post(`https://api.octopush.com/v1/public/sms-campaign/send`, data, config)
+ return true;
+ } catch (error) {
+ console.log(error)
+ return false;
+ }
} else if (notification.type === "slack") {
try {
if (heartbeatJSON == null) {
diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue
index 6c481681d..a3e72da07 100644
--- a/src/components/NotificationDialog.vue
+++ b/src/components/NotificationDialog.vue
@@ -22,6 +22,7 @@
+
@@ -252,6 +253,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ More info on: https://octopush.com/api-sms-documentation/envoi-de-sms/
+
+
+
From eb34dc6cc24e5946d6b36d99dd8710a0c4a673c3 Mon Sep 17 00:00:00 2001
From: Alexandre Gagner
Date: Thu, 12 Aug 2021 00:58:51 +0200
Subject: [PATCH 2/2] Update notification.js
Fix remove non ascii char from msg
---
server/notification.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/server/notification.js b/server/notification.js
index 1f13ad496..56838513e 100644
--- a/server/notification.js
+++ b/server/notification.js
@@ -208,7 +208,8 @@ class Notification {
"phone_number": notification.octopushPhoneNumber
}
],
- "text": msg,
+ //octopush not supporting non ascii char
+ "text": msg.replace(/[^\x00-\x7F]/g, ""),
"type": notification.octopushSMSType,
"purpose": "alert",
"sender": notification.octopushSenderName