🔊 Add notifying logs

This commit is contained in:
LittleSheep 2024-11-23 00:07:28 +08:00
parent ae48597f96
commit 6c5324e131

View File

@ -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 { 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( err := authkit.NotifyUserBatch(
gap.Nx, gap.Nx,
pendingUsers, pendingUsers,
pushkit.Notification{ pushkit.Notification{
Topic: "messaging.message", Topic: "messaging.message",
Title: fmt.Sprintf("%s (%s)", event.Sender.Nick, event.Channel.DisplayText()), Title: displayTitle,
Subtitle: displaySubtitle, Subtitle: displaySubtitle,
Body: displayText, Body: displayText,
Metadata: map[string]any{ Metadata: map[string]any{
@ -197,12 +205,18 @@ func NotifyMessageEvent(members []models.ChannelMember, event models.Event) {
displaySubtitle = "Mentioned you" displaySubtitle = "Mentioned you"
} }
log.Debug().
Uint("event_id", event.ID).
Str("title", displayTitle).
Int("count", len(mentionedUsers)).
Msg("Notifying new event...")
err := authkit.NotifyUserBatch( err := authkit.NotifyUserBatch(
gap.Nx, gap.Nx,
mentionedUsers, mentionedUsers,
pushkit.Notification{ pushkit.Notification{
Topic: "messaging.message", Topic: "messaging.message",
Title: fmt.Sprintf("%s (%s)", event.Sender.Nick, event.Channel.DisplayText()), Title: displayTitle,
Subtitle: displaySubtitle, Subtitle: displaySubtitle,
Body: displayText, Body: displayText,
Metadata: map[string]any{ Metadata: map[string]any{