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.")