diff --git a/db/patch9.sql b/db/patch9.sql
new file mode 100644
index 00000000..d4d13aab
--- /dev/null
+++ b/db/patch9.sql
@@ -0,0 +1,7 @@
+-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
+BEGIN TRANSACTION;
+
+ALTER TABLE notification
+ ADD is_default BOOLEAN default 0 NOT NULL;
+
+COMMIT;
diff --git a/server/database.js b/server/database.js
index 77c4da75..832166d2 100644
--- a/server/database.js
+++ b/server/database.js
@@ -7,7 +7,7 @@ class Database {
static templatePath = "./db/kuma.db"
static dataDir;
static path;
- static latestVersion = 8;
+ static latestVersion = 9;
static noReject = true;
static sqliteInstance = null;
diff --git a/server/notification.js b/server/notification.js
index 5d2ffb03..1e1e0ccd 100644
--- a/server/notification.js
+++ b/server/notification.js
@@ -92,8 +92,13 @@ class Notification {
bean.name = notification.name;
bean.user_id = userID;
- bean.config = JSON.stringify(notification)
+ bean.config = JSON.stringify(notification);
+ bean.is_default = notification.isDefault;
await R.store(bean)
+
+ if (notification.applyExisting) {
+ await applyNotificationEveryMonitor(bean.id, userID);
+ }
}
static async delete(notificationID, userID) {
@@ -117,6 +122,26 @@ class Notification {
}
+async function applyNotificationEveryMonitor(notificationID, userID) {
+ let monitors = await R.getAll("SELECT id FROM monitor WHERE user_id = ?", [
+ userID
+ ]);
+
+ for (let i = 0; i < monitors.length; i++) {
+ let checkNotification = await R.findOne("monitor_notification", " monitor_id = ? AND notification_id = ? ", [
+ monitors[i].id,
+ notificationID,
+ ])
+
+ if (! checkNotification) {
+ let relation = R.dispense("monitor_notification");
+ relation.monitor_id = monitors[i].id;
+ relation.notification_id = notificationID;
+ await R.store(relation)
+ }
+ }
+}
+
module.exports = {
Notification,
}
diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue
index 8a05d66e..cd8ee817 100644
--- a/src/components/NotificationDialog.vue
+++ b/src/components/NotificationDialog.vue
@@ -37,7 +37,7 @@
-
- You can get your chat id by sending message to the bot and go to this url to view the chat_id: -
- -- - {{ telegramGetUpdatesURL }} - - - - {{ telegramGetUpdatesURL }} - -
-+ You can get your chat id by sending message to the bot and go to this url to view the chat_id: +
+ ++ + {{ telegramGetUpdatesURL }} + + + + {{ telegramGetUpdatesURL }} + +