From d4636d5436eb9362fa4b8d42e17319c1dbe3f593 Mon Sep 17 00:00:00 2001 From: Tola Leng Date: Tue, 12 Aug 2025 22:26:51 +0700 Subject: [PATCH] feat: Add error_message placeholder for uptime notifications - Add support for the `${error_message}` placeholder in uptime service notifications --- .../form/PlaceholdersTabContent.tsx | 21 +++++++++++++++++++ .../notification/templateProcessor.ts | 1 + 2 files changed, 22 insertions(+) diff --git a/application/src/components/settings/alerts-templates/form/PlaceholdersTabContent.tsx b/application/src/components/settings/alerts-templates/form/PlaceholdersTabContent.tsx index adc3f22..26bbec1 100644 --- a/application/src/components/settings/alerts-templates/form/PlaceholdersTabContent.tsx +++ b/application/src/components/settings/alerts-templates/form/PlaceholdersTabContent.tsx @@ -221,6 +221,23 @@ export const PlaceholdersTabContent: React.FC = ({ )} /> + + ( + + Error Message Placeholder + + + + + Used for error details when service is down + + + + )} + /> @@ -283,6 +300,10 @@ export const PlaceholdersTabContent: React.FC = ({ ${"{time}"}

Current date and time

+
+ ${"{error_message}"} +

Error details when service is down

+
diff --git a/application/src/services/notification/templateProcessor.ts b/application/src/services/notification/templateProcessor.ts index bca3147..ec44151 100644 --- a/application/src/services/notification/templateProcessor.ts +++ b/application/src/services/notification/templateProcessor.ts @@ -56,6 +56,7 @@ export function processTemplate( .replace(/\${region_name}/g, service.region_name || service.RegionName || 'Default') .replace(/\${agent_id}/g, service.agent_id ? service.agent_id.toString() : (service.AgentID ? service.AgentID.toString() : '1')) .replace(/\${uptime}/g, service.uptime ? `${service.uptime}%` : (service.Uptime ? `${service.Uptime}%` : 'N/A')) + .replace(/\${error_message}/g, service.error_message || service.ErrorMessage || service.error || '') .replace(/\${time}/g, new Date().toLocaleString()); return message;