<?php

namespace Plugins\Larablog\AiCommentModeration;

use App\Domain\Ai\Jobs\ModerateCommentJob;
use App\Domain\Plugin\Hook;
use App\Models\Comment;
use Illuminate\Support\ServiceProvider;

class PluginServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        //
    }

    public function boot(): void
    {
        Hook::listen('comment.created', function (Comment $comment): void {
            $comment->update(['moderation_status' => Comment::STATUS_PENDING_AI]);
            ModerateCommentJob::dispatch($comment->id);
        });
    }
}
