From 87b2b8dc5a94c2af3cee7a91c122a7240044cddf Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 9 Dec 2011 07:40:54 +0100 Subject: [PATCH] Return default avatar ID (null) when ID points to invalid image. This can happen after you delete your avatar image. --- .../java/net/pterodactylus/sone/template/ProfileAccessor.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java b/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java index 97be0cd..8c7d1e4 100644 --- a/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java @@ -60,16 +60,22 @@ public class ProfileAccessor extends ReflectionAccessor { /* not logged in? don’t show custom avatars, then. */ return null; } + String avatarId = profile.getAvatar(); + if (avatarId != null) { + if (core.getImage(avatarId, false) == null) { + /* avatar ID but no matching image? show nothing. */ + return null; + } + } Sone remoteSone = profile.getSone(); if (core.isLocalSone(remoteSone)) { /* always show your own avatars. */ - return profile.getAvatar(); + return avatarId; } ShowCustomAvatars showCustomAvatars = currentSone.getOptions(). getEnumOption("ShowCustomAvatars").get(); if (showCustomAvatars == ShowCustomAvatars.NEVER) { return null; } - String avatarId = profile.getAvatar(); if ((showCustomAvatars == ShowCustomAvatars.ALWAYS) || (avatarId == null)) { return avatarId; } -- 2.7.4