X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FProfileAccessor.java;h=9b0a7fc66f15371e481401d84e97bbea0c11272c;hb=953c41bc82b474680d84266fd7227ce08480883c;hp=19177c3fb4b1a150bf51b3fdf70ddd7d815db877;hpb=a88e930a23b550dae75116d7759924d760941776;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 19177c3..9b0a7fc 100644 --- a/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java @@ -1,5 +1,5 @@ /* - * Sone - ProfileAccessor.java - Copyright © 2011–2012 David Roden + * Sone - ProfileAccessor.java - Copyright © 2011–2013 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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()); + } + }