Update guzzle psr7 calls
The prior methods used have been deprecated and removed from upstream project.
This commit is contained in:
parent
939c7839f6
commit
76dfe41e8c
1 changed files with 13 additions and 10 deletions
|
@ -6,7 +6,10 @@ namespace App\Jobs;
|
||||||
|
|
||||||
use App\Models\Note;
|
use App\Models\Note;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\Psr7\Header;
|
||||||
use GuzzleHttp\Psr7\Uri;
|
use GuzzleHttp\Psr7\Uri;
|
||||||
|
use GuzzleHttp\Psr7\UriResolver;
|
||||||
|
use GuzzleHttp\Psr7\Utils;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
@ -65,14 +68,14 @@ class SendWebMentions implements ShouldQueue
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function discoverWebmentionEndpoint(string $url)
|
public function discoverWebmentionEndpoint(string $url): ?string
|
||||||
{
|
{
|
||||||
//let’s not send webmentions to myself
|
//let’s not send webmentions to myself
|
||||||
if (parse_url($url, PHP_URL_HOST) == config('app.longurl')) {
|
if (parse_url($url, PHP_URL_HOST) === config('app.longurl')) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
if (Str::startsWith($url, '/notes/tagged/')) {
|
if (Str::startsWith($url, '/notes/tagged/')) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$endpoint = null;
|
$endpoint = null;
|
||||||
|
@ -80,7 +83,7 @@ class SendWebMentions implements ShouldQueue
|
||||||
$guzzle = resolve(Client::class);
|
$guzzle = resolve(Client::class);
|
||||||
$response = $guzzle->get($url);
|
$response = $guzzle->get($url);
|
||||||
//check HTTP Headers for webmention endpoint
|
//check HTTP Headers for webmention endpoint
|
||||||
$links = \GuzzleHttp\Psr7\parse_header($response->getHeader('Link'));
|
$links = Header::parse($response->getHeader('Link'));
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
if (mb_stristr($link['rel'], 'webmention')) {
|
if (mb_stristr($link['rel'], 'webmention')) {
|
||||||
return $this->resolveUri(trim($link[0], '<>'), $url);
|
return $this->resolveUri(trim($link[0], '<>'), $url);
|
||||||
|
@ -110,7 +113,7 @@ class SendWebMentions implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function getLinks(?string $html): array
|
public function getLinks(?string $html): array
|
||||||
{
|
{
|
||||||
if ($html == '' || is_null($html)) {
|
if ($html === '' || is_null($html)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,13 +139,13 @@ class SendWebMentions implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function resolveUri(string $url, string $base): string
|
public function resolveUri(string $url, string $base): string
|
||||||
{
|
{
|
||||||
$endpoint = \GuzzleHttp\Psr7\uri_for($url);
|
$endpoint = Utils::uriFor($url);
|
||||||
if ($endpoint->getScheme() != '') {
|
if ($endpoint->getScheme() !== '') {
|
||||||
return (string) $endpoint;
|
return (string) $endpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) Uri::resolve(
|
return (string) UriResolver::resolve(
|
||||||
\GuzzleHttp\Psr7\uri_for($base),
|
Utils::uriFor($base),
|
||||||
$endpoint
|
$endpoint
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue