Migrate outbound HTTP calls from Guzzle to the Http facade

Replaces every raw GuzzleHttp\Client usage (Nominatim, web.archive.org,
webmention fetch/discover/send, Bridgy syndication, IndieAuth client_id
lookup, contact avatar/h-card fetch, profile image download, and the
CloudConvert screenshot pipeline) with Illuminate\Support\Facades\Http,
and enables Http::preventStrayRequests() globally in tests so any
un-faked outbound call now fails loudly instead of silently hitting the
network.

The CloudConvert retry-until-finished middleware in AppServiceProvider
is replaced by a plain polling loop in SaveScreenshot, which also fixes
a latent bug where the old middleware decoded a response object instead
of its body. Bridgy syndication jobs keep their tries=1/no-retry
semantics unchanged to avoid duplicate publishes. Guzzle's PSR-7 helpers
(Header, UriResolver, Utils) stay in SendWebMentions since Http has no
equivalent for them.

Every affected test file's Guzzle MockHandler/HandlerStack boilerplate
is replaced with Http::fake()/Http::sequence().

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P8j7cJhCiYDsGUgB7obKNQ
This commit is contained in:
Jonny Barnes 2026-07-26 09:12:01 +01:00
commit e08763c526
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
26 changed files with 337 additions and 630 deletions

View file

@ -5,13 +5,12 @@ declare(strict_types=1);
namespace App\Jobs;
use App\Models\Note;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Http;
class SyndicateNoteToMastodon implements ShouldQueue
{
@ -31,29 +30,18 @@ class SyndicateNoteToMastodon implements ShouldQueue
/**
* Execute the job.
*
* @throws GuzzleException
*/
public function handle(Client $guzzle): void
public function handle(): void
{
$response = $guzzle->request(
'POST',
'https://brid.gy/publish/webmention',
[
'headers' => [
'Accept' => 'application/json',
],
'form_params' => [
'source' => $this->note->uri,
'target' => 'https://brid.gy/publish/mastodon',
],
'http_errors' => false,
]
);
// no ->throw()/->retry() here — Bridgy would duplicate-publish on retry, see $tries above
$response = Http::acceptJson()->asForm()->post('https://brid.gy/publish/webmention', [
'source' => $this->note->uri,
'target' => 'https://brid.gy/publish/mastodon',
]);
$body = json_decode((string) $response->getBody(), true);
$body = $response->json();
if ($response->getStatusCode() === 201) {
if ($response->status() === 201) {
$this->note->mastodon_url = $body['url'];
$this->note->save();
@ -61,7 +49,7 @@ class SyndicateNoteToMastodon implements ShouldQueue
}
throw new \RuntimeException(
'Bridgy publish to Mastodon failed: '.($body['error'] ?? (string) $response->getBody())
'Bridgy publish to Mastodon failed: '.($body['error'] ?? $response->body())
);
}
}