🐛 Bug fixes of everything

This commit is contained in:
LittleSheep 2024-03-31 23:15:44 +08:00
parent cd61796de2
commit 054e91f5f8

View File

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