From 054e91f5f8c51dbd5b821fe78eee295b85fa053e Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 31 Mar 2024 23:15:44 +0800 Subject: [PATCH] :bug: Bug fixes of everything --- pkg/services/messages.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/services/messages.go b/pkg/services/messages.go index 5095577..d71e1ea 100644 --- a/pkg/services/messages.go +++ b/pkg/services/messages.go @@ -30,6 +30,8 @@ func ListMessage(channel models.Channel, take int, offset int) ([]models.Message Order("created_at DESC"). Preload("Attachments"). Preload("ReplyTo"). + Preload("ReplyTo.Sender"). + Preload("ReplyTo.Sender.Account"). Preload("Sender"). Preload("Sender.Account"). Find(&messages).Error; err != nil { @@ -47,6 +49,8 @@ func GetMessage(channel models.Channel, id uint) (models.Message, error) { ChannelID: channel.ID, }). Preload("ReplyTo"). + Preload("ReplyTo.Sender"). + Preload("ReplyTo.Sender.Account"). Preload("Attachments"). Preload("Sender"). Preload("Sender.Account"). @@ -78,6 +82,10 @@ func NewMessage(message models.Message) (models.Message, error) { ChannelID: message.ChannelID, }).Preload("Account").Find(&members).Error; err == nil { for _, member := range members { + if member.ID == message.Sender.ID { + continue + } + 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.")