Documentation
¶
Overview ¶
Package handlers provides WebSocket command handlers for different domains
Package handlers provides WebSocket command handlers for async operations ¶
Package handlers provides WebSocket command handlers for different domains ¶
Package handlers provides WebSocket command handlers for different domains ¶
Package handlers provides WebSocket command handlers for different domains ¶
Package handlers provides WebSocket command handlers for system/utility commands
Index ¶
- Constants
- func ExecuteGenericCommand(ctx context.Context, handler *streaming.BaseCommandHandler, ...) (*streaming.CommandResponse, error)
- type AccountCommandHandler
- type AsyncCommandHandler
- type BulkService
- type CommandExecutor
- type ImportExportService
- type RelationshipCommandHandler
- type RelationshipsService
- type SimpleStatusExecutor
- func (e *SimpleStatusExecutor) BuildCommand(conn *streaming.ConnectionInfo, payload map[string]interface{}) interface{}
- func (e *SimpleStatusExecutor) Execute(ctx context.Context, serviceCmd interface{}) (interface{}, error)
- func (e *SimpleStatusExecutor) FormatResponse(result interface{}) (map[string]interface{}, error)
- func (e *SimpleStatusExecutor) RequiredFields() []string
- func (e *SimpleStatusExecutor) RequiresAuth() bool
- type StatusCommandHandlerV2
- type SystemCommandHandler
Constants ¶
const ( StatusProcessing = "processing" StatusCompleted = "completed" )
Constants for operation statuses
Variables ¶
This section is empty.
Functions ¶
func ExecuteGenericCommand ¶
func ExecuteGenericCommand( ctx context.Context, handler *streaming.BaseCommandHandler, conn *streaming.ConnectionInfo, cmd *streaming.Command, executor CommandExecutor, errorCode string, ) (*streaming.CommandResponse, error)
ExecuteGenericCommand provides a generic execution flow for commands
Types ¶
type AccountCommandHandler ¶
type AccountCommandHandler struct {
*streaming.BaseCommandHandler
// contains filtered or unexported fields
}
AccountCommandHandler handles WebSocket commands related to accounts/users
func NewAccountCommandHandler ¶
func NewAccountCommandHandler(accountsService *accounts.Service, logger *zap.Logger) *AccountCommandHandler
NewAccountCommandHandler creates a new account command handler
func (*AccountCommandHandler) GetSupportedCommands ¶
func (ach *AccountCommandHandler) GetSupportedCommands() []string
GetSupportedCommands returns the list of commands this handler supports
func (*AccountCommandHandler) HandleCommand ¶
func (ach *AccountCommandHandler) HandleCommand(ctx context.Context, conn *streaming.ConnectionInfo, cmd *streaming.Command) (*streaming.CommandResponse, error)
HandleCommand processes account-related WebSocket commands
type AsyncCommandHandler ¶
type AsyncCommandHandler struct {
*streaming.BaseCommandHandler
// contains filtered or unexported fields
}
AsyncCommandHandler handles WebSocket commands for async operations (bulk ops, import/export)
func NewAsyncCommandHandler ¶
func NewAsyncCommandHandler( bulkService BulkService, importExportService ImportExportService, relationshipsService RelationshipsService, publisher streaming.Publisher, logger *zap.Logger, ) *AsyncCommandHandler
NewAsyncCommandHandler creates a new async command handler
func (*AsyncCommandHandler) GetSupportedCommands ¶
func (ach *AsyncCommandHandler) GetSupportedCommands() []string
GetSupportedCommands returns the list of commands this handler supports
func (*AsyncCommandHandler) HandleCommand ¶
func (ach *AsyncCommandHandler) HandleCommand(ctx context.Context, conn *streaming.ConnectionInfo, cmd *streaming.Command) (*streaming.CommandResponse, error)
HandleCommand processes async-related WebSocket commands
type BulkService ¶
type BulkService interface {
BulkFollow(ctx context.Context, cmd *bulk.FollowCommand) (*bulk.OperationResult, error)
BulkDeleteStatuses(ctx context.Context, cmd *bulk.DeleteStatusesCommand) (*bulk.OperationResult, error)
GetOperation(ctx context.Context, query *bulk.GetOperationQuery) (*bulk.OperationResult, error)
// Bulk Content Management Operations
BulkDelete(ctx context.Context, cmd *bulk.DeleteCommand) (*bulk.OperationResult, error)
BulkArchive(ctx context.Context, cmd *bulk.ArchiveCommand) (*bulk.OperationResult, error)
BulkRestore(ctx context.Context, cmd *bulk.RestoreCommand) (*bulk.OperationResult, error)
BulkExport(ctx context.Context, cmd *bulk.ExportCommand) (*bulk.OperationResult, error)
BulkListMembers(ctx context.Context, cmd *bulk.ListMembersCommand) (*bulk.OperationResult, error)
// Bulk Moderation Operations
BulkUnblock(ctx context.Context, cmd *bulk.UnblockCommand) (*bulk.OperationResult, error)
BulkMute(ctx context.Context, cmd *bulk.MuteCommand) (*bulk.OperationResult, error)
BulkBlock(ctx context.Context, cmd *bulk.BlockCommand) (*bulk.OperationResult, error)
}
BulkService defines the interface for bulk operations
type CommandExecutor ¶
type CommandExecutor interface {
// RequiresAuth returns true if the command requires authentication
RequiresAuth() bool
// RequiredFields returns the list of required fields for validation
RequiredFields() []string
// BuildCommand builds the service command from the WebSocket command payload
BuildCommand(conn *streaming.ConnectionInfo, payload map[string]interface{}) interface{}
// Execute executes the service command and returns the result
Execute(ctx context.Context, serviceCmd interface{}) (interface{}, error)
// FormatResponse formats the service result for WebSocket response
FormatResponse(result interface{}) (map[string]interface{}, error)
}
CommandExecutor defines the interface for executing service commands
type ImportExportService ¶
type ImportExportService interface {
CreateExport(ctx context.Context, cmd *importexport.CreateExportCommand) (*importexport.ExportResult, error)
GetExport(ctx context.Context, query *importexport.GetExportQuery) (*importexport.ExportResult, error)
ListExports(ctx context.Context, query *importexport.ListExportsQuery) (*importexport.ExportListResult, error)
CancelExport(ctx context.Context, cmd *importexport.CancelExportCommand) (*importexport.ExportResult, error)
CreateImport(ctx context.Context, cmd *importexport.CreateImportCommand) (*importexport.ImportResult, error)
GetImport(ctx context.Context, query *importexport.GetImportQuery) (*importexport.ImportResult, error)
ListImports(ctx context.Context, query *importexport.ListImportsQuery) (*importexport.ImportListResult, error)
}
ImportExportService defines the interface for import/export operations
type RelationshipCommandHandler ¶
type RelationshipCommandHandler struct {
*streaming.BaseCommandHandler
// contains filtered or unexported fields
}
RelationshipCommandHandler handles WebSocket commands related to relationships
func NewRelationshipCommandHandler ¶
func NewRelationshipCommandHandler(relationshipsService *relationships.Service, accountsService *accounts.Service, logger *zap.Logger) *RelationshipCommandHandler
NewRelationshipCommandHandler creates a new relationship command handler
func (*RelationshipCommandHandler) GetSupportedCommands ¶
func (rch *RelationshipCommandHandler) GetSupportedCommands() []string
GetSupportedCommands returns the list of commands this handler supports
func (*RelationshipCommandHandler) HandleCommand ¶
func (rch *RelationshipCommandHandler) HandleCommand(ctx context.Context, conn *streaming.ConnectionInfo, cmd *streaming.Command) (*streaming.CommandResponse, error)
HandleCommand processes relationship-related WebSocket commands
type RelationshipsService ¶
type RelationshipsService interface {
Unfollow(ctx context.Context, cmd *relationships.UnfollowCommand) (*relationships.RelationshipResult, error)
Unmute(ctx context.Context, cmd *relationships.UnmuteCommand) (*relationships.RelationshipResult, error)
}
RelationshipsService defines the interface for relationship operations needed by async handlers.
type SimpleStatusExecutor ¶
type SimpleStatusExecutor struct {
// contains filtered or unexported fields
}
SimpleStatusExecutor handles simple status operations that follow a common pattern
func NewSimpleStatusExecutor ¶
func NewSimpleStatusExecutor( requiresAuth bool, requiredFields []string, commandBuilder func(*streaming.ConnectionInfo, map[string]interface{}) interface{}, executor func(context.Context, interface{}) (interface{}, error), responseKey string, ) *SimpleStatusExecutor
NewSimpleStatusExecutor creates a new simple status executor
func (*SimpleStatusExecutor) BuildCommand ¶
func (e *SimpleStatusExecutor) BuildCommand(conn *streaming.ConnectionInfo, payload map[string]interface{}) interface{}
BuildCommand builds the service command from the WebSocket command payload
func (*SimpleStatusExecutor) Execute ¶
func (e *SimpleStatusExecutor) Execute(ctx context.Context, serviceCmd interface{}) (interface{}, error)
Execute executes the service command and returns the result
func (*SimpleStatusExecutor) FormatResponse ¶
func (e *SimpleStatusExecutor) FormatResponse(result interface{}) (map[string]interface{}, error)
FormatResponse formats the service result for WebSocket response
func (*SimpleStatusExecutor) RequiredFields ¶
func (e *SimpleStatusExecutor) RequiredFields() []string
RequiredFields returns the list of required fields for validation
func (*SimpleStatusExecutor) RequiresAuth ¶
func (e *SimpleStatusExecutor) RequiresAuth() bool
RequiresAuth returns whether this command requires authentication
type StatusCommandHandlerV2 ¶
type StatusCommandHandlerV2 struct {
*streaming.BaseCommandHandler
// contains filtered or unexported fields
}
StatusCommandHandlerV2 handles WebSocket commands related to statuses/notes with reduced duplication
func NewStatusCommandHandlerV2 ¶
func NewStatusCommandHandlerV2(notesService *notes.Service, logger *zap.Logger) *StatusCommandHandlerV2
NewStatusCommandHandlerV2 creates a new status command handler with reduced duplication
func (*StatusCommandHandlerV2) GetSupportedCommands ¶
func (sch *StatusCommandHandlerV2) GetSupportedCommands() []string
GetSupportedCommands returns the list of commands this handler supports
func (*StatusCommandHandlerV2) HandleCommand ¶
func (sch *StatusCommandHandlerV2) HandleCommand(ctx context.Context, conn *streaming.ConnectionInfo, cmd *streaming.Command) (*streaming.CommandResponse, error)
HandleCommand processes status-related WebSocket commands with reduced duplication
type SystemCommandHandler ¶
type SystemCommandHandler struct {
*streaming.BaseCommandHandler
// contains filtered or unexported fields
}
SystemCommandHandler handles WebSocket commands for system-level operations
func NewSystemCommandHandler ¶
func NewSystemCommandHandler( notesService *notes.Service, listsService *lists.Service, mediaService mediaUploader, notificationsService *notifications.Service, logger *zap.Logger, ) *SystemCommandHandler
NewSystemCommandHandler creates a new system command handler
func (*SystemCommandHandler) GetSupportedCommands ¶
func (sch *SystemCommandHandler) GetSupportedCommands() []string
GetSupportedCommands returns the list of commands this handler supports
func (*SystemCommandHandler) HandleCommand ¶
func (sch *SystemCommandHandler) HandleCommand(ctx context.Context, conn *streaming.ConnectionInfo, cmd *streaming.Command) (*streaming.CommandResponse, error)
HandleCommand processes system-related WebSocket commands