Switch Bridgy syndication from Micropub to webmention

Bridgy's Micropub endpoint required per-silo access tokens and posted
raw markdown content directly. Switch to Bridgy's webmention publish
endpoint instead: POST source/target to /publish/webmention and let
Bridgy re-fetch the note page, which now carries hidden verification
links for silos not yet syndicated. Removes the now-unused
config/bridgy.php and BRIDGY_MASTODON_TOKEN env var, and caps both
jobs to a single try since retries would send Bridgy a duplicate
publish webmention.
This commit is contained in:
Jonny Barnes 2026-07-14 17:36:25 +01:00
commit db09718a96
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
9 changed files with 167 additions and 94 deletions

View file

@ -17,6 +17,11 @@ class SyndicateNoteToMastodon implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Only try once retrying would send Bridgy a duplicate publish webmention.
*/
public int $tries = 1;
/**
* Create a new job instance.
*/
@ -31,33 +36,32 @@ class SyndicateNoteToMastodon implements ShouldQueue
*/
public function handle(Client $guzzle): void
{
// We can only make the request if we have an access token
if (config('bridgy.mastodon_token') === null) {
return;
}
// Make micropub request
$response = $guzzle->request(
'POST',
'https://brid.gy/micropub',
'https://brid.gy/publish/webmention',
[
'headers' => [
'Authorization' => 'Bearer '.config('bridgy.mastodon_token'),
'Accept' => 'application/json',
],
'json' => [
'type' => ['h-entry'],
'properties' => [
'content' => [$this->note->getRawOriginal('note')],
],
'form_params' => [
'source' => $this->note->uri,
'target' => 'https://brid.gy/publish/mastodon',
],
'http_errors' => false,
]
);
// Parse for syndication URL
$body = json_decode((string) $response->getBody(), true);
if ($response->getStatusCode() === 201) {
$mastodonUrl = $response->getHeader('Location')[0];
$this->note->mastodon_url = $mastodonUrl;
$this->note->mastodon_url = $body['url'];
$this->note->save();
return;
}
throw new \RuntimeException(
'Bridgy publish to Mastodon failed: '.($body['error'] ?? (string) $response->getBody())
);
}
}