Handle finding webmention targets better
If a site does not support webmentions, my code should not error
This commit is contained in:
parent
8ad225c8f6
commit
9fcd16ec16
2 changed files with 19 additions and 2 deletions
|
@ -100,9 +100,12 @@ class SendWebMentions implements ShouldQueue
|
||||||
} elseif (array_key_exists('http://webmention.org/', $rels[0])) {
|
} elseif (array_key_exists('http://webmention.org/', $rels[0])) {
|
||||||
$endpoint = $rels[0]['http://webmention.org/'][0];
|
$endpoint = $rels[0]['http://webmention.org/'][0];
|
||||||
}
|
}
|
||||||
if ($endpoint) {
|
|
||||||
return $this->resolveUri($endpoint, $url);
|
if ($endpoint === null) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->resolveUri($endpoint, $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -109,4 +109,18 @@ class SendWebMentionJobTest extends TestCase
|
||||||
$job->handle();
|
$job->handle();
|
||||||
$this->assertTrue(true);
|
$this->assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function linksInNotesCanNotSupportWebmentions(): void
|
||||||
|
{
|
||||||
|
$mock = new MockHandler([
|
||||||
|
new Response(200),
|
||||||
|
]);
|
||||||
|
$handler = HandlerStack::create($mock);
|
||||||
|
$client = new Client(['handler' => $handler]);
|
||||||
|
$this->app->instance(Client::class, $client);
|
||||||
|
|
||||||
|
$job = new SendWebMentions(new Note());
|
||||||
|
$this->assertNull($job->discoverWebmentionEndpoint('https://example.org'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue