This commit is contained in:
Vladislav Kunetskiy
2026-10-01 12:59:06 +03:00
parent 65003b6119
commit 51b236a69f
86 changed files with 33332 additions and 16 deletions
+38
View File
@@ -0,0 +1,38 @@
package domain
import (
"fmt"
"slices"
"time"
"github.com/google/uuid"
)
type Chat struct {
ID uuid.UUID
Title string
MemberIDs []uuid.UUID
CreatedAt time.Time
}
func (c Chat) HasMember(userID uuid.UUID) bool {
return slices.Contains(c.MemberIDs, userID)
}
type ChatDraft struct {
Title string
MemberIDs []uuid.UUID
CallerID uuid.UUID
}
func (d ChatDraft) Validate() error {
if err := validateNotBlank("title", d.Title); err != nil {
return err
}
if !slices.Contains(d.MemberIDs, d.CallerID) {
return fmt.Errorf("member_ids must contain the caller: %w", ErrValidation)
}
return nil
}