From a6413da67a4579866f0fd0323ddb23a7b6b9654a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 18 Sep 2026 17:00:53 +0000
Subject: [PATCH] =Cleaning up the Integrations setup a bit, started the Helcim integration work too
---
inc/rest/routes/FavouritesRoutes.php | 59 +++++++++++++++++++++++++++++------------------------------
1 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/inc/rest/routes/FavouritesRoutes.php b/inc/rest/routes/FavouritesRoutes.php
index 9e9c0fc..795ddeb 100644
--- a/inc/rest/routes/FavouritesRoutes.php
+++ b/inc/rest/routes/FavouritesRoutes.php
@@ -4,7 +4,10 @@
use JVBase\Instance;
use JVBase\managers\Cache;
use JVBase\managers\CustomTable;
+use JVBase\managers\Emails;
use JVBase\managers\Favourites;
+use JVBase\managers\NotificationManager;
+use JVBase\managers\queue\Queue;
use JVBase\registrar\Registrar;
use JVBase\rest\PermissionHandler;
use JVBase\rest\Response;
@@ -404,8 +407,7 @@
return ['added' => $added, 'errors' => $errors];
} catch (Exception $e) {
- $this->logError('addItemsToList', [
- 'error' => $e->getMessage(),
+ $this->logError($e->getMessage(),'addItemsToList', [
'user_id' => $user_id,
'list_id' => $list_id,
]);
@@ -553,7 +555,7 @@
// Get list items
$items = $this->listItems
->where(['list_id' => $list_id])
- ->orderBy('added_at', 'DESC')
+ ->orderBy('added_at')
->getResults();
// Format items - convert to favourite-like objects
@@ -578,10 +580,11 @@
// Get shared users if owner
$shared_users = [];
+ $is_owner = false;//TODO
if ($is_owner) {
$shares = $this->listShares
->where(['list_id' => $list_id])
- ->orderBy('created_at', 'DESC')
+ ->orderBy('created_at')
->getResults();
foreach ($shares as $share_item) {
@@ -600,7 +603,7 @@
$shared_users[] = $shared_user;
}
}
-
+ $list = []; //TODO: check this
return [
'success' => true,
'list' => [
@@ -616,8 +619,7 @@
];
} catch (Exception $e) {
- $this->logError('getListDetails', [
- 'error' => $e->getMessage(),
+ $this->logError($e->getMessage(), 'getListDetails', [
'user_id' => $user_id,
'list_id' => $list_id
]);
@@ -746,8 +748,7 @@
];
} catch (Exception $e) {
- $this->logError('updateList', [
- 'error' => $e->getMessage(),
+ $this->logError($e->getMessage(),'updateList', [
'user_id' => $user_id,
'list_id' => $list_id
]);
@@ -938,8 +939,7 @@
];
} catch (Exception $e) {
- $this->logError('removeFromList', [
- 'error' => $e->getMessage(),
+ $this->logError($e->getMessage(), 'removeFromList', [
'user_id' => $user_id,
'list_id' => $list_id
]);
@@ -1027,19 +1027,20 @@
]);
// Send notification
- NotificationManager::getInstance()->addNotification(
- $share_user->ID,
- 'list_shared',
- $user_id,
- sprintf('%s shared a favorites list with you: "%s"', $owner_name, $list->name),
- $list_id,
- 'favourites_list',
- [
- 'list_id' => $list_id,
- 'list_name' => $list->name,
- 'permission_type' => $permission_type
- ]
- );
+ // TODO This should be handled by the Favourites:: manager
+// NotificationManager::getInstance()->addNotification(
+// $share_user->ID,
+// 'list_shared',
+// $user_id,
+// sprintf('%s shared a favorites list with you: "%s"', $owner_name, $list->name),
+// $list_id,
+// 'favourites_list',
+// [
+// 'list_id' => $list_id,
+// 'list_name' => $list->name,
+// 'permission_type' => $permission_type
+// ]
+// );
return [
'success' => true,
@@ -1176,8 +1177,7 @@
];
} catch (Exception $e) {
- $this->logError('unshareList', [
- 'error' => $e->getMessage(),
+ $this->logError($e->getMessage(),'unshareList', [
'user_id' => $user_id,
'list_id' => $list_id,
'email' => $email
@@ -1317,8 +1317,7 @@
];
} catch (Exception $e) {
- $this->logError('acceptListInvitation', [
- 'error' => $e->getMessage(),
+ $this->logError($e->getMessage(),'acceptListInvitation', [
'token' => $token,
'email' => $email
]);
@@ -1338,7 +1337,7 @@
// For posts
if (str_contains($type, 'post') || in_array($type, array_keys($this->valid_types))) {
$post = get_post($target_id);
- return $post ? $post->post_author : null;
+ return $post?->post_author;
}
// For terms (shops, etc.)
@@ -1579,7 +1578,7 @@
};
if (!$operation_type) {
- return $this->error('Invalid action', 'invalid_action', 400);
+ return $this->error('Invalid action', 'invalid_action');
}
Queue::getInstance()->queueOperation(
--
Gitblit v1.10.0