Skip to content

Commit

Permalink
update avatar and originalAvatar display size check (#671)
Browse files Browse the repository at this point in the history
* update avatar and originalAvatar display size check

The linkedIn response replaced/removed the array key `storageSize` with `displaySize`, this change will check for both.

It currently throws an exception:

```
ErrorException GET /auth/linkedin
Undefined array key "storageSize"
```

* fix: indentation

* fix: indentation - 2nd try
  • Loading branch information
luigitec committed Oct 25, 2023
1 parent 116b233 commit 444b2c7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Two/LinkedInProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,16 @@ protected function mapUserToObject(array $user)

$images = (array) Arr::get($user, 'profilePicture.displayImage~.elements', []);
$avatar = Arr::first($images, function ($image) {
return $image['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['storageSize']['width'] === 100;
return (
$image['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['storageSize']['width'] ??
$image['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['displaySize']['width']
) === 100;
});
$originalAvatar = Arr::first($images, function ($image) {
return $image['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['storageSize']['width'] === 800;
return (
$image['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['storageSize']['width'] ??
$image['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['displaySize']['width']
) === 800;
});

return (new User)->setRaw($user)->map([
Expand Down

0 comments on commit 444b2c7

Please sign in to comment.