Jake Vanderwerf
2026-01-25 b38f03c0e7218762d90fa5092696b127f24f36db
inc/rest/routes/SettingsRoutes.php
@@ -3,7 +3,7 @@
use JVBase\JVB;
use JVBase\rest\RestRouteManager;
use JVBase\managers\CacheManager;
use JVBase\managers\Cache;
use JVBase\meta\MetaManager;
use JVBase\meta\MetaSanitizer;
use WP_REST_Request;
@@ -48,10 +48,9 @@
     */
    public function saveSettings(WP_REST_Request $request):WP_REST_Response
    {
        $this->queue = JVB()->queue();
        $data = $request->get_params();
      error_log('User: '.print_r($data['user'], true));
        error_log('Settings routes data: '.print_r($data, true));
        $user_id = (int)$data['user'];
        if (!$this->userCheck($user_id)) {
@@ -62,9 +61,6 @@
        }
        $operation_id = $data['id'];
        unset($data['id']);
        $fields = JVB()->getFields('user');
        $meta = new MetaSanitizer();
        $add = [];
@@ -83,8 +79,7 @@
                //Sanitize values
                $data[$name] = $meta->sanitize($value, $fields[$name]);
                if ($name === 'notify') {
                    $cache = new CacheManager('usernames');
                    $cache->invalidate($user_id);
                    Cache::for('usernames')->forget($user_id);
                }
            }
        }
@@ -92,13 +87,12 @@
            $data['notification_preferences'] = $add;
        }
        $this->queue->queueOperation(
            $this->type,
        JVB()->queue()->queueOperation(
            'user_settings',
            $user_id,
            $data,
            [
                'count'   => 1,
                'operation_id'      => $operation_id
            ]
        );
@@ -106,7 +100,6 @@
        return new WP_REST_Response([
            'success' =>true,
            'message' => 'Request received and queued',
            'operation_id' => $operation_id,
            'status' => 'queued'
        ]);
    }
@@ -154,7 +147,7 @@
            }
            }
            CacheManager::invalidateGroup($this->cache_name);
            $this->cache->flush();
        }
        return [
            'success'   => true,
@@ -223,7 +216,7 @@
            // Success - commit transaction
            $wpdb->query('COMMIT');
            CacheManager::invalidateGroup($this->cache_name);
            $this->cache->flush();
            return [
                'success' => true,
                'result' => 'Notification preferences updated successfully'