feat: allow network admin to control ephemerality setting

Resolves #92
This commit is contained in:
talksik
2026-03-30 13:27:27 -07:00
parent 7f93aa9db3
commit d56541bd13
16 changed files with 323 additions and 60 deletions
+14
View File
@@ -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 (24336 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 {