feat(dto):lab4 include attachment_ids in Message response

This commit is contained in:
Голиков Maximillian Антон
2026-10-21 19:14:37 +03:00
parent c912fe437e
commit d3cc2113fe
+6
View File
@@ -14,6 +14,7 @@ type MessageResponse struct {
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"`
AttachmentIDs []string `json:"attachment_ids"`
CreatedAt string `json:"created_at"` CreatedAt string `json:"created_at"`
} }
@@ -23,11 +24,16 @@ 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,
AttachmentIDs: ids,
CreatedAt: m.CreatedAt.UTC().Format(timeFormat), CreatedAt: m.CreatedAt.UTC().Format(timeFormat),
} }
} }