Open driesvints opened 3 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.
To be clear: I mean the coloured block ones in this screenshot should also be the greyed out Laravel.io icon.
Additionally, we should filter out empty avatars on the homepage so we have a full wall of photo's.
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.
https://api.github.com/users/USERNAME
$response->avatar_url
Not sure if I'll have enough time to sit and implement this, but thought I'd leave these notes regardless
oh nice @ProjektGopher. Thanks a lot for digging into that! Definitely useful for follow up.
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.
@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.
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 :)
Hah that's an elaborate way to go about it @tauseefsshah! Do you think a PR could fulfil all the requirements listed above?
@driesvints Following is my understanding of the pending requirements:
Following is my solution:
has_default_avatar
, avatar_synced_at
and github_profile_updated_at
in users
tablehas_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.
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.
Figure our a way to show a grayed out Laravel logo as a default avatar instead of the current default GitHub one.