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=1f29b65c02d67b9cf46ace175da4bfe04b78d135;hpb=50ce65f69e49ed10abeedaeb6615ffb37a0c0772;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 1f29b65..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 @@ -21,6 +21,7 @@ import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Profile; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.data.Sone.ShowCustomAvatars; +import net.pterodactylus.sone.freenet.wot.OwnIdentity; import net.pterodactylus.sone.freenet.wot.Trust; import net.pterodactylus.util.template.Accessor; import net.pterodactylus.util.template.ReflectionAccessor; @@ -48,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; @@ -64,12 +62,15 @@ 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 (core.isLocalSone(remoteSone)) { + if (remoteSone.isLocal()) { /* always show your own avatars. */ return avatarId; } @@ -83,7 +84,7 @@ public class ProfileAccessor extends ReflectionAccessor { if (showCustomAvatars == ShowCustomAvatars.FOLLOWED) { return currentSone.hasFriend(remoteSone.getId()) ? avatarId : null; } - Trust trust = core.getTrust(currentSone, remoteSone); + Trust trust = remoteSone.getIdentity().getTrust((OwnIdentity) currentSone.getIdentity()); if (trust == null) { return null; } @@ -98,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()); + } + }