<?php
namespace EasyChat\Library\Messenger;

use EasyChat\Library\Queue\QueueManager;






final class SmsInboundFilterRefreshScheduler {
    public const JOB_TYPE = 'sms_inbound_filter_refresh';
    public const DEDUPE_KEY = 'sms_inbound_filter_refresh:v1';

    private $registry;

    public function __construct($registry) {
        $this->registry = $registry;
    }

    public function enqueue(): array {
        try {
            $job_id = (new QueueManager($this->registry))->pushUnique(
                self::JOB_TYPE,
                [],
                self::DEDUPE_KEY,
                0,
                90
            );
            return [
                'queued' => $job_id > 0,
                'job_id' => $job_id,
            ];
        } catch (\Throwable $ignored) {
             
             
            return [
                'queued' => false,
                'job_id' => 0,
                'error' => 'sms_inbound_filter_refresh_enqueue_failed',
            ];
        }
    }
}
