<?php
@ini_set('display_errors','0');
@ini_set('log_errors','1');
error_reporting(E_ALL);
require_once __DIR__ . '/api_common.php';
require_once __DIR__ . '/../auth.php';
require_once __DIR__ . '/../db_bootstrap.php';
require_once __DIR__ . '/../messages_lib.php';

require_login();
$conn = ensure_db(true);
if (function_exists('require_perm')) require_perm('can_manage_messages');

$run = messages_queue_active_run($conn, true);
out([
  'ok' => true,
  'active' => $run ? messages_queue_run_is_active((string)$run['status']) : false,
  'run' => messages_queue_run_public($run),
]);
