更新 Speed/Convoy.php

This commit is contained in:
ste87 2026-03-14 14:38:39 +08:00
parent 5ec978f4cb
commit 43659ac4ee

View File

@ -22,7 +22,11 @@ class Convoy extends Server
if (!$response->successful()) { if (!$response->successful()) {
$json = $response->json(); $json = $response->json();
$message = $json['message'] ?? $json['error'] ?? 'Server Error'; if (is_array($json)) {
$message = $json['message'] ?? $json['error'] ?? $json['errors'][0]['message'] ?? 'Server Error';
} else {
$message = 'Server Error: ' . $response->status();
}
throw new Exception($message); throw new Exception($message);
} }
@ -30,7 +34,7 @@ class Convoy extends Server
} }
/** /**
* Get all the configuration for the extension * Get all configuration for extension
* *
* @param array $values * @param array $values
*/ */
@ -150,10 +154,10 @@ class Convoy extends Server
$os = $this->request('nodes/' . $node . '/template-groups'); $os = $this->request('nodes/' . $node . '/template-groups');
$options = []; $options = [];
foreach ($os['data'] as $os) { foreach ($os['data'] as $osGroup) {
foreach ($os['templates'] as $template) { foreach ($osGroup['templates'] as $templateGroup) {
foreach ($template as $template1) { foreach ($templateGroup as $template) {
$options[$template1['uuid']] = $template1['name']; $options[$template['uuid']] = $template['name'];
} }
} }
} }
@ -178,7 +182,7 @@ class Convoy extends Server
} }
/** /**
* Check if currenct configuration is valid * Check if current configuration is valid
*/ */
public function testConfig(): bool|string public function testConfig(): bool|string
{ {
@ -193,7 +197,7 @@ class Convoy extends Server
return true; return true;
} }
// Convoy is reallyy strict (The account password must contain 8 - 50 characters, 1 uppercase, 1 lowercase, 1 number and 1 special character.) // Convoy is really strict (The account password must contain 8 - 50 characters, 1 uppercase, 1 lowercase, 1 number and 1 special character.)
private function createPassword() private function createPassword()
{ {
$password = Str::password(); $password = Str::password();
@ -432,4 +436,4 @@ class Convoy extends Server
return rtrim($this->config('host'), '/') . '/authenticate?token=' . $data['data']['token']; return rtrim($this->config('host'), '/') . '/authenticate?token=' . $data['data']['token'];
} }
} }