| | |
| | | '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 |
| | | Route::for('queue/poll') |
| | |
| | | '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 |
| | | Route::for(Route::pattern('queue/{id}')) |
| | | ->get([$this, 'getOperation']) |
| | | ->arg('id', 'string|required') |
| | | ->auth('user') |
| | | ->rateLimit(15); |
| | | ->rateLimit() |
| | | ->register(); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | $params = $request->get_params(); |
| | | $user_id = absint($params['user']); |
| | | $this->cache = Cache::for($user_id.'_queue'); |
| | | $status = sanitize_text_field($params['status']); |
| | | $ids = !empty($params['ids']) |
| | | ? array_map('trim', array_map('sanitize_text_field', explode(',', $params['ids']))) |
| | |
| | | $action = sanitize_text_field($data['action'] ?? ''); |
| | | $user_id = absint($data['user']); |
| | | |
| | | $this->cache = Cache::for($user_id.'_queue'); |
| | | |
| | | // Validate input |
| | | if (empty($ids)) { |
| | | return Response::validationError(['ids' => 'Missing or invalid operation IDs']); |
| | |
| | | public function pollQueue(WP_REST_Request $request): WP_REST_Response |
| | | { |
| | | $userId = $request->get_param('user'); |
| | | $this->cache = Cache::for($userId.'_queue'); |
| | | $since = $request->get_param('since'); |
| | | $ids = $request->get_param('ids'); |
| | | |
| | |
| | | public function getOperationErrors(WP_REST_Request $request): WP_REST_Response |
| | | { |
| | | $user_id = absint($request->get_param('user')); |
| | | $this->cache = Cache::for($user_id.'_queue'); |
| | | $operations = JVB()->queue()->getUserOperations($user_id, [ |
| | | 'state' => 'completed', |
| | | 'outcome' => ['failed', 'failed_permanent', 'partial'], |
| | |
| | | { |
| | | $id = $request->get_param('id'); |
| | | $userId = $request->get_param('user'); |
| | | $this->cache = Cache::for($userId.'_queue'); |
| | | |
| | | $op = JVB()->queue()->get($id); |
| | | |