- if ("fields".equals(member)) {
- Map<String, String> fields = new LinkedHashMap<String, String>();
- for (String field : profile.getFields()) {
- fields.put(field, profile.getField(field));
+ if ("avatar".equals(member)) {
+ Sone currentSone = (Sone) templateContext.get("currentSone");
+ if (currentSone == null) {
+ /* not logged in? donāt show custom avatars, then. */
+ return null;
+ }
+ String avatarId = profile.getAvatar();
+ if (avatarId == null) {
+ return null;
+ }
+ if (core.getImage(avatarId, false) == null) {
+ /* avatar ID but no matching image? show nothing. */
+ return null;
+ }
+ Sone remoteSone = profile.getSone();
+ if (remoteSone.isLocal()) {
+ /* always show your own avatars. */
+ return avatarId;
+ }
+ LoadExternalContent showCustomAvatars = currentSone.getOptions().getShowCustomAvatars();
+ if (showCustomAvatars == LoadExternalContent.NEVER) {
+ return null;
+ }
+ if (showCustomAvatars == LoadExternalContent.ALWAYS) {
+ return avatarId;
+ }
+ if (showCustomAvatars == LoadExternalContent.FOLLOWED) {
+ return currentSone.hasFriend(remoteSone.getId()) ? avatarId : null;
+ }
+ Trust trust = remoteSone.getIdentity().getTrust((OwnIdentity) currentSone.getIdentity());
+ if (trust == null) {
+ return null;
+ }
+ if ((showCustomAvatars == LoadExternalContent.MANUALLY_TRUSTED) && (trust.getExplicit() != null) && (trust.getExplicit() > 0)) {
+ return avatarId;
+ }
+ if ((showCustomAvatars == LoadExternalContent.TRUSTED) && (((trust.getExplicit() != null) && (trust.getExplicit() > 0)) || ((trust.getImplicit() != null) && (trust.getImplicit() > 0)))) {
+ return avatarId;