From 7f0fc524daf0054708517ef7acb30e1e7a296107 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 1 Aug 2024 19:45:06 +0800 Subject: [PATCH] :lipstick: Improve notifcation with attachment --- pkg/internal/services/events.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/internal/services/events.go b/pkg/internal/services/events.go index 71b596d..736e79c 100644 --- a/pkg/internal/services/events.go +++ b/pkg/internal/services/events.go @@ -147,9 +147,17 @@ func NotifyMessageEvent(members []models.ChannelMember, event models.Event) { } if len(displayText) == 0 { - displayText = fmt.Sprintf("%d file(s)", len(body.Attachments)) + if len(displayText) == 1 { + displayText = fmt.Sprintf("%d file", len(body.Attachments)) + } else { + displayText = fmt.Sprintf("%d files", len(body.Attachments)) + } } else if len(body.Attachments) > 0 { - displayText += fmt.Sprintf("with %d file(s)", len(body.Attachments)) + if len(displayText) == 1 { + displayText += fmt.Sprintf(" (%d file)", len(body.Attachments)) + } else { + displayText += fmt.Sprintf(" (%d files)", len(body.Attachments)) + } } if len(pendingUsers) > 0 {