Skip to content

Commit a9f701e

Browse files
committed
fix: Handling for domain expiration alert
1 parent f579f8d commit a9f701e

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

main.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -281,20 +281,23 @@ func convertToGoogleChatCard(notification UptimeKumaNotification) GoogleChatMess
281281
if messageToCheck == "" {
282282
messageToCheck = cleanHeartbeatMsg
283283
}
284-
isCertificateMessage := strings.Contains(strings.ToLower(messageToCheck), "certificate") &&
285-
(strings.Contains(strings.ToLower(messageToCheck), "expire") ||
286-
strings.Contains(strings.ToLower(messageToCheck), "expiration"))
284+
lower := strings.ToLower(messageToCheck)
285+
isExpiryMessage := (strings.Contains(lower, "certificate") || strings.Contains(lower, "domain")) &&
286+
(strings.Contains(lower, "expire") || strings.Contains(lower, "expiration"))
287287

288288
// First line with status or actual message for certificate expiration
289-
if isCertificateMessage && messageToCheck != "" {
290-
// Remove "Down -" or "DOWN -" prefix from certificate message
291-
cleanedCertMsg := strings.TrimSpace(messageToCheck)
292-
cleanedCertMsg = strings.TrimPrefix(cleanedCertMsg, "Down -")
293-
cleanedCertMsg = strings.TrimPrefix(cleanedCertMsg, "DOWN -")
294-
cleanedCertMsg = strings.TrimPrefix(cleanedCertMsg, "down -")
295-
cleanedCertMsg = strings.TrimSpace(cleanedCertMsg)
296-
// Use the cleaned certificate message as the first line (and only line)
297-
previewLines = append(previewLines, cleanedCertMsg)
289+
if isExpiryMessage && messageToCheck != "" {
290+
// Remove status prefix ("Down -", "UP -", etc.) from expiry message
291+
cleanedMsg := strings.TrimSpace(messageToCheck)
292+
cleanedMsg = strings.TrimPrefix(cleanedMsg, "Down -")
293+
cleanedMsg = strings.TrimPrefix(cleanedMsg, "DOWN -")
294+
cleanedMsg = strings.TrimPrefix(cleanedMsg, "down -")
295+
cleanedMsg = strings.TrimPrefix(cleanedMsg, "Up -")
296+
cleanedMsg = strings.TrimPrefix(cleanedMsg, "UP -")
297+
cleanedMsg = strings.TrimPrefix(cleanedMsg, "up -")
298+
cleanedMsg = strings.TrimSpace(cleanedMsg)
299+
// Use the cleaned expiry message as the first line (and only line)
300+
previewLines = append(previewLines, cleanedMsg)
298301
} else {
299302
// Use generic status message
300303
if isUp {

0 commit comments

Comments
 (0)