From cd61796de25d1e9bb66c2e96d4f50c2aac76b632 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 31 Mar 2024 22:49:08 +0800 Subject: [PATCH] :bug: Fix notify --- pkg/services/accounts.go | 2 +- pkg/services/messages.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/services/accounts.go b/pkg/services/accounts.go index 30ab592..7f6980d 100644 --- a/pkg/services/accounts.go +++ b/pkg/services/accounts.go @@ -20,7 +20,7 @@ func NotifyAccount(user models.Account, subject, content string, realtime bool, Subject: subject, Content: content, Links: links, - RecipientId: uint64(user.ID), + RecipientId: uint64(user.ExternalID), IsRealtime: realtime, IsImportant: false, }) diff --git a/pkg/services/messages.go b/pkg/services/messages.go index 6855e9b..5095577 100644 --- a/pkg/services/messages.go +++ b/pkg/services/messages.go @@ -3,6 +3,7 @@ package services import ( "git.solsynth.dev/hydrogen/messaging/pkg/database" "git.solsynth.dev/hydrogen/messaging/pkg/models" + "github.com/rs/zerolog/log" ) func CountMessage(channel models.Channel) int64 { @@ -77,7 +78,11 @@ func NewMessage(message models.Message) (models.Message, error) { ChannelID: message.ChannelID, }).Preload("Account").Find(&members).Error; err == nil { for _, member := range members { - _ = NotifyAccount(member.Account, "New message at "+message.Channel.Name, message.Content, true) + err = NotifyAccount(member.Account, "New message at "+message.Channel.Name, message.Content, true) + if err != nil { + log.Warn().Err(err).Msg("An error occurred when trying notify user.") + } + message, _ = GetMessage(message.Channel, message.ID) PushCommand(member.AccountID, models.UnifiedCommand{ Action: "messages.new",