Use Laravel’s Array helper to ease accessing data in authorship array
This commit is contained in:
parent
d3996ad3d9
commit
631826923a
1 changed files with 7 additions and 6 deletions
|
@ -10,6 +10,7 @@ use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Jonnybarnes\WebmentionsParser\Authorship;
|
use Jonnybarnes\WebmentionsParser\Authorship;
|
||||||
use Jonnybarnes\WebmentionsParser\Exceptions\AuthorshipParserException;
|
use Jonnybarnes\WebmentionsParser\Exceptions\AuthorshipParserException;
|
||||||
|
|
||||||
|
@ -19,8 +20,7 @@ class SaveProfileImage implements ShouldQueue
|
||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/** @var array */
|
protected array $microformats;
|
||||||
protected $microformats;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
|
@ -44,17 +44,18 @@ class SaveProfileImage implements ShouldQueue
|
||||||
} catch (AuthorshipParserException $e) {
|
} catch (AuthorshipParserException $e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$photo = $author['properties']['photo'][0];
|
$photo = Arr::get($author, 'properties.photo.0');
|
||||||
$home = $author['properties']['url'][0];
|
$home = Arr::get($author, 'properties.url.0');
|
||||||
//dont save pbs.twimg.com links
|
//dont save pbs.twimg.com links
|
||||||
if (
|
if (
|
||||||
parse_url($photo, PHP_URL_HOST) != 'pbs.twimg.com'
|
$photo
|
||||||
|
&& parse_url($photo, PHP_URL_HOST) != 'pbs.twimg.com'
|
||||||
&& parse_url($photo, PHP_URL_HOST) != 'twitter.com'
|
&& parse_url($photo, PHP_URL_HOST) != 'twitter.com'
|
||||||
) {
|
) {
|
||||||
$client = resolve(Client::class);
|
$client = resolve(Client::class);
|
||||||
try {
|
try {
|
||||||
$response = $client->get($photo);
|
$response = $client->get($photo);
|
||||||
$image = $response->getBody(true);
|
$image = $response->getBody();
|
||||||
} catch (RequestException $e) {
|
} catch (RequestException $e) {
|
||||||
// we are opening and reading the default image so that
|
// we are opening and reading the default image so that
|
||||||
$default = public_path() . '/assets/profile-images/default-image';
|
$default = public_path() . '/assets/profile-images/default-image';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue