Skip to content

fallback to Gravatar for rendering avatar icons - #3513

Merged
iAmWillShepherd merged 16 commits into
masterfrom
avatar-fall-through-cache
Dec 7, 2017
Merged

iAmWillShepherd merged 16 commits into
masterfrom
avatar-fall-through-cache

Conversation

@shiftkey

@shiftkey shiftkey commented Dec 6, 2017 •

Copy link
Copy Markdown
Member

Fixes #821

This changes up the strategy for rendering avatars in a few ways, because who knew rendering an image on screen could be so fascinating.

  • initially render Hubot avatar while fetching an image
  • if no GitHub avatar found, generate and try for a Gravatar avatar
  • transform these into object URLs that the browser handles and can cache fine
  • handle cache failures instead of retrying each time
  • test against GHE setup and confirm the fallbacks make sense
    • unauthenticated GHE requests will redirect and return something like text/html - handle this and skip it
    • blacklist GHE avatars for now so we don't HTTP 429 ourselves
    • commit form user should change to use gravatar, instead of falling back to Hubot
    • accounts list should render something for the avatar
  • test against non-GitHub repository
    • don't show Hubot, do show Gravatars

}

/**
* Fetch an avatar associated to associate with a user, using graceful fallback

This comment was marked as spam.

This comment was marked as spam.

@shiftkey

shiftkey commented Dec 7, 2017 •

Copy link
Copy Markdown
Member Author

Visually, this is what our current master does when you're only signed into GitHub Enterprise:

GitHub Enterprise repository

Some Other repository (in this case it's Desktop)

With this change, things get a bit more personal:

GitHub Enterprise repository

Some Other repository

I don't think it's worth trying to get Identicons working as a fallback for those people who don't have Gravatar setup for their email addresses.

Also, this solution involves a fair bit of blacklisting of GitHub Enterprise avatars 😢 I have ideas for rolling this back later but it requires us to know about the version of GitHub Enterprise you're talking to - a job for a follow-up PR.

const gitHubUser =
this.props.gitHubUsers.get(commit.author.email.toLowerCase()) || null
let avatarUser = null
if (gitHubUser) {

This comment was marked as spam.

@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Dec 7, 2017
@iAmWillShepherd

Copy link
Copy Markdown
Contributor

Looks good and works on my machine 🤞

kabel added a commit to kabel/vscode-pull-request-github that referenced this pull request Apr 26, 2023
In GitHub Enterprise, the avatarUrl endpoints that the APIs return require authentication in standard configuration. There is currently no way to do token authentication to these endpoints, so a fallback is necessary to render an image.

The interface was previously coded to handle fallback to the Gravatar service (just like GitHub Desktop [did](desktop/desktop#3513)), but this behavior was disabled in 13ab0a7 and 6769dd4 because of end-user preference for making this feature configurable.

A new setting has been added

* `githubPullRequests.defaultGravatarsStyle` is an `enum` of the Gravatar supported fallback styles plus an internal value of `none` to disable the integration

These settings provide a richer user experience for GitHub Enterprise pull requests, allowing users to opt-in/out on avatar rendering via a third-party service with multiple options for the default fallback image style.

For consistency in multiple interface areas where `<Avatar>` is rendered, the graphQL queryies (and matching typescript interfaces) have been updated to include the necessary `email` property for integration with Gravatar.

REST provided actors are missing email. If missing email and using GitHub Enterprise, make another REST API call to the user endpoiint to get email. This allows a fallback avatar to be generated.

This fixes GitHub Enterprise avatars not being rendered in the tree views.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants