Add unit test for IdentityAccessor.
[Sone.git] / src / main / java / net / pterodactylus / sone / template / ProfileAccessor.java
index d215c82..9b0a7fc 100644 (file)
@@ -66,6 +66,9 @@ public class ProfileAccessor extends ReflectionAccessor {
                                /* 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. */
@@ -96,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());
+       }
+
 }