Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avatar URL gets overridden regardless of custom user resolution #133

Closed
JanniGrabe opened this issue Dec 4, 2023 · 1 comment
Closed

Comments

@JanniGrabe
Copy link

Pulse Version

1.0.0-beta2

Laravel Version

10.34.2

PHP Version

8.2.12

Database Driver & Version

MySQL 8.0.32

Description

Even if I define an 'avatar' array key as described in the docs

Pulse::users(function ($ids) {
    return User::findMany($ids)->map(fn ($user) => [
        'id' => $user->id,
        'name' => $user->name,
        'extra' => $user->email,
        'avatar' => $user->avatar_url,
    ]);
});

it will get overriden by the Collection mapping in src/Livewire/Usage.php.

'avatar' => $user['avatar'] ?? (($user['email'] ?? false)
? sprintf('https://gravatar.com/avatar/%s?d=mp', hash('sha256', trim(strtolower($user['email']))))
: null),

Also, the gravatar URL includes an 'email' array key that is not stated in the docs, I would suggest to either replace that with 'extra' or add email to the example.

Steps To Reproduce

  1. Install Laravel Pulse
  2. Insert
    Pulse::users(function ($ids) {
    return User::findMany($ids)->map(fn ($user) => [
        'id' => $user->id,
        'name' => $user->name,
        'extra' => $user->email,
        'avatar' => $user->avatar_url,
    ]);
    });
    
    into your AuthServiceProvider.php's boot() function
  3. Open Laravel Pulse
@jbrooksuk
Copy link
Member

This should be fixed in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants