From 6c5324e131b38f354ab7fbeaa50bd11313ecac48 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 23 Nov 2024 00:07:28 +0800 Subject: [PATCH] :loud_sound: Add notifying logs --- pkg/internal/services/events.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/internal/services/events.go b/pkg/internal/services/events.go index 09b0c69..8dfeeb1 100644 --- a/pkg/internal/services/events.go +++ b/pkg/internal/services/events.go @@ -166,13 +166,21 @@ func NotifyMessageEvent(members []models.ChannelMember, event models.Event) { } } + displayTitle := fmt.Sprintf("%s (%s)", event.Sender.Nick, event.Channel.DisplayText()) + if len(pendingUsers) > 0 { + log.Debug(). + Uint("event_id", event.ID). + Str("title", displayTitle). + Int("count", len(pendingUsers)). + Msg("Notifying new event...") + err := authkit.NotifyUserBatch( gap.Nx, pendingUsers, pushkit.Notification{ Topic: "messaging.message", - Title: fmt.Sprintf("%s (%s)", event.Sender.Nick, event.Channel.DisplayText()), + Title: displayTitle, Subtitle: displaySubtitle, Body: displayText, Metadata: map[string]any{ @@ -197,12 +205,18 @@ func NotifyMessageEvent(members []models.ChannelMember, event models.Event) { displaySubtitle = "Mentioned you" } + log.Debug(). + Uint("event_id", event.ID). + Str("title", displayTitle). + Int("count", len(mentionedUsers)). + Msg("Notifying new event...") + err := authkit.NotifyUserBatch( gap.Nx, mentionedUsers, pushkit.Notification{ Topic: "messaging.message", - Title: fmt.Sprintf("%s (%s)", event.Sender.Nick, event.Channel.DisplayText()), + Title: displayTitle, Subtitle: displaySubtitle, Body: displayText, Metadata: map[string]any{