diff --git a/backend/internal/service/attachment.go b/backend/internal/service/attachment.go index 9f7ebba..762c59b 100644 --- a/backend/internal/service/attachment.go +++ b/backend/internal/service/attachment.go @@ -32,6 +32,17 @@ func NewAttachmentService( } } +func (s *AttachmentService) Get(ctx context.Context, userID, attachmentID string) (*domain.Attachment, error) { + a, err := s.attachments.GetByID(ctx, attachmentID) + if err != nil { + return nil, err + } + if err := s.ensureMember(ctx, userID, a.ChatID); err != nil { + return nil, err + } + return a, nil +} + func (s *AttachmentService) ensureMember(ctx context.Context, userID, chatID string) error { c, err := s.chats.GetByID(ctx, chatID) if err != nil {