From fff721dd185f5b97f7ae7a6e64189e55887ff590 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 05 Jul 2026 18:36:57 +0000
Subject: [PATCH] =Cleaning up the Square integration (still a bit more to do yet). Also majorly overhauled /rest/ files to ignore a rest request 'user' paramater, and rely on get_current_user_id() instead.

---
 inc/rest/routes/FeedRoutes.php |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/inc/rest/routes/FeedRoutes.php b/inc/rest/routes/FeedRoutes.php
index 6abb894..b0fcbe2 100644
--- a/inc/rest/routes/FeedRoutes.php
+++ b/inc/rest/routes/FeedRoutes.php
@@ -70,7 +70,6 @@
 				'context' => 'string',
 				'contextId' => 'string',
 				'favourites' => 'boolean',
-				'user' => 'integer',
 				'highlight' => 'string',
 			])
 			->auth('public')
@@ -89,7 +88,6 @@
 				'context' => 'string',
 				'contextId' => 'string',
 				'favourites' => 'boolean',
-				'user' => 'integer',
 				'highlight' => 'string',
 			])
 			->auth('public')
@@ -501,7 +499,7 @@
 					: explode(',', $args['post_type']);
 
 				// Check if filtering global feed content
-				if (in_array(jvbNoBase($context['type']), Registrar::getFeatured('is_content', 'term'))) {
+				if (in_array(jvbNoBase($context['type']), Registrar::withFeature('is_content', 'term'))) {
 					// Global: show posts from any content type with this taxonomy
 					$for_content = Registrar::getInstance($context['type'])->registrar->for ?? [];
 
@@ -509,7 +507,7 @@
 					$post_types = array_map(fn($type) => jvbCheckBase($type), $for_content);
 
 					// Filter to only show_feed content types
-					$show_feed_types = Registrar::getFeatured('show_feed', 'post');
+					$show_feed_types = Registrar::withFeature('show_feed', 'post');
 					$args['post_type'] = array_intersect(
 						$post_types,
 						array_map(fn($type) => jvbCheckBase($type), $show_feed_types)
@@ -543,11 +541,15 @@
 	 */
 	protected function applyFavouritesFilter(array $args, array $data): array
 	{
-		if (empty($data['favourites']) || empty($data['user'])) {
+		if (empty($data['favourites'])) {
 			return $args;
 		}
 
-		$user_id = (int)$data['user'];
+		$user_id = get_current_user_id();
+		if (!$user_id) {
+			//Shouldn't happen, but whatever
+			return $args;
+		}
 		$content = jvbNoBase($args['post_type']);
 
 		// Get user's favourites for this content type
@@ -1147,7 +1149,7 @@
 				$config = [];
 
 				// Get content types with show_feed
-				$contentTypes = Registrar::getFeatured('show_feed', 'post');
+				$contentTypes = Registrar::withFeature('show_feed', 'post');
 				foreach ($contentTypes as $slug) {
 					$this->cache->tag('content:'.$slug);
 					$registrar = Registrar::getInstance($slug);
@@ -1163,7 +1165,7 @@
 				}
 
 				// Get taxonomies with show_feed (content taxonomies)
-				$taxonomies = Registrar::getFeatured('show_feed', 'term');
+				$taxonomies = Registrar::withFeature('show_feed', 'term');
 				foreach ($taxonomies as $slug) {
 					$registrar = Registrar::getInstance($slug);
 					if (!$registrar || !($registrar->hasFeature('is_content') ?? false)) {

--
Gitblit v1.10.0