feat(service):lab4 add AttachmentService.Get with member check

This commit is contained in:
Голиков Maximillian Антон
2026-10-21 17:52:07 +03:00
parent 4a71b690c3
commit 21363f5b91
+11
View File
@@ -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 {