Allow plain text response for plugin data polling

This commit is contained in:
kwlo 2025-11-01 12:59:59 -04:00 committed by Benjamin Nussbaum
parent 882cbff7fe
commit 52dfe92054
2 changed files with 31 additions and 3 deletions

View file

@ -235,9 +235,15 @@ class Plugin extends Model
}
}
// Default to JSON parsing
try {
return $httpResponse->json() ?? [];
// Attempt to parse it into JSON
$json = $httpResponse->json();
if($json !== null) {
return $json;
}
// Response doesn't seem to be JSON, wrap the response body text as a JSON object
return ['text' => $httpResponse->body()];
} catch (Exception $e) {
Log::warning('Failed to parse JSON response: '.$e->getMessage());