diff --git a/pkg/models/channels.go b/pkg/models/channels.go index 6502617..d557ba3 100644 --- a/pkg/models/channels.go +++ b/pkg/models/channels.go @@ -16,6 +16,7 @@ type Channel struct { Members []ChannelMember `json:"members"` Messages []Message `json:"messages"` Type ChannelType `json:"type"` + Account Account `json:"account"` AccountID uint `json:"account_id"` RealmID uint `json:"realm_id"` } diff --git a/pkg/services/messages.go b/pkg/services/messages.go index 559fd3e..861713f 100644 --- a/pkg/services/messages.go +++ b/pkg/services/messages.go @@ -27,6 +27,7 @@ func ListMessage(channel models.Channel, take int, offset int) ([]models.Message ChannelID: channel.ID, }).Limit(take).Offset(offset). Order("created_at DESC"). + Preload("Attachments"). Preload("Sender"). Preload("Sender.Account"). Find(&messages).Error; err != nil { @@ -42,7 +43,9 @@ func GetMessage(channel models.Channel, id uint) (models.Message, error) { Where(models.Message{ BaseModel: models.BaseModel{ID: id}, ChannelID: channel.ID, - }).Preload("Sender"). + }). + Preload("Attachments"). + Preload("Sender"). Preload("Sender.Account"). First(&message).Error; err != nil { return message, err