From 7a9054bb3f033c98067b3196378311dae54c5fbf Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 20 Jan 2026 01:31:53 +0000
Subject: [PATCH] =OperationQueue refactor to the JVBase/managers/queue namespace
---
inc/rest/RestRouteManager.php | 46 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/inc/rest/RestRouteManager.php b/inc/rest/RestRouteManager.php
index 96ccfb7..f017e9c 100644
--- a/inc/rest/RestRouteManager.php
+++ b/inc/rest/RestRouteManager.php
@@ -1,11 +1,14 @@
<?php
namespace JVBase\rest;
+use DateTime;
+use DateTimeZone;
use JVBase\JVB;
use JVBase\rest\RateLimiter;
use JVBase\managers\OperationQueue;
use JVBase\managers\CacheManager;
use JVBase\managers\NotificationManager;
+use JVBase\utility\Features;
use WP_REST_Request;
use WP_Error;
use Exception;
@@ -36,7 +39,7 @@
protected NotificationManager $notifications;
protected string $cache_name ='';
protected int $cache_ttl = 3600; //1 hour default
-
+ protected array $response_headers = [];
// Error code constants for consistency
const ERROR_MISSING_PARAMS = 'missing_parameters';
@@ -127,6 +130,32 @@
return true;
}
+ /**
+ * Convert MySQL datetime to ISO 8601 timestamp with proper timezone
+ */
+ public function formatTimestamp(?string $mysql_datetime): ?string
+ {
+ if (empty($mysql_datetime)) {
+ return null;
+ }
+
+ try {
+ // Get WordPress timezone - dates are stored in this timezone
+ $wp_timezone = wp_timezone();
+
+ // Parse the datetime in WordPress timezone
+ $date = new DateTime($mysql_datetime, $wp_timezone);
+
+ // Convert to UTC for API consistency
+ $date->setTimezone(new DateTimeZone('UTC'));
+
+ // Return ISO 8601 format
+ return $date->format('c');
+ } catch (Exception $e) {
+ return null;
+ }
+ }
+
protected function checkContent(string $content, bool $bool = false):string|bool
{
$result = JVB_CONTENT[$content]??JVB_TAXONOMY[$content]??JVB_USER[$content]??'';
@@ -540,6 +569,7 @@
protected function error(string $message, string $code, int $status = 400, ?string $field = null): WP_REST_Response
{
$data = [
+ 'success' => false,
'message' => $message,
'code' => $code
];
@@ -555,6 +585,7 @@
*/
protected function success(array $data, int $status = 200): WP_REST_Response
{
+ $data['success'] = true;
return new WP_REST_Response($data, $status);
}
@@ -906,6 +937,19 @@
$lock_key = 'op_lock_' . md5($operation_key);
delete_transient($lock_key);
}
+
+ protected function verifyTurnstile(string $token): bool
+ {
+ if (!Features::hasIntegration('cloudflare') || !JVB()->connect('cloudflare')->isSetUp()) {
+ return true;
+ }
+
+ if (empty($token)) {
+ return false;
+ }
+
+ return JVB()->connect('cloudflare')->verifyTurnstile($token);
+ }
}
//
//Simple example:
--
Gitblit v1.10.0