refactor: Refactor and add tests for SaveProfileImage feature

- Add error handling checks for photo and home
- Add 3 new tests and modify an existing test for SaveProfileImageJob
- Test getting URL from photo object if alt text is provided
- Test using the first URL if multiple homepages are provided
This commit is contained in:
Jonny Barnes 2023-06-17 19:48:27 +01:00
parent 58ee36c932
commit dabd03f556
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
2 changed files with 67 additions and 0 deletions

View file

@ -42,6 +42,14 @@ class SaveProfileImage implements ShouldQueue
$photo = Arr::get($author, 'properties.photo.0');
$home = Arr::get($author, 'properties.url.0');
if (is_array($photo) && array_key_exists('value', $photo)) {
$photo = $photo['value'];
}
if (is_array($home)) {
$home = array_shift($home);
}
//dont save pbs.twimg.com links
if (
$photo