From 674a67b0ba6a6cfde0e8a4584a0047748821ab76 Mon Sep 17 00:00:00 2001 From: Venkatesh Sangam Date: Sun, 30 Jun 2024 15:04:19 +0530 Subject: [PATCH] changes made according to rabbitai --- .../ai/elimu/web/SignOnControllerDiscord.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/ai/elimu/web/SignOnControllerDiscord.java b/src/main/java/ai/elimu/web/SignOnControllerDiscord.java index f20b27b59..8723206e1 100644 --- a/src/main/java/ai/elimu/web/SignOnControllerDiscord.java +++ b/src/main/java/ai/elimu/web/SignOnControllerDiscord.java @@ -132,24 +132,24 @@ public String handleCallback(HttpServletRequest request) throws IOException, Int String id = String.valueOf(idAsLong); contributor.setProviderIdDiscord(id); } + private static final String DEFAULT_AVATAR_URL = "https://e7.pngegg.com/pngimages/84/165/" + + "png-clipart-united-states-avatar-organization-information" + + "-user-avatar-service-computer-wallpaper-thumbnail.png"; + + if (jsonObject.has("avatar")) { - if (jsonObject.get("avatar") instanceof String) { + if (jsonObject.get("avatar") instanceof String) { String avatar = jsonObject.getString("avatar"); if (!avatar.isEmpty()) { String uriAvatar = "https://cdn.discordapp.com/avatars/" + jsonObject.getLong("id") + "/" + avatar + ".png"; logger.info(uriAvatar); contributor.setImageUrl(uriAvatar); } else { - // Handle case where avatar field is empty or not provided - contributor.setImageUrl("https://e7.pngegg.com/pngimages/84/165/" - +"png-clipart-united-states-avatar-organization-information" - +"-user-avatar-service-computer-wallpaper-thumbnail.png"); + contributor.setImageUrl(DEFAULT_AVATAR_URL); } } else { logger.warn("Avatar field is not a string: " + jsonObject.get("avatar")); - contributor.setImageUrl("https://e7.pngegg.com/pngimages/84/165/" - +"png-clipart-united-states-avatar-organization-information" - +"-user-avatar-service-computer-wallpaper-thumbnail.png"); // Replace with your default avatar URL + contributor.setImageUrl(DEFAULT_AVATAR_URL); } } if (jsonObject.has("username")) {