🚀 Launch tech preview

This commit is contained in:
LittleSheep 2024-03-31 01:27:41 +08:00
parent 56af8688f6
commit ec1cf74207
2 changed files with 5 additions and 1 deletions

View File

@ -16,6 +16,7 @@ type Channel struct {
Members []ChannelMember `json:"members"` Members []ChannelMember `json:"members"`
Messages []Message `json:"messages"` Messages []Message `json:"messages"`
Type ChannelType `json:"type"` Type ChannelType `json:"type"`
Account Account `json:"account"`
AccountID uint `json:"account_id"` AccountID uint `json:"account_id"`
RealmID uint `json:"realm_id"` RealmID uint `json:"realm_id"`
} }

View File

@ -27,6 +27,7 @@ func ListMessage(channel models.Channel, take int, offset int) ([]models.Message
ChannelID: channel.ID, ChannelID: channel.ID,
}).Limit(take).Offset(offset). }).Limit(take).Offset(offset).
Order("created_at DESC"). Order("created_at DESC").
Preload("Attachments").
Preload("Sender"). Preload("Sender").
Preload("Sender.Account"). Preload("Sender.Account").
Find(&messages).Error; err != nil { Find(&messages).Error; err != nil {
@ -42,7 +43,9 @@ func GetMessage(channel models.Channel, id uint) (models.Message, error) {
Where(models.Message{ Where(models.Message{
BaseModel: models.BaseModel{ID: id}, BaseModel: models.BaseModel{ID: id},
ChannelID: channel.ID, ChannelID: channel.ID,
}).Preload("Sender"). }).
Preload("Attachments").
Preload("Sender").
Preload("Sender.Account"). Preload("Sender.Account").
First(&message).Error; err != nil { First(&message).Error; err != nil {
return message, err return message, err