<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Cron extends CI_Controller {

    public function __construct() {
        parent::__construct();

        // Amankan: hanya CLI atau pakai secret
        if (!$this->input->is_cli_request()) {
            $key = $this->input->get('key');
            if ($key !== 'GANTI_SECRET_CRON_ANDA') {
                show_404();
            }
        }

        $this->load->helper('az_device_helper');
    }

    public function rotate_device_tokens() {
        $count = az_rotate_all_device_tokens(6);
        echo "Rotasi token selesai. Total device: " . $count . "\n";
    }
}