feat(wire): add moderation and builtin hooks to post service wiring
Add wire providers for ModerationHooks and BuiltinHooks, injecting them into PostService via dependency injection. Hooks are passed as blank identifiers to trigger their initialization and registration side effects.
This commit is contained in:
@@ -47,8 +47,10 @@ func InitializeApp() (*App, error) {
|
||||
postAIService := wire.ProvidePostAIService(openaiClient)
|
||||
transactionManager := wire.ProvideTransactionManager(db)
|
||||
manager := wire.ProvideHookManager()
|
||||
postService := wire.ProvidePostService(postRepository, systemMessageService, gorseClient, postAIService, cache, transactionManager, manager)
|
||||
commentRepository := repository.NewCommentRepository(db)
|
||||
moderationHooks := wire.ProvideModerationHooks(manager, postAIService, postRepository, commentRepository, config)
|
||||
builtinHooks := wire.ProvideBuiltinHooks(manager)
|
||||
postService := wire.ProvidePostService(postRepository, systemMessageService, gorseClient, postAIService, cache, transactionManager, manager, moderationHooks, builtinHooks)
|
||||
commentService := wire.ProvideCommentService(commentRepository, postRepository, systemMessageService, gorseClient, postAIService, cache, manager)
|
||||
operationLogRepository := repository.NewOperationLogRepository(db)
|
||||
loginLogRepository := repository.NewLoginLogRepository(db)
|
||||
|
||||
@@ -80,6 +80,10 @@ func (h *PostModerationHook) Execute(ctx *HookContext) error {
|
||||
result.Approved = false
|
||||
result.Error = err
|
||||
result.ReviewedBy = "ai"
|
||||
zap.L().Error("AI post moderation failed in strict mode, reject post",
|
||||
zap.String("post_id", data.PostID),
|
||||
zap.Error(err),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -164,6 +168,10 @@ func (h *CommentModerationHook) Execute(ctx *HookContext) error {
|
||||
result.Approved = false
|
||||
result.Error = err
|
||||
result.ReviewedBy = "ai"
|
||||
zap.L().Error("AI comment moderation failed in strict mode, reject comment",
|
||||
zap.String("comment_id", data.CommentID),
|
||||
zap.Error(err),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,8 @@ func ProvidePostService(
|
||||
cacheBackend cache.Cache,
|
||||
txManager repository.TransactionManager,
|
||||
hookManager *hook.Manager,
|
||||
_ *hook.ModerationHooks,
|
||||
_ *hook.BuiltinHooks,
|
||||
) service.PostService {
|
||||
return service.NewPostService(postRepo, systemMessageService, gorseClient, postAIService, cacheBackend, txManager, hookManager)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user