@@ -13,6 +13,7 @@ import (
|
||||
var ErrNotFound = errors.New("network not found")
|
||||
var ErrInvalidName = errors.New("name cannot be empty")
|
||||
var ErrCapacityExceeded = errors.New("active stream capacity exceeded")
|
||||
var ErrInvalidRetentionHours = errors.New("message retention hours must be between 24 and 336")
|
||||
|
||||
type Service interface {
|
||||
// Create creates a network and adds adminHumanId as the first member. Returns ErrInvalidName if name is empty.
|
||||
@@ -25,6 +26,8 @@ type Service interface {
|
||||
RemoveMember(ctx context.Context, networkID, humanId string) error
|
||||
ListForHuman(ctx context.Context, humanId string) ([]*Network, error)
|
||||
IsMember(ctx context.Context, networkID, humanId string) (bool, error)
|
||||
// SetMessageRetentionHours sets how long messages remain visible (24–336 hours).
|
||||
SetMessageRetentionHours(ctx context.Context, id string, hours int) error
|
||||
|
||||
// Invitations (email-based, for users who haven't registered yet)
|
||||
InviteByEmail(ctx context.Context, networkID string, emails []string) error
|
||||
@@ -115,6 +118,17 @@ func (s *serviceImpl) IsMember(ctx context.Context, networkID, humanId string) (
|
||||
return s.repo.isMember(ctx, networkID, humanId)
|
||||
}
|
||||
|
||||
func (s *serviceImpl) SetMessageRetentionHours(ctx context.Context, id string, hours int) error {
|
||||
if hours < 24 || hours > 336 {
|
||||
return ErrInvalidRetentionHours
|
||||
}
|
||||
err := s.repo.updateMessageRetentionHours(ctx, id, hours)
|
||||
if errors.Is(err, errNotFound) {
|
||||
return ErrNotFound
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// Invitation methods
|
||||
|
||||
func (s *serviceImpl) InviteByEmail(ctx context.Context, networkID string, emails []string) error {
|
||||
|
||||
Reference in New Issue
Block a user