Jake Vanderwerf
2026-09-18 a6413da67a4579866f0fd0323ddb23a7b6b9654a
inc/integrations/Integrations.php
@@ -3,6 +3,7 @@
use Exception;
use JVBase\managers\Cache;
use JVBase\managers\queue\Queue;
use JVBase\managers\UploadManager;
use JVBase\registrar\Registrar;
use WP_Error;
@@ -177,7 +178,7 @@
         return $this->response(false, 'Failed to save credentials to database');
      } catch (\Exception $e) {
      } catch (Exception $e) {
         // Revert to old credentials on any error
         $old = Auth::getInstance()->getCredentials(
            $this->service_name,
@@ -246,7 +247,7 @@
   public function testConnection(bool $force = false): bool
   {
      if (!$this->isSetUp()) {
         return false;
         return true;
      }
      $this->ensureInitialized();
@@ -254,13 +255,6 @@
         return false;
      }
      // Cache test results to avoid excessive API calls
      $cacheKey = "connection_test_$this->service_name" . ($this->userID ? "_$this->userID" : '');
      $cached = $this->cache->get($cacheKey);
      if ($cached !== false && !$force) {
         return (bool)$cached;
      }
      try {
         if (!$this->hasOAuthCredentials()){
@@ -271,11 +265,9 @@
         }
         $this->updateLastTestedTime();
         $this->cache->set($cacheKey, $result, 300); // Cache for 5 minutes
         return $result;
      } catch (Exception $e) {
         $this->logError('Connection test failed', ['error' => $e->getMessage()]);
         $this->cache->set($cacheKey, false, 60); // Cache failure for 1 minute
         $this->logError('testConnection', $e->getMessage());
         return false;
      }
   }
@@ -476,7 +468,7 @@
            'message' => 'Connection established successfully'
         ];
      } catch (\Exception $e) {
      } catch (Exception $e) {
         return [
            'success' => false,
            'message' => 'Error: ' . $e->getMessage()
@@ -608,7 +600,7 @@
         return $jpegVersion;
      }
      $uploader = UploadManager::getInstance();
      $converted = $uploader->convertImageTo($imgID, 'jpeg', 80, false);
      $converted = $uploader->convertImageTo($imgID, 'jpeg');
      if ($converted && !is_wp_error($converted)) {
         update_post_meta($imgID, BASE . 'jpeg_version', $converted['attachment_id']);
         return $converted['attachment_id'];
@@ -633,4 +625,9 @@
      return $this->icon;
   }
   public function getUserID():?int
   {
      return $this->userID;
   }
}