Expose Link class.
[Sone.git] / src / main / java / net / pterodactylus / sone / template / ProfileAccessor.java
index f072041..9b0a7fc 100644 (file)
@@ -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;
@@ -69,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. */
@@ -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());
+       }
+
 }