laravelio / laravel.io

The Laravel.io Community Portal.
https://laravel.io
MIT License
2.44k stars 650 forks source link

Replace default GitHub avatar #688

Open driesvints opened 3 years ago

driesvints commented 3 years ago

Figure our a way to show a grayed out Laravel logo as a default avatar instead of the current default GitHub one.

driesvints commented 2 years ago

Gonna re-open this to keep our target to also figure out a way to replace the default GitHub avatar. Maybe we can sync through GitHub web hooks to figure out if a user is using a default GitHub avatar or not.

driesvints commented 2 years ago

To be clear: I mean the coloured block ones in this screenshot should also be the greyed out Laravel.io icon.

Screenshot 2022-01-08 at 16 22 24
driesvints commented 2 years ago

Additionally, we should filter out empty avatars on the homepage so we have a full wall of photo's.

driesvints commented 11 months ago

Might also want to remove unavatar in total because we seem to be running into rate limiting issues. Not sure what the best way forward is here.

ProjektGopher commented 11 months ago

Not sure if I'll have enough time to sit and implement this, but thought I'd leave these notes regardless

for reference

driesvints commented 11 months ago

oh nice @ProjektGopher. Thanks a lot for digging into that! Definitely useful for follow up.

imacrayon commented 11 months ago

Might also want to remove unavatar

We could store a user’s GitHub avatar URL in the DB when they register. Then we could check if the URL needs to be updated each time a user logs in or through a scheduled job.

driesvints commented 11 months ago

@imacrayon yeah I was first thinking about GitHub webhooks but that might be a bit too complex. A middleware on logged in routes that checks the updated_at timestamp of a logged in user and rechecks the avatar might work.

tauseefsshah commented 2 weeks ago

Hi @driesvints

So I found something for the coloured github default avatar thing.

We can get the current user avatar from the https://api.github.com/users/{USERNAME} api and then we can verify if it's the default github identicon by comparing with the https://github.com/identicons/{USERNAME}.png (This url has the default github identicon png for the user)

I found this package image-comparator-laravel and it has 100% accuracy for this (I tried on 5 samples). This package uses gd under the hood and uses the image hashes to compare so it won't be compute intensive.

Let me know if this package and approach looks good. I'll take it up :)

driesvints commented 1 week ago

Hah that's an elaborate way to go about it @tauseefsshah! Do you think a PR could fulfil all the requirements listed above?

tauseefsshah commented 1 week ago

@driesvints Following is my understanding of the pending requirements:

  1. If a user has a default github avatar then show grayed out laravel.io icon
  2. Filter out empty avatars and only have ones with an actual photo

Following is my solution:

  1. Create columns has_default_avatar, avatar_synced_at and github_profile_updated_at in users table
  2. Write a command that runs every 6hrs to run a job to update the has_default_avatar field if the last sync is >24hrs (The job will only run if the github_profile_updated_at is not same as updated_at returned by github api)

Let me know if I am missing on any requirement or should change the approach.

driesvints commented 4 days ago

Yes that's correct. Although I'm not sure we'd want to add that many columns. Tbh I'd like to see a more simpler solution. Maybe we should let this issue be for what it is for now.