From abecbe6d9c9016bd40cb97d7c4206e1a4cc15c41 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 26 Apr 2023 08:35:39 +0300 Subject: API: include hidden messages --- src/main/java/com/juick/www/api/Messages.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/main/java/com/juick') diff --git a/src/main/java/com/juick/www/api/Messages.java b/src/main/java/com/juick/www/api/Messages.java index d127d166..c9936dee 100644 --- a/src/main/java/com/juick/www/api/Messages.java +++ b/src/main/java/com/juick/www/api/Messages.java @@ -91,25 +91,33 @@ public class Messages { List mids; if (StringUtils.hasText(uname)) { User user = userService.getUserByName(uname); + int privacy = 0; + if (!visitor.isAnonymous()) { + if (user.getUid() == visitor.getUid() || visitor.getUid() == 1) { + privacy = -3; + } else if (userService.isInWL(user.getUid(), visitor.getUid())) { + privacy = -2; + } + } if (!user.isAnonymous() && !user.isBanned()) { if (StringUtils.hasText(media)) { - mids = messagesService.getUserPhotos(user.getUid(), 0, before); + mids = messagesService.getUserPhotos(user.getUid(), privacy, before); } else if (StringUtils.hasText(tag)) { Tag tagObject = tagService.getTag(tag, false); if (tagObject != null) { - mids = messagesService.getUserTag(user.getUid(), tagObject.getId(), 0, before); + mids = messagesService.getUserTag(user.getUid(), tagObject.getId(), privacy, before); } else { throw new HttpNotFoundException(); } } else if (StringUtils.hasText(withrecommended)) { - mids = messagesService.getUserBlogWithRecommendations(user, visitor, 0, before); + mids = messagesService.getUserBlogWithRecommendations(user, visitor, privacy, before); } else if (daysback > 0) { - mids = messagesService.getUserBlogAtDay(user.getUid(), 0, daysback); + mids = messagesService.getUserBlogAtDay(user.getUid(), privacy, daysback); } else if (StringUtils.hasText(search)) { - mids = messagesService.getUserSearch(visitor, user.getUid(), search, 0, + mids = messagesService.getUserSearch(visitor, user.getUid(), search, privacy, page); } else { - mids = messagesService.getUserBlog(user.getUid(), 0, before); + mids = messagesService.getUserBlog(user.getUid(), privacy, before); } } else { throw new HttpNotFoundException(); -- cgit v1.2.3