X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FProfileAccessor.java;h=9b0a7fc66f15371e481401d84e97bbea0c11272c;hb=61c23dc5c1244abc3efff879ee2d3a99c1acebba;hp=30c0a526b04dc90f24ece038b4546e9ebacdb2f2;hpb=6f019de1d4d9742981d851ac3c9097cca8bff58e;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java b/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java index 30c0a52..9b0a7fc 100644 --- a/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java @@ -49,9 +49,6 @@ public class ProfileAccessor extends ReflectionAccessor { this.core = core; } - /** - * {@inheritDoc} - */ @Override public Object get(TemplateContext templateContext, Object object, String member) { Profile profile = (Profile) object; @@ -65,10 +62,13 @@ public class ProfileAccessor extends ReflectionAccessor { if (avatarId == null) { return null; } - if (core.getImage(avatarId, false) == null) { + if (!core.getImage(avatarId).isPresent()) { /* avatar ID but no matching image? show nothing. */ return null; } + if (!avatarImageBelongsToTheSameSoneAsTheProfile(profile, avatarId)) { + return null; + } Sone remoteSone = profile.getSone(); if (remoteSone.isLocal()) { /* always show your own avatars. */ @@ -99,4 +99,8 @@ public class ProfileAccessor extends ReflectionAccessor { return super.get(templateContext, object, member); } + private boolean avatarImageBelongsToTheSameSoneAsTheProfile(Profile profile, String avatarId) { + return core.getImage(avatarId).get().getSone().equals(profile.getSone()); + } + }