From c204185ae86a98994f80010abf35a190c9406739 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 12 Jul 2026 18:08:19 +0000
Subject: [PATCH] =Refactor of Integrations.php. Separated different functionality into traits that classes can use to add that functionality. Hopefully will make maintaining it a little easier. Still have to finish up, as well as refactoring the individual classes to utilize the new system.
---
inc/rest/routes/QueueRoutes.php | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/inc/rest/routes/QueueRoutes.php b/inc/rest/routes/QueueRoutes.php
index c1017be..e7fd1d7 100644
--- a/inc/rest/routes/QueueRoutes.php
+++ b/inc/rest/routes/QueueRoutes.php
@@ -87,7 +87,10 @@
public function getQueue(WP_REST_Request $request): WP_REST_Response
{
$params = $request->get_params();
- $user_id = absint($params['user']);
+ $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'])
@@ -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);
--
Gitblit v1.10.0