Merge branch 'fix/database-down-notification' of https://github.com/SmartDever02/uptime-kuma into fix/database-down-notification
This commit is contained in:
commit
516494fa23
@ -329,7 +329,10 @@ class Notification {
|
||||
});
|
||||
|
||||
this.cacheLastRefresh = Date.now();
|
||||
log.debug("notification", `Refreshed notification cache with ${this.notificationCache.length} notifications (database down opt-in)`);
|
||||
log.debug(
|
||||
"notification",
|
||||
`Refreshed notification cache with ${this.notificationCache.length} notifications (database down opt-in)`
|
||||
);
|
||||
} catch (e) {
|
||||
log.error("notification", `Failed to refresh notification cache: ${e.message}`);
|
||||
// Don't clear the cache if refresh fails, keep using old cache
|
||||
|
||||
@ -129,10 +129,14 @@
|
||||
<label class="form-check-label">{{ $t("Apply on all existing monitors") }}</label>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<br />
|
||||
|
||||
<div class="form-check form-switch">
|
||||
<input v-model="notification.sendDatabaseDown" class="form-check-input" type="checkbox">
|
||||
<input
|
||||
v-model="notification.sendDatabaseDown"
|
||||
class="form-check-input"
|
||||
type="checkbox"
|
||||
/>
|
||||
<label class="form-check-label">{{ $t("Send database down notifications") }}</label>
|
||||
</div>
|
||||
<div class="form-text">
|
||||
@ -422,7 +426,8 @@ export default {
|
||||
this.notification = JSON.parse(n.config);
|
||||
// Load send_database_down from database (not stored in config)
|
||||
if (n.send_database_down !== undefined) {
|
||||
this.notification.sendDatabaseDown = n.send_database_down === 1 || n.send_database_down === true;
|
||||
this.notification.sendDatabaseDown =
|
||||
n.send_database_down === 1 || n.send_database_down === true;
|
||||
} else {
|
||||
this.notification.sendDatabaseDown = false;
|
||||
}
|
||||
|
||||
@ -83,8 +83,7 @@ describe("Database Down Notification", () => {
|
||||
const nonOptInBean = R.dispense("notification");
|
||||
nonOptInBean.name = "Non-Opt-In Notification";
|
||||
nonOptInBean.user_id = 1;
|
||||
nonOptInBean.config = JSON.stringify({ type: "webhook",
|
||||
webhookURL: "https://example.com/webhook2" });
|
||||
nonOptInBean.config = JSON.stringify({ type: "webhook", webhookURL: "https://example.com/webhook2" });
|
||||
nonOptInBean.active = 1;
|
||||
nonOptInBean.is_default = 0;
|
||||
nonOptInBean.send_database_down = 0; // NOT opted-in
|
||||
@ -97,7 +96,7 @@ describe("Database Down Notification", () => {
|
||||
assert.ok(Notification.cacheLastRefresh > 0, "Cache refresh time should be set");
|
||||
|
||||
// Verify test notification (opt-in) is in cache
|
||||
const cached = Notification.notificationCache.find(n => n.id === testNotification.id);
|
||||
const cached = Notification.notificationCache.find((n) => n.id === testNotification.id);
|
||||
assert.ok(cached, "Opt-in notification should be in cache");
|
||||
assert.strictEqual(cached.name, "Test Notification");
|
||||
// Config is stored as raw string, parse to verify
|
||||
@ -105,7 +104,7 @@ describe("Database Down Notification", () => {
|
||||
assert.strictEqual(config.type, "webhook");
|
||||
|
||||
// Verify non-opt-in notification is NOT in cache
|
||||
const nonOptInCached = Notification.notificationCache.find(n => n.id === nonOptInBean.id);
|
||||
const nonOptInCached = Notification.notificationCache.find((n) => n.id === nonOptInBean.id);
|
||||
assert.strictEqual(nonOptInCached, undefined, "Non-opt-in notification should NOT be in cache");
|
||||
} finally {
|
||||
// Clean up
|
||||
|
||||
Loading…
Reference in New Issue
Block a user