mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
feat: Add support for incident episode notification rule type and update default title generation to use 'Untitled Episode'
This commit is contained in:
@@ -376,6 +376,13 @@ export class Service extends DatabaseService<Model> {
|
||||
return NotificationRuleType.ON_CALL_EXECUTED_ALERT_EPISODE;
|
||||
}
|
||||
|
||||
if (
|
||||
userNotificationEventType ===
|
||||
UserNotificationEventType.IncidentEpisodeCreated
|
||||
) {
|
||||
return NotificationRuleType.ON_CALL_EXECUTED_INCIDENT_EPISODE;
|
||||
}
|
||||
|
||||
// Invalid user notification event type.
|
||||
throw new BadDataException("Invalid user notification event type.");
|
||||
}
|
||||
|
||||
@@ -461,8 +461,9 @@ describe("Template Variable Replacement Logic", () => {
|
||||
|
||||
describe("Default Title Generation", () => {
|
||||
test("should use monitor name when no template provided", () => {
|
||||
const defaultTitle: string = `Alert Episode: ${mockAlert.monitor?.name || mockAlert.title || "Alert Episode"}`;
|
||||
expect(defaultTitle).toBe("Alert Episode: API Server");
|
||||
const defaultTitle: string =
|
||||
mockAlert.monitor?.name || mockAlert.title || "Untitled Episode";
|
||||
expect(defaultTitle).toBe("API Server");
|
||||
});
|
||||
|
||||
test("should use alert title when no monitor", () => {
|
||||
@@ -473,8 +474,11 @@ describe("Template Variable Replacement Logic", () => {
|
||||
alertNoMonitor.title = "High CPU Usage";
|
||||
// monitor is intentionally not set
|
||||
|
||||
const defaultTitle: string = `Alert Episode: ${alertNoMonitor.monitor?.name || alertNoMonitor.title || "Alert Episode"}`;
|
||||
expect(defaultTitle).toBe("Alert Episode: High CPU Usage");
|
||||
const defaultTitle: string =
|
||||
alertNoMonitor.monitor?.name ||
|
||||
alertNoMonitor.title ||
|
||||
"Untitled Episode";
|
||||
expect(defaultTitle).toBe("High CPU Usage");
|
||||
});
|
||||
|
||||
test("should use generic title when no monitor and no alert title", () => {
|
||||
@@ -484,8 +488,9 @@ describe("Template Variable Replacement Logic", () => {
|
||||
alertMinimal.id = alertId;
|
||||
// monitor and title are intentionally not set
|
||||
|
||||
const defaultTitle: string = `Alert Episode: ${alertMinimal.monitor?.name || alertMinimal.title || "Alert Episode"}`;
|
||||
expect(defaultTitle).toBe("Alert Episode: Alert Episode");
|
||||
const defaultTitle: string =
|
||||
alertMinimal.monitor?.name || alertMinimal.title || "Untitled Episode";
|
||||
expect(defaultTitle).toBe("Untitled Episode");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ enum NotificationRuleType {
|
||||
ON_CALL_EXECUTED_INCIDENT = "When incident on-call policy is executed",
|
||||
ON_CALL_EXECUTED_ALERT = "When alert on-call policy is executed",
|
||||
ON_CALL_EXECUTED_ALERT_EPISODE = "When alert episode on-call policy is executed",
|
||||
ON_CALL_EXECUTED_INCIDENT_EPISODE = "When incident episode on-call policy is executed",
|
||||
WHEN_USER_GOES_ON_CALL = "When user goes on call",
|
||||
WHEN_USER_GOES_OFF_CALL = "When user goes off call",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user