From d3cc2113fe73d62e574c9d9c262c76f13d976736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Wed, 21 Oct 2026 19:14:37 +0300 Subject: [PATCH] feat(dto):lab4 include attachment_ids in Message response --- backend/internal/httpapi/dto/message.go | 26 +++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/backend/internal/httpapi/dto/message.go b/backend/internal/httpapi/dto/message.go index 8cb70b8..0e55e84 100644 --- a/backend/internal/httpapi/dto/message.go +++ b/backend/internal/httpapi/dto/message.go @@ -10,11 +10,12 @@ type CreateMessageRequest struct { } type MessageResponse struct { - ID string `json:"id"` - ChatID string `json:"chat_id"` - SenderID string `json:"sender_id"` - Text string `json:"text"` - CreatedAt string `json:"created_at"` + ID string `json:"id"` + ChatID string `json:"chat_id"` + SenderID string `json:"sender_id"` + Text string `json:"text"` + AttachmentIDs []string `json:"attachment_ids"` + CreatedAt string `json:"created_at"` } type MessagePageResponse struct { @@ -23,12 +24,17 @@ type MessagePageResponse struct { } func MessageFromDomain(m *domain.Message) MessageResponse { + ids := m.AttachmentIDs + if ids == nil { + ids = []string{} + } return MessageResponse{ - ID: m.ID, - ChatID: m.ChatID, - SenderID: m.SenderID, - Text: m.Text, - CreatedAt: m.CreatedAt.UTC().Format(timeFormat), + ID: m.ID, + ChatID: m.ChatID, + SenderID: m.SenderID, + Text: m.Text, + AttachmentIDs: ids, + CreatedAt: m.CreatedAt.UTC().Format(timeFormat), } }