From 458cdf9f9b79ac5dbcd280bd791d970d891840bb Mon Sep 17 00:00:00 2001 From: Adam Stachowicz Date: Sat, 6 Jan 2024 18:06:06 +0000 Subject: [PATCH 01/10] Fix `encodeBase64` for empty password or user in HTTP Basic Authentication (#4326) --- server/model/monitor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index e407e5a2..2dc77fbd 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -230,10 +230,12 @@ class Monitor extends BeanModel { /** * Encode user and password to Base64 encoding * for HTTP "basic" auth, as per RFC-7617 + * @param {string|null} user - The username (nullable if not changed by a user) + * @param {string|null} pass - The password (nullable if not changed by a user) * @returns {string} */ encodeBase64(user, pass) { - return Buffer.from(user + ":" + pass).toString("base64"); + return Buffer.from(`${user || ""}:${pass || ""}`).toString("base64"); } /** From 7635ab54a08991cccf58655b6fc0244b33899fb3 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sun, 7 Jan 2024 16:55:10 +0100 Subject: [PATCH 02/10] made sure that the i18n does use `navigator.languages` instead of `navigator.language` for automatic language detection (#4244) --- src/i18n.js | 14 ++++++++++---- test/cypress/unit/i18n.spec.js | 12 ++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/i18n.js b/src/i18n.js index c33b523e..ad3894d4 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -57,10 +57,16 @@ for (let lang in languageList) { const rtlLangs = [ "fa", "ar-SY", "ur" ]; -export const currentLocale = () => localStorage.locale - || languageList[navigator.language] && navigator.language - || languageList[navigator.language.substring(0, 2)] && navigator.language.substring(0, 2) - || "en"; +/** + * Find the best matching locale to display + * If no locale can be matched, the default is "en" + * @returns {string} the locale that should be displayed + */ +export function currentLocale() { + const potentialLocales = [ localStorage.locale, navigator.language, navigator.language.substring(0, 2), ...navigator.languages ]; + const availableLocales = potentialLocales.filter(l => languageList[l]); + return availableLocales[0] || "en"; +} export const localeDirection = () => { return rtlLangs.includes(currentLocale()) ? "rtl" : "ltr"; diff --git a/test/cypress/unit/i18n.spec.js b/test/cypress/unit/i18n.spec.js index da63d95a..c53f341f 100644 --- a/test/cypress/unit/i18n.spec.js +++ b/test/cypress/unit/i18n.spec.js @@ -4,9 +4,13 @@ describe("Test i18n.js", () => { it("currentLocale()", () => { const setLanguage = (language) => { - Object.defineProperty(window.navigator, 'language', { - value: language, - writable: true + Object.defineProperty(window.navigator, 'language', { + value: language, + writable: true + }); + Object.defineProperty(window.navigator, 'languages', { + value: [language], + writable: true }); } setLanguage('en-EN'); @@ -41,4 +45,4 @@ describe("Test i18n.js", () => { expect(currentLocale()).equal("zh-HK"); }); -}); \ No newline at end of file +}); From b4e45c7ce8ceb47d55c2ab41310852f052227047 Mon Sep 17 00:00:00 2001 From: AnnAngela Date: Sat, 20 Jan 2024 03:29:13 +0800 Subject: [PATCH 03/10] fix(notification-dingding): throw error when failed (#3598) --- server/notification-providers/dingding.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/notification-providers/dingding.js b/server/notification-providers/dingding.js index cea0b0a1..8f4bd482 100644 --- a/server/notification-providers/dingding.js +++ b/server/notification-providers/dingding.js @@ -18,7 +18,7 @@ class DingDing extends NotificationProvider { text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`, } }; - if (this.sendToDingDing(notification, params)) { + if (await this.sendToDingDing(notification, params)) { return okMsg; } } else { @@ -28,7 +28,7 @@ class DingDing extends NotificationProvider { content: msg } }; - if (this.sendToDingDing(notification, params)) { + if (await this.sendToDingDing(notification, params)) { return okMsg; } } @@ -59,7 +59,7 @@ class DingDing extends NotificationProvider { if (result.data.errmsg === "ok") { return true; } - return false; + throw new Error(result.data.errmsg); } /** From 288cab6dd775de94eb21db1579b8264afd47ea45 Mon Sep 17 00:00:00 2001 From: Nelson Chan <3271800+chakflying@users.noreply.github.com> Date: Thu, 25 Jan 2024 07:59:42 +0800 Subject: [PATCH 04/10] Fix: Make sure browser is connected before returning (#4417) --- .../monitor-types/real-browser-monitor-type.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/server/monitor-types/real-browser-monitor-type.js b/server/monitor-types/real-browser-monitor-type.js index 5e5a56a0..ae814fa2 100644 --- a/server/monitor-types/real-browser-monitor-type.js +++ b/server/monitor-types/real-browser-monitor-type.js @@ -9,6 +9,10 @@ const Database = require("../database"); const jwt = require("jsonwebtoken"); const config = require("../config"); +/** + * Cached instance of a browser + * @type {import ("playwright-core").Browser} + */ let browser = null; let allowedList = []; @@ -62,8 +66,15 @@ async function isAllowedChromeExecutable(executablePath) { return allowedList.includes(executablePath); } +/** + * Get the current instance of the browser. If there isn't one, create + * it. + * @returns {Promise} The browser + */ async function getBrowser() { - if (!browser) { + if (browser && browser.isConnected()) { + return browser; + } else { let executablePath = await Settings.get("chromeExecutable"); executablePath = await prepareChromeExecutable(executablePath); @@ -72,8 +83,9 @@ async function getBrowser() { //headless: false, executablePath, }); + + return browser; } - return browser; } async function prepareChromeExecutable(executablePath) { From 2b8f55194f7a4b21427cb02b2dcf6c662105c22f Mon Sep 17 00:00:00 2001 From: Nelson Chan <3271800+chakflying@users.noreply.github.com> Date: Sun, 28 Jan 2024 03:18:24 +0800 Subject: [PATCH 05/10] Fix: [JSON-Query] Prevent parsing string-only JSON (#4425) --- server/model/monitor.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 2dc77fbd..40cdd735 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -578,8 +578,12 @@ class Monitor extends BeanModel { let data = res.data; // convert data to object - if (typeof data === "string") { - data = JSON.parse(data); + if (typeof data === "string" && res.headers["content-type"] !== "application/json") { + try { + data = JSON.parse(data); + } catch (_) { + // Failed to parse as JSON, just process it as a string + } } let expression = jsonata(this.jsonPath); From 21bbf3e1da6492ab0427d44f8a564dd30c655022 Mon Sep 17 00:00:00 2001 From: Simon Nilsson Date: Fri, 22 Mar 2024 08:23:22 +0100 Subject: [PATCH 06/10] added files --- .../cellsyntmobileservices.js | 156 ++++++++++++++++++ server/notification.js | 4 +- src/components/NotificationDialog.vue | 3 +- .../notifications/CellsyntMobileServices.vue | 43 +++++ src/components/notifications/index.js | 5 +- 5 files changed, 208 insertions(+), 3 deletions(-) create mode 100644 server/notification-providers/cellsyntmobileservices.js create mode 100644 src/components/notifications/CellsyntMobileServices.vue diff --git a/server/notification-providers/cellsyntmobileservices.js b/server/notification-providers/cellsyntmobileservices.js new file mode 100644 index 00000000..49bc93eb --- /dev/null +++ b/server/notification-providers/cellsyntmobileservices.js @@ -0,0 +1,156 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class CellsyntMobileServices extends NotificationProvider { + + name = "cellsyntmobileservices"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + + try { + let config = { + headers: { + "Content-Type": "application/json", + "Authorization": "Basic " + Buffer.from(notification.clicksendsmsLogin + ":" + notification.clicksendsmsPassword).toString("base64"), + "Accept": "text/json", + } + }; + let data = { + /* messages: [ + { + "body": msg.replace(/[^\x00-\x7F]/g, ""), + "to": notification.clicksendsmsToNumber, + "source": "uptime-kuma", + "from": notification.clicksendsmsSenderName, + } + ]*/ + messages: [ + { + //"from": notification.clicksendsmsSenderName, + + /* Your username (received when account is setup). + */ + "username": "abc123", + + /* Your password to use together with the username for + authentication (received when account is setup). + */ + "password": "abc123", + + /* Recipient's telephone number on international format with + leading 00 followed by country code, e.g. 00447920110000 for + UK number 07920 110 000 (max 17 digits in total). + To send the same message to multiple recipients, separate + numbers with comma. Max 25000 recipients per HTTP request. + */ + "destination": "0046738387444", + + "text": msg.replace(/[^\x00-\x7F]/g, ""), + /* Character set text and other data is sent as in the HTTP + request. Possible values: ISO-8859-1 (default) and UTF-8 + */ + "charset": "UTF-8", + + /* Controls the originator type the message should be sent with. + Possible values: numeric, shortcode and alpha. + */ + "originatortype": "alpha", + + /* Identifier which will be visible on recipient's mobile phone as + originator of the message. Allowed values and function depends + on parameter originatortype's value according to below: + ** numeric ** + Numeric value (max 15 digits) with telephone number on + international format without leading 00 (example UK number + 07920 110 000 should be set as 447920110000). Receiving + mobile phone will add a leading + sign and thus see the + originator as a normal mobile phone number (+447920110000). + Therefore it is also possible to reply to the message. + ** shortcode ** + Numerical value (max 15 digits). Used to set a shortcode in an + operator network as originator (i.e. will be shown without leading + + sign, e.g. 72456). + ** alpha ** + 3Send SMS + Alphanumeric string (max 11 characters). The following + characters are guaranteed to work: a-z, A-Z and 0-9. Other + characters may work but functionality can not be guaranteed. + Recipients can not reply to messages with alphanumeric + originators + */ + //"originator": "uptime-kuma", + "originator": notification.clicksendsmsSenderName, + /* Type of message that should be sent. Possible values: text + (default), binary and unicode */ + "type": "text", + + /* Maximum number of SMS permitted to be linked together when + needed (default value is 1, see Long SMS). Maximum value is 6 + (i.e. max 153 x 6 = 918 characters). + */ + "allowconcat": 1, + + /* Can be used if you want to prevent a message from being + delivered after a certain time, e.g. 9 PM the same evening if + information thereafter is considered invalid / outdated. If + message has not been delivered after the set time (e.g. mobile + phone was switched off) you will get a delivery receipt with + status "failed". + Value should be given as a Unix timestamp. Different operators + permit different allowed max values (e.g. 3 days expiry time). If + a value is set that is above an operator's max allowed time it will + be adjusted to the highest possible value. + */ + //"expiry": "9 PM", + + /* Value can be set to true if message should be sent as "flash + message", i.e. displayed directly on phone screen instead of + being saved to inbox. This is identical to setting class=0. + Please note that support for flash messages cannot be + guaranteed to all operator networks. If flash is not supported the + message will be sent as a regular text message instead + (class=1). + */ + //"flash": "", + + /* Message class can be set to 0 (flash message), 1 (default, MEspecific), 2 (SIM-specific) or 3 (TE-specific). + */ + //"class": "", + + /* UDH (User Data Header) can be used to send concatenated + SMS, contain formatting information, convey port numbers as a + mean to cause start of an application etc. The value should be + given on hexadecimal format for the corresponding bytes you + wish to send (e.g. AABBCC). + */ + //"udh": "", + + /* Protocol Identifier (specified in GSM 03.40) says how the + message should be interpreted. Value should be given on + hexadecimal format, e.g. 00 for a regular message and 7D + (decimal 125) for a configuration message ("ME Data + download"). + */ + //"pid": "", + } + ] + }; + let resp = await axios.post("https://se-1.cellsynt.net/sms.php", data, config); + console.log(resp); + if (resp.data.data.messages[0].status !== "SUCCESS") { + let error = "Something gone wrong. Api returned " + resp.data.data.messages[0].status + "."; + this.throwGeneralAxiosError(error); + } + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = CellsyntMobileServices; diff --git a/server/notification.js b/server/notification.js index 570c440d..83e36985 100644 --- a/server/notification.js +++ b/server/notification.js @@ -53,6 +53,7 @@ const GoAlert = require("./notification-providers/goalert"); const SMSManager = require("./notification-providers/smsmanager"); const ServerChan = require("./notification-providers/serverchan"); const ZohoCliq = require("./notification-providers/zoho-cliq"); +const CellsyntMobileServices = require("./notification-providers/cellsyntmobileservices"); class Notification { @@ -117,7 +118,8 @@ class Notification { new Webhook(), new WeCom(), new GoAlert(), - new ZohoCliq() + new ZohoCliq(), + new CellsyntMobileServices() ]; for (let item of list) { if (! item.name) { diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index f7fce0d3..c5b57bcd 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -150,7 +150,8 @@ export default { "Splunk": "Splunk", "webhook": "Webhook", "GoAlert": "GoAlert", - "ZohoCliq": "ZohoCliq" + "ZohoCliq": "ZohoCliq", + "CellsyntMobileServices": "Cellsynt mobile services" }; // Put notifications here if it's not supported in most regions or its documentation is not in English diff --git a/src/components/notifications/CellsyntMobileServices.vue b/src/components/notifications/CellsyntMobileServices.vue new file mode 100644 index 00000000..15ed241b --- /dev/null +++ b/src/components/notifications/CellsyntMobileServices.vue @@ -0,0 +1,43 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 05b82a10..15d48764 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -51,6 +51,8 @@ import WeCom from "./WeCom.vue"; import GoAlert from "./GoAlert.vue"; import ZohoCliq from "./ZohoCliq.vue"; import Splunk from "./Splunk.vue"; +import CellsyntMobileServices from "./CellsyntMobileServices.vue"; + /** * Manage all notification form. @@ -110,7 +112,8 @@ const NotificationFormList = { "WeCom": WeCom, "GoAlert": GoAlert, "ServerChan": ServerChan, - "ZohoCliq": ZohoCliq + "ZohoCliq": ZohoCliq, + "CellsyntMobileServices": CellsyntMobileServices }; export default NotificationFormList; From cbda7c63794f26885a2f70452d33b60578508a57 Mon Sep 17 00:00:00 2001 From: Simon Nilsson Date: Fri, 22 Mar 2024 13:25:49 +0100 Subject: [PATCH 07/10] Notification provider testing now working --- .../cellsyntmobileservices.js | 261 +++++++++--------- .../notifications/CellsyntMobileServices.vue | 62 +++-- 2 files changed, 174 insertions(+), 149 deletions(-) diff --git a/server/notification-providers/cellsyntmobileservices.js b/server/notification-providers/cellsyntmobileservices.js index 49bc93eb..169ecd4e 100644 --- a/server/notification-providers/cellsyntmobileservices.js +++ b/server/notification-providers/cellsyntmobileservices.js @@ -1,9 +1,12 @@ const NotificationProvider = require("./notification-provider"); -const axios = require("axios"); +const { DOWN, UP } = require("../../src/util"); +const { default: axios } = require("axios"); +const Crypto = require("crypto"); +const qs = require("qs"); class CellsyntMobileServices extends NotificationProvider { - name = "cellsyntmobileservices"; + name = "CellsyntMobileServices"; /** * @inheritdoc @@ -12,137 +15,133 @@ class CellsyntMobileServices extends NotificationProvider { let okMsg = "Sent Successfully."; try { - let config = { - headers: { - "Content-Type": "application/json", - "Authorization": "Basic " + Buffer.from(notification.clicksendsmsLogin + ":" + notification.clicksendsmsPassword).toString("base64"), - "Accept": "text/json", - } - }; let data = { - /* messages: [ - { - "body": msg.replace(/[^\x00-\x7F]/g, ""), - "to": notification.clicksendsmsToNumber, - "source": "uptime-kuma", - "from": notification.clicksendsmsSenderName, - } - ]*/ - messages: [ - { - //"from": notification.clicksendsmsSenderName, - - /* Your username (received when account is setup). - */ - "username": "abc123", - - /* Your password to use together with the username for - authentication (received when account is setup). - */ - "password": "abc123", - - /* Recipient's telephone number on international format with - leading 00 followed by country code, e.g. 00447920110000 for - UK number 07920 110 000 (max 17 digits in total). - To send the same message to multiple recipients, separate - numbers with comma. Max 25000 recipients per HTTP request. - */ - "destination": "0046738387444", - - "text": msg.replace(/[^\x00-\x7F]/g, ""), - /* Character set text and other data is sent as in the HTTP - request. Possible values: ISO-8859-1 (default) and UTF-8 - */ - "charset": "UTF-8", - - /* Controls the originator type the message should be sent with. - Possible values: numeric, shortcode and alpha. - */ - "originatortype": "alpha", - - /* Identifier which will be visible on recipient's mobile phone as - originator of the message. Allowed values and function depends - on parameter originatortype's value according to below: - ** numeric ** - Numeric value (max 15 digits) with telephone number on - international format without leading 00 (example UK number - 07920 110 000 should be set as 447920110000). Receiving - mobile phone will add a leading + sign and thus see the - originator as a normal mobile phone number (+447920110000). - Therefore it is also possible to reply to the message. - ** shortcode ** - Numerical value (max 15 digits). Used to set a shortcode in an - operator network as originator (i.e. will be shown without leading - + sign, e.g. 72456). - ** alpha ** - 3Send SMS - Alphanumeric string (max 11 characters). The following - characters are guaranteed to work: a-z, A-Z and 0-9. Other - characters may work but functionality can not be guaranteed. - Recipients can not reply to messages with alphanumeric - originators - */ - //"originator": "uptime-kuma", - "originator": notification.clicksendsmsSenderName, - /* Type of message that should be sent. Possible values: text - (default), binary and unicode */ - "type": "text", - - /* Maximum number of SMS permitted to be linked together when - needed (default value is 1, see Long SMS). Maximum value is 6 - (i.e. max 153 x 6 = 918 characters). - */ - "allowconcat": 1, - - /* Can be used if you want to prevent a message from being - delivered after a certain time, e.g. 9 PM the same evening if - information thereafter is considered invalid / outdated. If - message has not been delivered after the set time (e.g. mobile - phone was switched off) you will get a delivery receipt with - status "failed". - Value should be given as a Unix timestamp. Different operators - permit different allowed max values (e.g. 3 days expiry time). If - a value is set that is above an operator's max allowed time it will - be adjusted to the highest possible value. - */ - //"expiry": "9 PM", - - /* Value can be set to true if message should be sent as "flash - message", i.e. displayed directly on phone screen instead of - being saved to inbox. This is identical to setting class=0. - Please note that support for flash messages cannot be - guaranteed to all operator networks. If flash is not supported the - message will be sent as a regular text message instead - (class=1). - */ - //"flash": "", - - /* Message class can be set to 0 (flash message), 1 (default, MEspecific), 2 (SIM-specific) or 3 (TE-specific). - */ - //"class": "", - - /* UDH (User Data Header) can be used to send concatenated - SMS, contain formatting information, convey port numbers as a - mean to cause start of an application etc. The value should be - given on hexadecimal format for the corresponding bytes you - wish to send (e.g. AABBCC). - */ - //"udh": "", - - /* Protocol Identifier (specified in GSM 03.40) says how the - message should be interpreted. Value should be given on - hexadecimal format, e.g. 00 for a regular message and 7D - (decimal 125) for a configuration message ("ME Data - download"). - */ - //"pid": "", - } - ] + params: { + /* Your username (received when account is setup). + */ + "username": notification.cellsyntLogin, + + /* Your password to use together with the username for + authentication (received when account is setup). + */ + "password": notification.cellsyntPassword, + + /* Recipient's telephone number on international format with + leading 00 followed by country code, e.g. 00447920110000 for + UK number 07920 110 000 (max 17 digits in total). + To send the same message to multiple recipients, separate + numbers with comma. Max 25000 recipients per HTTP request. + */ + "destination": notification.cellsyntDestination, + + "text": msg.replace(/[^\x00-\x7F]/g, ""), + /* Character set text and other data is sent as in the HTTP + request. Possible values: ISO-8859-1 (default) and UTF-8 + */ + "charset": "UTF-8", + + /* Controls the originator type the message should be sent with. + Possible values: numeric, shortcode and alpha. + */ + "originatortype": notification.Originatortype, + + /* Identifier which will be visible on recipient's mobile phone as + originator of the message. Allowed values and function depends + on parameter originatortype's value according to below: + ** numeric ** + Numeric value (max 15 digits) with telephone number on + international format without leading 00 (example UK number + 07920 110 000 should be set as 447920110000). Receiving + mobile phone will add a leading + sign and thus see the + originator as a normal mobile phone number (+447920110000). + Therefore it is also possible to reply to the message. + ** shortcode ** + Numerical value (max 15 digits). Used to set a shortcode in an + operator network as originator (i.e. will be shown without leading + + sign, e.g. 72456). + ** alpha ** + 3Send SMS + Alphanumeric string (max 11 characters). The following + characters are guaranteed to work: a-z, A-Z and 0-9. Other + characters may work but functionality can not be guaranteed. + Recipients can not reply to messages with alphanumeric + originators + */ + //"originator": "uptime-kuma", + "originator": notification.cellsyntOriginator, + /* Type of message that should be sent. Possible values: text + (default), binary and unicode */ + "type": "text", + + /* Maximum number of SMS permitted to be linked together when + needed (default value is 1, see Long SMS). Maximum value is 6 + (i.e. max 153 x 6 = 918 characters). + */ + "allowconcat": notification.cellsyntAllowLongSMS?6:1, + + /* Can be used if you want to prevent a message from being + delivered after a certain time, e.g. 9 PM the same evening if + information thereafter is considered invalid / outdated. If + message has not been delivered after the set time (e.g. mobile + phone was switched off) you will get a delivery receipt with + status "failed". + Value should be given as a Unix timestamp. Different operators + permit different allowed max values (e.g. 3 days expiry time). If + a value is set that is above an operator's max allowed time it will + be adjusted to the highest possible value. + */ + //"expiry": "9 PM", + + /* Value can be set to true if message should be sent as "flash + message", i.e. displayed directly on phone screen instead of + being saved to inbox. This is identical to setting class=0. + Please note that support for flash messages cannot be + guaranteed to all operator networks. If flash is not supported the + message will be sent as a regular text message instead + (class=1). + */ + //"flash": "", + + /* Message class can be set to 0 (flash message), 1 (default, MEspecific), 2 (SIM-specific) or 3 (TE-specific). + */ + //"class": "", + + /* UDH (User Data Header) can be used to send concatenated + SMS, contain formatting information, convey port numbers as a + mean to cause start of an application etc. The value should be + given on hexadecimal format for the corresponding bytes you + wish to send (e.g. AABBCC). + */ + //"udh": "", + + /* Protocol Identifier (specified in GSM 03.40) says how the + message should be interpreted. Value should be given on + hexadecimal format, e.g. 00 for a regular message and 7D + (decimal 125) for a configuration message ("ME Data + download"). + */ + //"pid": "", + } }; - let resp = await axios.post("https://se-1.cellsynt.net/sms.php", data, config); - console.log(resp); - if (resp.data.data.messages[0].status !== "SUCCESS") { - let error = "Something gone wrong. Api returned " + resp.data.data.messages[0].status + "."; + try { + if (heartbeatJSON != null) { + var d = new Date(heartbeatJSON["time"]), + dformat = [d.getMonth()+1, + d.getDate(), + d.getFullYear()].join('/')+' '+ + [d.getHours(), + d.getMinutes()].join(':'); + msg = dformat+" - "+msg; + data.params.text = msg.replace(/[^\x00-\x7F]/g, ""); + } + + let resp = await axios.post("https://se-1.cellsynt.net/sms.php", null, data); + if(typeof resp.data == undefined || resp.data == null || resp.data.includes("Error")) { + this.throwGeneralAxiosError(resp.data); + }else{ + + } + }catch (error) { this.throwGeneralAxiosError(error); } diff --git a/src/components/notifications/CellsyntMobileServices.vue b/src/components/notifications/CellsyntMobileServices.vue index 15ed241b..06532828 100644 --- a/src/components/notifications/CellsyntMobileServices.vue +++ b/src/components/notifications/CellsyntMobileServices.vue @@ -1,34 +1,60 @@ From c34ec0dc9114a521eb7e07490a9ab86ec72edbb0 Mon Sep 17 00:00:00 2001 From: Simon Nilsson Date: Sun, 24 Mar 2024 13:38:41 +0100 Subject: [PATCH 08/10] QA release --- .../notifications/CellsyntMobileServices.vue | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/notifications/CellsyntMobileServices.vue b/src/components/notifications/CellsyntMobileServices.vue index 06532828..99cb8772 100644 --- a/src/components/notifications/CellsyntMobileServices.vue +++ b/src/components/notifications/CellsyntMobileServices.vue @@ -10,23 +10,23 @@
-

numeric:
+

Numeric:
Numeric value (max 15 digits) with telephone number on international format without leading 00 (example UK number 07920 110 000 should be set as 447920110000). Receiving mobile phone will add a leading + sign and thus see the originator as a normal mobile phone number (+447920110000). Therefore it is also possible to reply to the message.

-

shortcode:
+

Shortcode:
Numerical value (max 15 digits). Used to set a shortcode in an operator network as originator (i.e. will be shown without leading + sign, e.g. 72456).

-

alpha:
+

Alpha:
Alphanumeric string (max 11 characters). The following characters are guaranteed to work: a-z, A-Z and 0-9. Other characters may work but functionality can not be guaranteed. @@ -56,6 +56,12 @@ numbers with comma. Max 25000 recipients per HTTP request.

Long SMS (also known as "concatenated SMS") enables sending messages exceeding 160 characters.
+
+ +
+ For sign-up and price information check out this link, https://www.cellsynt.com/en/ +
+
From 300c21d3ab0045c224f6c567d0d4723437af4e10 Mon Sep 17 00:00:00 2001 From: Simon Nilsson Date: Sun, 24 Mar 2024 18:04:19 +0100 Subject: [PATCH 09/10] Remove timestamp in notification because phone already show it in SMS log --- server/notification-providers/cellsyntmobileservices.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/server/notification-providers/cellsyntmobileservices.js b/server/notification-providers/cellsyntmobileservices.js index 169ecd4e..68959549 100644 --- a/server/notification-providers/cellsyntmobileservices.js +++ b/server/notification-providers/cellsyntmobileservices.js @@ -125,13 +125,7 @@ class CellsyntMobileServices extends NotificationProvider { }; try { if (heartbeatJSON != null) { - var d = new Date(heartbeatJSON["time"]), - dformat = [d.getMonth()+1, - d.getDate(), - d.getFullYear()].join('/')+' '+ - [d.getHours(), - d.getMinutes()].join(':'); - msg = dformat+" - "+msg; + msg = msg; data.params.text = msg.replace(/[^\x00-\x7F]/g, ""); } From 23af76c43d24401ae0a2477e6658630001ed1a4f Mon Sep 17 00:00:00 2001 From: Simon Nilsson Date: Mon, 25 Mar 2024 21:12:16 +0100 Subject: [PATCH 10/10] Modified files and last correction --- ...{cellsyntmobileservices.js => cellsynt.js} | 44 +++-------- server/notification.js | 4 +- src/components/NotificationDialog.vue | 2 +- src/components/notifications/Cellsynt.vue | 59 +++++++++++++++ .../notifications/CellsyntMobileServices.vue | 75 ------------------- src/components/notifications/index.js | 4 +- 6 files changed, 75 insertions(+), 113 deletions(-) rename server/notification-providers/{cellsyntmobileservices.js => cellsynt.js} (80%) create mode 100644 src/components/notifications/Cellsynt.vue delete mode 100644 src/components/notifications/CellsyntMobileServices.vue diff --git a/server/notification-providers/cellsyntmobileservices.js b/server/notification-providers/cellsynt.js similarity index 80% rename from server/notification-providers/cellsyntmobileservices.js rename to server/notification-providers/cellsynt.js index 68959549..d2c4fe6c 100644 --- a/server/notification-providers/cellsyntmobileservices.js +++ b/server/notification-providers/cellsynt.js @@ -1,12 +1,9 @@ const NotificationProvider = require("./notification-provider"); -const { DOWN, UP } = require("../../src/util"); const { default: axios } = require("axios"); -const Crypto = require("crypto"); -const qs = require("qs"); -class CellsyntMobileServices extends NotificationProvider { +class Cellsynt extends NotificationProvider { - name = "CellsyntMobileServices"; + name = "Cellsynt"; /** * @inheritdoc @@ -48,17 +45,6 @@ class CellsyntMobileServices extends NotificationProvider { /* Identifier which will be visible on recipient's mobile phone as originator of the message. Allowed values and function depends on parameter originatortype's value according to below: - ** numeric ** - Numeric value (max 15 digits) with telephone number on - international format without leading 00 (example UK number - 07920 110 000 should be set as 447920110000). Receiving - mobile phone will add a leading + sign and thus see the - originator as a normal mobile phone number (+447920110000). - Therefore it is also possible to reply to the message. - ** shortcode ** - Numerical value (max 15 digits). Used to set a shortcode in an - operator network as originator (i.e. will be shown without leading - + sign, e.g. 72456). ** alpha ** 3Send SMS Alphanumeric string (max 11 characters). The following @@ -66,12 +52,19 @@ class CellsyntMobileServices extends NotificationProvider { characters may work but functionality can not be guaranteed. Recipients can not reply to messages with alphanumeric originators + ** numeric ** + Numeric value (max 15 digits) with telephone number on + international format without leading 00 (example UK number + 07920 110 000 should be set as 447920110000). Receiving + mobile phone will add a leading + sign and thus see the + originator as a normal mobile phone number (+447920110000). + Therefore it is also possible to reply to the message. */ //"originator": "uptime-kuma", "originator": notification.cellsyntOriginator, /* Type of message that should be sent. Possible values: text (default), binary and unicode */ - "type": "text", + //"type": "text", /* Maximum number of SMS permitted to be linked together when needed (default value is 1, see Long SMS). Maximum value is 6 @@ -79,19 +72,6 @@ class CellsyntMobileServices extends NotificationProvider { */ "allowconcat": notification.cellsyntAllowLongSMS?6:1, - /* Can be used if you want to prevent a message from being - delivered after a certain time, e.g. 9 PM the same evening if - information thereafter is considered invalid / outdated. If - message has not been delivered after the set time (e.g. mobile - phone was switched off) you will get a delivery receipt with - status "failed". - Value should be given as a Unix timestamp. Different operators - permit different allowed max values (e.g. 3 days expiry time). If - a value is set that is above an operator's max allowed time it will - be adjusted to the highest possible value. - */ - //"expiry": "9 PM", - /* Value can be set to true if message should be sent as "flash message", i.e. displayed directly on phone screen instead of being saved to inbox. This is identical to setting class=0. @@ -132,8 +112,6 @@ class CellsyntMobileServices extends NotificationProvider { let resp = await axios.post("https://se-1.cellsynt.net/sms.php", null, data); if(typeof resp.data == undefined || resp.data == null || resp.data.includes("Error")) { this.throwGeneralAxiosError(resp.data); - }else{ - } }catch (error) { this.throwGeneralAxiosError(error); @@ -146,4 +124,4 @@ class CellsyntMobileServices extends NotificationProvider { } } -module.exports = CellsyntMobileServices; +module.exports = Cellsynt; diff --git a/server/notification.js b/server/notification.js index 83e36985..42efe33a 100644 --- a/server/notification.js +++ b/server/notification.js @@ -53,7 +53,7 @@ const GoAlert = require("./notification-providers/goalert"); const SMSManager = require("./notification-providers/smsmanager"); const ServerChan = require("./notification-providers/serverchan"); const ZohoCliq = require("./notification-providers/zoho-cliq"); -const CellsyntMobileServices = require("./notification-providers/cellsyntmobileservices"); +const Cellsynt = require("./notification-providers/cellsynt"); class Notification { @@ -119,7 +119,7 @@ class Notification { new WeCom(), new GoAlert(), new ZohoCliq(), - new CellsyntMobileServices() + new Cellsynt() ]; for (let item of list) { if (! item.name) { diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index c5b57bcd..cdc6e2cc 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -151,7 +151,7 @@ export default { "webhook": "Webhook", "GoAlert": "GoAlert", "ZohoCliq": "ZohoCliq", - "CellsyntMobileServices": "Cellsynt mobile services" + "Cellsynt": "Cellsynt" }; // Put notifications here if it's not supported in most regions or its documentation is not in English diff --git a/src/components/notifications/Cellsynt.vue b/src/components/notifications/Cellsynt.vue new file mode 100644 index 00000000..11bf3257 --- /dev/null +++ b/src/components/notifications/Cellsynt.vue @@ -0,0 +1,59 @@ + + + diff --git a/src/components/notifications/CellsyntMobileServices.vue b/src/components/notifications/CellsyntMobileServices.vue deleted file mode 100644 index 99cb8772..00000000 --- a/src/components/notifications/CellsyntMobileServices.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 15d48764..7c2ea12d 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -51,7 +51,7 @@ import WeCom from "./WeCom.vue"; import GoAlert from "./GoAlert.vue"; import ZohoCliq from "./ZohoCliq.vue"; import Splunk from "./Splunk.vue"; -import CellsyntMobileServices from "./CellsyntMobileServices.vue"; +import Cellsynt from "./Cellsynt.vue"; /** @@ -113,7 +113,7 @@ const NotificationFormList = { "GoAlert": GoAlert, "ServerChan": ServerChan, "ZohoCliq": ZohoCliq, - "CellsyntMobileServices": CellsyntMobileServices + "Cellsynt": Cellsynt }; export default NotificationFormList;