Jake Vanderwerf
2026-07-05 fff721dd185f5b97f7ae7a6e64189e55887ff590
inc/rest/routes/QueueRoutes.php
@@ -41,14 +41,14 @@
            'limit' => 'integer|default:50|min:1|max:100',
         ])
         ->auth('user')
         ->rateLimit(30)
         ->rateLimit()
         ->post([$this, 'handleAction'])
         ->args([
            'ids' => 'array|required',
            'action' => 'string|required|enum:dismiss,retry,cancel',
         ])
         ->auth('user')
         ->rateLimit(30)
         ->rateLimit()
         ->register();
      // Poll endpoint
@@ -59,14 +59,14 @@
            'ids' => 'string',
         ])
         ->auth('user')
         ->rateLimit(15)
         ->rateLimit()
         ->register();
      // Errors endpoint
      Route::for('queue/errors')
         ->get([$this, 'getOperationErrors'])
         ->auth('user')
         ->rateLimit(15)
         ->rateLimit()
         ->register();
      // Single operation with dynamic ID
@@ -74,7 +74,7 @@
         ->get([$this, 'getOperation'])
         ->arg('id', 'string|required')
         ->auth('user')
         ->rateLimit(15)
         ->rateLimit()
         ->register();
   }
@@ -87,8 +87,11 @@
   public function getQueue(WP_REST_Request $request): WP_REST_Response
   {
      $params = $request->get_params();
      $user_id = absint($params['user']);
      $this->cache = Cache::for($user_id.'_queue');
      $user_id = get_current_user_id();
      if (!$user_id) {
         return $this->unauthorized();
      }
      $this->cache = Cache::for('queue')->user();
      $status = sanitize_text_field($params['status']);
      $ids = !empty($params['ids'])
         ? array_map('trim', array_map('sanitize_text_field', explode(',', $params['ids'])))
@@ -148,7 +151,10 @@
         : array_map('trim', array_map('sanitize_text_field', explode(',', $data['ids'])));
      $action = sanitize_text_field($data['action'] ?? '');
      $user_id = absint($data['user']);
      $user_id = get_current_user_id();
      if (!$user_id) {
         return $this->unauthorized();
      }
      $this->cache = Cache::for($user_id.'_queue');
@@ -182,7 +188,10 @@
   public function pollQueue(WP_REST_Request $request): WP_REST_Response
   {
      $userId = $request->get_param('user');
      $userId = get_current_user_id();
      if (!$userId) {
         return $this->unauthorized();
      }
      $this->cache = Cache::for($userId.'_queue');
      $since = $request->get_param('since');
      $ids = $request->get_param('ids');
@@ -221,7 +230,10 @@
   public function getOperationErrors(WP_REST_Request $request): WP_REST_Response
   {
      $user_id = absint($request->get_param('user'));
      $user_id = get_current_user_id();
      if (!$user_id) {
         return $this->unauthorized();
      }
      $this->cache = Cache::for($user_id.'_queue');
      $operations = JVB()->queue()->getUserOperations($user_id, [
         'state' => 'completed',
@@ -247,7 +259,10 @@
   public function getOperation(WP_REST_Request $request): WP_REST_Response
   {
      $id = $request->get_param('id');
      $userId = $request->get_param('user');
      $userId = get_current_user_id();
      if (!$userId) {
         return $this->unauthorized();
      }
      $this->cache = Cache::for($userId.'_queue');
      $op = JVB()->queue()->get($id);