From 528a615fb2b330c05efc86a41cea678bc5b1dff3 Mon Sep 17 00:00:00 2001 From: CL0Pinette <51855790+CL0Pinette@users.noreply.github.com> Date: Wed, 5 Oct 2022 11:30:49 +0200 Subject: [PATCH] Add free.fr SMS notification provider (#2159) --- server/notification-providers/freemobile.js | 24 +++++++++++++++++++++ server/notification.js | 2 ++ src/components/notifications/FreeMobile.vue | 12 +++++++++++ src/components/notifications/index.js | 2 ++ 4 files changed, 40 insertions(+) create mode 100644 server/notification-providers/freemobile.js create mode 100644 src/components/notifications/FreeMobile.vue diff --git a/server/notification-providers/freemobile.js b/server/notification-providers/freemobile.js new file mode 100644 index 000000000..919150fa0 --- /dev/null +++ b/server/notification-providers/freemobile.js @@ -0,0 +1,24 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class FreeMobile extends NotificationProvider { + + name = "FreeMobile"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + try { + await axios.post(`https://smsapi.free-mobile.fr/sendmsg?msg=${encodeURIComponent(msg.replace("🔴", "⛔️"))}`, { + "user": notification.freemobileUser, + "pass": notification.freemobilePass, + }); + + return okMsg; + + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = FreeMobile; diff --git a/server/notification.js b/server/notification.js index 7a4b4f29f..aed92e5dc 100644 --- a/server/notification.js +++ b/server/notification.js @@ -9,6 +9,7 @@ const ClickSendSMS = require("./notification-providers/clicksendsms"); const DingDing = require("./notification-providers/dingding"); const Discord = require("./notification-providers/discord"); const Feishu = require("./notification-providers/feishu"); +const FreeMobile = require("./notification-providers/freemobile"); const GoogleChat = require("./notification-providers/google-chat"); const Gorush = require("./notification-providers/gorush"); const Gotify = require("./notification-providers/gotify"); @@ -63,6 +64,7 @@ class Notification { new DingDing(), new Discord(), new Feishu(), + new FreeMobile(), new GoogleChat(), new Gorush(), new Gotify(), diff --git a/src/components/notifications/FreeMobile.vue b/src/components/notifications/FreeMobile.vue new file mode 100644 index 000000000..852d9ae2a --- /dev/null +++ b/src/components/notifications/FreeMobile.vue @@ -0,0 +1,12 @@ + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 319a7922e..bca4a510d 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -7,6 +7,7 @@ import ClickSendSMS from "./ClickSendSMS.vue"; import DingDing from "./DingDing.vue"; import Discord from "./Discord.vue"; import Feishu from "./Feishu.vue"; +import FreeMobile from "./FreeMobile.vue"; import GoogleChat from "./GoogleChat.vue"; import Gorush from "./Gorush.vue"; import Gotify from "./Gotify.vue"; @@ -56,6 +57,7 @@ const NotificationFormList = { "DingDing": DingDing, "discord": Discord, "Feishu": Feishu, + "FreeMobile": FreeMobile, "GoogleChat": GoogleChat, "gorush": Gorush, "gotify": Gotify,