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\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Arr;
|
||||
use Jonnybarnes\WebmentionsParser\Authorship;
|
||||
use Jonnybarnes\WebmentionsParser\Exceptions\AuthorshipParserException;
|
||||
|
||||
|
@ -19,8 +20,7 @@ class SaveProfileImage implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var array */
|
||||
protected $microformats;
|
||||
protected array $microformats;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
|
@ -44,17 +44,18 @@ class SaveProfileImage implements ShouldQueue
|
|||
} catch (AuthorshipParserException $e) {
|
||||
return;
|
||||
}
|
||||
$photo = $author['properties']['photo'][0];
|
||||
$home = $author['properties']['url'][0];
|
||||
$photo = Arr::get($author, 'properties.photo.0');
|
||||
$home = Arr::get($author, 'properties.url.0');
|
||||
//dont save pbs.twimg.com links
|
||||
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'
|
||||
) {
|
||||
$client = resolve(Client::class);
|
||||
try {
|
||||
$response = $client->get($photo);
|
||||
$image = $response->getBody(true);
|
||||
$image = $response->getBody();
|
||||
} catch (RequestException $e) {
|
||||
// we are opening and reading the default image so that
|
||||
$default = public_path() . '/assets/profile-images/default-image';
|
||||
|
|
Loading…
Add table
Reference in a new issue