From c68aefb847b09daa0697de7684d3451e2e68ce1e Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Thu, 09 Jul 2026 23:10:23 +0000
Subject: [PATCH] =Refactor of Integrations.php to be a bit more useful with a suite of methods for create, update, delete back and forths for integrations where sharing is enabled. Also considering a single instance with a connect method to connect as the site (no user) vs connecting as an individual user - rather than recreating instances for every user.

---
 JVBase.php |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/JVBase.php b/JVBase.php
index 90f903d..e771147 100644
--- a/JVBase.php
+++ b/JVBase.php
@@ -86,7 +86,7 @@
 	}
 
 
-	public function __construct()
+	private function __construct()
 	{
 		$this->customBlocks = new CustomBlocks();
 		$this->managers = [
@@ -296,17 +296,20 @@
 
 	public function connect(string $service, ?int $userID = null): mixed
 	{
-		if ($userID) {
-			if (!$this->userCanConnect($service, $userID)) {
-				return null;
-			}
-
-			if (!array_key_exists($service, $this->integrations)) {
-				return null;
-			}
-			return $this->serviceMap[$service]::getInstance($userID);
-		}
-		return (array_key_exists($service, $this->integrations)) ? $this->integrations[$service] : null;
+//		if ($userID) {
+//			if (!$this->userCanConnect($service, $userID)) {
+//				return null;
+//			}
+//
+//			if (!array_key_exists($service, $this->integrations)) {
+//				return null;
+//			}
+//
+//			return $this->serviceMap[$service]::getInstance($userID);
+//		}
+		return is_null($userID) ?
+			$this->integrations[$service]??null :
+			(array_key_exists($service, $this->integrations) ? $this->serviceMap[$service]::getInstance($userID) : null);
 	}
 
 	public function userCanConnect(string $service, int $userID): bool

--
Gitblit v1.10.0