forked from mtusi2026/mtusi2026lab2
реализован уровень 3
This commit is contained in:
@@ -11,12 +11,6 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotFound = fmt.Errorf("not found")
|
||||
ErrConflict = fmt.Errorf("conflict")
|
||||
ErrInvalidCursor = fmt.Errorf("invalid cursor")
|
||||
)
|
||||
|
||||
type MemoryStore struct {
|
||||
mu sync.RWMutex
|
||||
|
||||
@@ -81,7 +75,11 @@ func (s *MemoryStore) CreateChat(title string, memberIDs []string) (domain.Chat,
|
||||
//все участники рил существуют
|
||||
for _, memberID := range memberIDs {
|
||||
if _, exists := s.usersByID[memberID]; !exists {
|
||||
return domain.Chat{}, fmt.Errorf("member not found: %s", memberID)
|
||||
return domain.Chat{}, fmt.Errorf(
|
||||
"%w: member %s",
|
||||
ErrNotFound,
|
||||
memberID,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,9 +284,13 @@ func (s *MemoryStore) GetMessages(
|
||||
if cursorStr != "" {
|
||||
decodedCursor, err := domain.DecodeCursor(cursorStr, chatID)
|
||||
if err != nil {
|
||||
return domain.MessagePage{},
|
||||
fmt.Errorf("invalid cursor: %w", err)
|
||||
return domain.MessagePage{}, fmt.Errorf(
|
||||
"%w: %v",
|
||||
ErrInvalidCursor,
|
||||
err,
|
||||
)
|
||||
}
|
||||
|
||||
cursorData = decodedCursor
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user