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

Replace default GitHub avatar #688

Open
driesvints opened this issue Sep 29, 2021 · 11 comments · Fixed by #759
Open

Replace default GitHub avatar #688

driesvints opened this issue Sep 29, 2021 · 11 comments · Fixed by #759

Comments

@driesvints
Copy link
Member

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

@driesvints
Copy link
Member Author

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 driesvints reopened this Jan 8, 2022
@driesvints
Copy link
Member Author

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 driesvints changed the title New default avatar Replace default GitHub avatar Jan 14, 2022
@driesvints
Copy link
Member Author

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

@driesvints
Copy link
Member Author

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
Copy link
Contributor

ProjektGopher commented Nov 6, 2023

  • get user info from api https://api.github.com/users/USERNAME
  • on 200, temporarily download image $response->avatar_url
  • if image !png, return
  • if image !420x420, return
  • if image has > 2 colours, return (more resource intensive)

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

for reference

@driesvints
Copy link
Member Author

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

@imacrayon
Copy link
Contributor

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
Copy link
Member Author

@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
Copy link
Contributor

tauseefsshah commented Oct 5, 2024

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
Copy link
Member Author

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

@tauseefsshah
Copy link
Contributor

@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.

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

Successfully merging a pull request may close this issue.

4 participants