From 090618fdb9ab27eb39e45477217e625f7c59acca Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Thu, 27 Oct 2016 23:51:34 +0300 Subject: [PATCH] Fix wrong avatar url In my case profileImageUrl is not null but empty string so I get "https://secure.gravatar.com/avatar/" link to profile image. --- .../springframework/social/github/api/impl/UserTemplate.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/UserTemplate.java b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/UserTemplate.java index 6f512467..e5f6112a 100644 --- a/spring-social-github/src/main/java/org/springframework/social/github/api/impl/UserTemplate.java +++ b/spring-social-github/src/main/java/org/springframework/social/github/api/impl/UserTemplate.java @@ -57,7 +57,10 @@ public GitHubUserProfile getUserProfile() { String email = user.get("email") != null ? String.valueOf(user.get("email")) : null; Date createdDate = toDate(String.valueOf(user.get("created_at")), dateFormat); String gravatarId = (String) user.get("gravatar_id"); - String profileImageUrl = gravatarId != null ? "https://secure.gravatar.com/avatar/" + gravatarId : null; + String profileImageUrl = (gravatarId != null && !gravatarId.equals("")) ? "https://secure.gravatar.com/avatar/" + gravatarId : null; + if (profileImageUrl == null) { + profileImageUrl = user.get("avatar_url") != null ? String.valueOf(user.get("avatar_url")) : null; + } return new GitHubUserProfile(gitHubId, username, name, location, company, blog, email, profileImageUrl, createdDate); }