This commit is contained in:
Pegasus 2026-01-11 11:28:15 +00:00 committed by GitHub
commit f15fb8163a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 3 deletions

View File

@ -1374,7 +1374,7 @@ class Monitor extends BeanModel {
// UP -> UP = not important
// PENDING -> PENDING = not important
// * PENDING -> DOWN = important
// PENDING -> UP = not important
// * PENDING -> UP = not important
// DOWN -> PENDING = this case not exists
// DOWN -> DOWN = not important
// * DOWN -> UP = important

View File

@ -52,6 +52,10 @@ router.all("/api/push/:pushToken", async (request, response) => {
let statusString = request.query.status || "up";
const statusFromParam = statusString === "up" ? UP : DOWN;
// Check if status=down was explicitly provided (not defaulting to "up")
// When explicitly pushing down, bypass retry logic and go directly to DOWN
const isExplicitDown = request.query.status === "down";
let monitor = await R.findOne("monitor", " push_token = ? AND active = 1 ", [pushToken]);
if (!monitor) {
@ -78,7 +82,14 @@ router.all("/api/push/:pushToken", async (request, response) => {
msg = "Monitor under maintenance";
bean.status = MAINTENANCE;
} else {
determineStatus(statusFromParam, previousHeartbeat, monitor.maxretries, monitor.isUpsideDown(), bean);
determineStatus(
statusFromParam,
previousHeartbeat,
monitor.maxretries,
monitor.isUpsideDown(),
bean,
isExplicitDown
);
}
// Calculate uptime
@ -584,13 +595,21 @@ router.get("/api/badge/:id/response", cache("5 minutes"), async (request, respon
* @param {number} maxretries - The maximum number of retries allowed.
* @param {boolean} isUpsideDown - Indicates if the monitor is upside down.
* @param {object} bean - The new heartbeat object.
* @param {boolean} isExplicitDown - If status=down was explicitly pushed, bypass retries.
* @returns {void}
*/
function determineStatus(status, previousHeartbeat, maxretries, isUpsideDown, bean) {
function determineStatus(status, previousHeartbeat, maxretries, isUpsideDown, bean, isExplicitDown) {
if (isUpsideDown) {
status = flipStatus(status);
}
// If status=down was explicitly pushed, bypass retry logic and go directly to DOWN
if (isExplicitDown && status === DOWN) {
bean.retries = 0;
bean.status = DOWN;
return;
}
if (previousHeartbeat) {
if (previousHeartbeat.status === UP && status === DOWN) {
// Going Down