瀏覽代碼

Add missing test connection endpoints for JellyStat and UserWatchStats

- Add /api/v2/test/jellystat endpoint to connectionTester.php routes
- Add /api/v2/test/userWatchStats endpoint to connectionTester.php routes
- Both endpoints follow the same pattern as other test connection routes
- This fixes the 404 'Endpoint Not Found' error when testing plugin connections
- Enables the test connection buttons in the JellyStat and UserWatchStats plugin settings
mgomon 8 月之前
父節點
當前提交
303a4ec026
共有 2 個文件被更改,包括 68 次插入0 次删除
  1. 44 0
      api/v2/routes/connectionTester.php
  2. 24 0
      server.log

+ 44 - 0
api/v2/routes/connectionTester.php

@@ -765,3 +765,47 @@ $app->post('/test/slack-logs', function ($request, $response, $args) {
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
 });
+$app->post('/test/jellystat', function ($request, $response, $args) {
+	/**
+	 * @OA\Post(
+	 *     security={{ "api_key":{} }},
+	 *     tags={"test connection"},
+	 *     path="/api/v2/test/jellystat",
+	 *     summary="Test connection to JellyStat",
+	 *     @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
+	 *     @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
+	 *     @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
+	 *     @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
+	 * )
+	 */
+	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
+	if ($Organizr->qualifyRequest(1, true)) {
+		$Organizr->testConnectionJellyStat();
+	}
+	$response->getBody()->write(jsonE($GLOBALS['api']));
+	return $response
+		->withHeader('Content-Type', 'application/json;charset=UTF-8')
+		->withStatus($GLOBALS['responseCode']);
+});
+$app->post('/test/userWatchStats', function ($request, $response, $args) {
+	/**
+	 * @OA\Post(
+	 *     security={{ "api_key":{} }},
+	 *     tags={"test connection"},
+	 *     path="/api/v2/test/userWatchStats",
+	 *     summary="Test connection to User Watch Stats",
+	 *     @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
+	 *     @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
+	 *     @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
+	 *     @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
+	 * )
+	 */
+	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
+	if ($Organizr->qualifyRequest(1, true)) {
+		$Organizr->testConnectionUserWatchStats();
+	}
+	$response->getBody()->write(jsonE($GLOBALS['api']));
+	return $response
+		->withHeader('Content-Type', 'application/json;charset=UTF-8')
+		->withStatus($GLOBALS['responseCode']);
+});

+ 24 - 0
server.log

@@ -60,3 +60,27 @@
 [Sun Aug  3 21:31:02 2025] PHP Deprecated:  stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /Users/mgomon/Documents/Code/organizr/api/v2/index.php on line 73
 [Sun Aug  3 21:31:02 2025] [::1]:62158 [401]: GET /api/v2/homepage/jellystat
 [Sun Aug  3 21:31:02 2025] [::1]:62158 Closing
+[Sun Aug  3 21:40:09 2025] [::1]:63221 Accepted
+[Sun Aug  3 21:40:09 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1911
+[Sun Aug  3 21:40:09 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1922
+[Sun Aug  3 21:40:09 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1934
+[Sun Aug  3 21:40:09 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1949
+[Sun Aug  3 21:40:09 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1890
+[Sun Aug  3 21:40:09 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1869
+[Sun Aug  3 21:40:09 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1838
+[Sun Aug  3 21:40:09 2025] PHP Warning:  Undefined array key "QUERY_STRING" in /Users/mgomon/Documents/Code/organizr/api/v2/index.php on line 72
+[Sun Aug  3 21:40:09 2025] PHP Deprecated:  stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /Users/mgomon/Documents/Code/organizr/api/v2/index.php on line 73
+[Sun Aug  3 21:40:09 2025] [::1]:63221 [401]: GET /api/v2/homepage/jellystat
+[Sun Aug  3 21:40:09 2025] [::1]:63221 Closing
+[Sun Aug  3 21:40:14 2025] [::1]:63222 Accepted
+[Sun Aug  3 21:40:14 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1911
+[Sun Aug  3 21:40:14 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1922
+[Sun Aug  3 21:40:14 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1934
+[Sun Aug  3 21:40:14 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1949
+[Sun Aug  3 21:40:14 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1890
+[Sun Aug  3 21:40:14 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1869
+[Sun Aug  3 21:40:14 2025] PHP Deprecated:  Return type of Tightenco\Collect\Support\Collection::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/mgomon/Documents/Code/organizr/api/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1838
+[Sun Aug  3 21:40:14 2025] PHP Warning:  Undefined array key "QUERY_STRING" in /Users/mgomon/Documents/Code/organizr/api/v2/index.php on line 72
+[Sun Aug  3 21:40:14 2025] PHP Deprecated:  stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /Users/mgomon/Documents/Code/organizr/api/v2/index.php on line 73
+[Sun Aug  3 21:40:14 2025] [::1]:63222 [401]: GET /api/v2/homepage/jellystat
+[Sun Aug  3 21:40:14 2025] [::1]:63222 Closing