feat(dto):lab4 include attachment_ids in Message response
This commit is contained in:
@@ -10,11 +10,12 @@ type CreateMessageRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MessageResponse struct {
|
type MessageResponse struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
ChatID string `json:"chat_id"`
|
ChatID string `json:"chat_id"`
|
||||||
SenderID string `json:"sender_id"`
|
SenderID string `json:"sender_id"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
CreatedAt string `json:"created_at"`
|
AttachmentIDs []string `json:"attachment_ids"`
|
||||||
|
CreatedAt string `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessagePageResponse struct {
|
type MessagePageResponse struct {
|
||||||
@@ -23,12 +24,17 @@ type MessagePageResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MessageFromDomain(m *domain.Message) MessageResponse {
|
func MessageFromDomain(m *domain.Message) MessageResponse {
|
||||||
|
ids := m.AttachmentIDs
|
||||||
|
if ids == nil {
|
||||||
|
ids = []string{}
|
||||||
|
}
|
||||||
return MessageResponse{
|
return MessageResponse{
|
||||||
ID: m.ID,
|
ID: m.ID,
|
||||||
ChatID: m.ChatID,
|
ChatID: m.ChatID,
|
||||||
SenderID: m.SenderID,
|
SenderID: m.SenderID,
|
||||||
Text: m.Text,
|
Text: m.Text,
|
||||||
CreatedAt: m.CreatedAt.UTC().Format(timeFormat),
|
AttachmentIDs: ids,
|
||||||
|
CreatedAt: m.CreatedAt.UTC().Format(timeFormat),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user