From 3d002b3ce95d51ead40b71c8c31cbe0bb3522e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bla=C5=BEej?= Date: Sat, 25 Dec 2021 20:25:21 +0100 Subject: [PATCH 1/2] add status boolean parameter to push monitor --- server/routers/api-router.js | 5 +++-- src/pages/EditMonitor.vue | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/routers/api-router.js b/server/routers/api-router.js index 1920cef71..1b3138282 100644 --- a/server/routers/api-router.js +++ b/server/routers/api-router.js @@ -5,7 +5,7 @@ const server = require("../server"); const apicache = require("../modules/apicache"); const Monitor = require("../model/monitor"); const dayjs = require("dayjs"); -const { UP, flipStatus, debug } = require("../../src/util"); +const { UP, DOWN, flipStatus, debug } = require("../../src/util"); let router = express.Router(); let cache = apicache.middleware; @@ -22,6 +22,8 @@ router.get("/api/push/:pushToken", async (request, response) => { let pushToken = request.params.pushToken; let msg = request.query.msg || "OK"; let ping = request.query.ping || null; + let status = request.query.status || "true"; + status = status === "true" ? UP : DOWN; let monitor = await R.findOne("monitor", " push_token = ? AND active = 1 ", [ pushToken @@ -33,7 +35,6 @@ router.get("/api/push/:pushToken", async (request, response) => { const previousHeartbeat = await Monitor.getPreviousHeartbeat(monitor.id); - let status = UP; if (monitor.isUpsideDown()) { status = flipStatus(status); } diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 4b6a920c8..7d31c7da3 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -53,7 +53,7 @@
{{ $t("needPushEvery", [monitor.interval]) }}
- {{ $t("pushOptionalParams", ["msg, ping"]) }} + {{ $t("pushOptionalParams", ["status, msg, ping"]) }}
@@ -349,7 +349,7 @@ export default { }, pushURL() { - return this.$root.baseURL + "/api/push/" + this.monitor.pushToken + "?msg=OK&ping="; + return this.$root.baseURL + "/api/push/" + this.monitor.pushToken + "?status=true&msg=OK&ping="; }, bodyPlaceholder() { From 60538036c60d43799a52c02b37c2da30df405bff Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Thu, 28 Apr 2022 23:44:08 +0800 Subject: [PATCH 2/2] [#1108] Change "true" to "up" --- server/routers/api-router.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/routers/api-router.js b/server/routers/api-router.js index 73c728b80..8f5f6d6f2 100644 --- a/server/routers/api-router.js +++ b/server/routers/api-router.js @@ -34,8 +34,8 @@ router.get("/api/push/:pushToken", async (request, response) => { let pushToken = request.params.pushToken; let msg = request.query.msg || "OK"; let ping = request.query.ping || null; - let status = request.query.status || "true"; - status = status === "true" ? UP : DOWN; + let statusString = request.query.status || "up"; + let status = (statusString === "up") ? UP : DOWN; let monitor = await R.findOne("monitor", " push_token = ? AND active = 1 ", [ pushToken