Merge pull request #1315 from jonnybarnes/1314-fix-error-in-sendwebmentions-job

Fix issue discovering webmentions endpoints for some sites
This commit is contained in:
Jonny Barnes 2024-03-02 10:18:46 +00:00 committed by GitHub
commit 33e5855140
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View file

@ -76,7 +76,7 @@ class SendWebMentions implements ShouldQueue
//check HTTP Headers for webmention endpoint //check HTTP Headers for webmention endpoint
$links = Header::parse($response->getHeader('Link')); $links = Header::parse($response->getHeader('Link'));
foreach ($links as $link) { foreach ($links as $link) {
if (mb_stristr($link['rel'], 'webmention')) { if (array_key_exists('rel', $link) && mb_stristr($link['rel'], 'webmention')) {
return $this->resolveUri(trim($link[0], '<>'), $url); return $this->resolveUri(trim($link[0], '<>'), $url);
} }
} }

View file

@ -114,7 +114,8 @@ class SendWebMentionJobTest extends TestCase
public function linksInNotesCanNotSupportWebmentions(): void public function linksInNotesCanNotSupportWebmentions(): void
{ {
$mock = new MockHandler([ $mock = new MockHandler([
new Response(200), // URLs with commas currently break the parse function Im using
new Response(200, ['Link' => '<https://example.org/foo,bar>; rel="preconnect"']),
]); ]);
$handler = HandlerStack::create($mock); $handler = HandlerStack::create($mock);
$client = new Client(['handler' => $handler]); $client = new Client(['handler' => $handler]);