<?php

namespace App\Console\Commands;

use App\Jobs\DeleteExpiredWireChatMessagesJob;
use Illuminate\Console\Command;

class WireChatDeleteExpiredMessages extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'wirechat:delete-expired';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Delete expired disappearing messages from WireChat conversations';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        if (!timebank_config('wirechat.disappearing_messages.enabled', true)) {
            $this->info('Disappearing messages feature is disabled');
            return Command::SUCCESS;
        }

        $this->info('Dispatching job to delete expired disappearing messages...');

        // Dispatch to 'low' queue
        DeleteExpiredWireChatMessagesJob::dispatch();

        $this->info('Job dispatched to low queue!');

        return Command::SUCCESS;
    }
}
