mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
- ModerationService: ban/unban with validation and audit logging - VoiceService: join (with capacity check), leave, mute, deafen, camera (with video limit), screenshare (with permission check) - MemStore: in-memory Store implementation for service unit tests - Permission tests: cache hit/miss, invalidation, TTL behavior - Add Moderation and Voice to Services struct https://claude.ai/code/session_01CBFF3r84ywkJRWwuqw8zD8
43 lines
1.4 KiB
Go
43 lines
1.4 KiB
Go
// Package service provides the domain service layer for OwnCord.
|
|
// Services encapsulate business logic (validation, permission checks, DB operations)
|
|
// that was previously scattered across REST and WebSocket handlers.
|
|
// Both REST and WS handlers become thin adapters that call service methods.
|
|
package service
|
|
|
|
import (
|
|
"github.com/owncord/server/auth"
|
|
"github.com/owncord/server/permissions"
|
|
"github.com/owncord/server/store"
|
|
)
|
|
|
|
// Services bundles all domain services for dependency injection.
|
|
// Handlers receive this struct instead of raw *db.DB references.
|
|
type Services struct {
|
|
Messages *MessageService
|
|
Channels *ChannelService
|
|
Permissions *PermissionService
|
|
Users *UserService
|
|
DMs *DMService
|
|
Invites *InviteService
|
|
Blocks *BlockService
|
|
Moderation *ModerationService
|
|
Voice *VoiceService
|
|
}
|
|
|
|
// New creates all domain services wired together.
|
|
func New(st store.Store, limiter *auth.RateLimiter) *Services {
|
|
permChecker := permissions.NewChecker(st)
|
|
permSvc := NewPermissionService(st, permChecker)
|
|
return &Services{
|
|
Messages: NewMessageService(st, permSvc, limiter),
|
|
Channels: NewChannelService(st, permSvc),
|
|
Permissions: permSvc,
|
|
Users: NewUserService(st),
|
|
DMs: NewDMService(st),
|
|
Invites: NewInviteService(st),
|
|
Blocks: NewBlockService(st),
|
|
Moderation: NewModerationService(st),
|
|
Voice: NewVoiceService(st, permSvc),
|
|
}
|
|
}
|