aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2021-08-26 14:28:06 +0300
committerGravatar Vitaly Takmazov2021-08-26 14:28:06 +0300
commit084917b0a517c7e6b97e63c383580d1068634175 (patch)
tree006b9a120909fcc6093c602930902864e56fd94d /src/main
parent017186244e4b5936ccabd28047af080520aa132d (diff)
Fix notifications endpoint flow
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/juick/www/api/Notifications.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main/java/com/juick/www/api/Notifications.java b/src/main/java/com/juick/www/api/Notifications.java
index 76bb4380..524e4da4 100644
--- a/src/main/java/com/juick/www/api/Notifications.java
+++ b/src/main/java/com/juick/www/api/Notifications.java
@@ -30,6 +30,8 @@ import com.juick.service.TelegramService;
import com.juick.service.UserService;
import com.juick.service.security.annotation.Visitor;
import io.swagger.v3.oas.annotations.Hidden;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@@ -50,7 +52,8 @@ import java.util.stream.Collectors;
*/
@RestController
public class Notifications {
-
+ private static final Logger logger = LoggerFactory.getLogger("www");
+
@Inject
private PushQueriesService pushQueriesService;
@Inject
@@ -64,7 +67,6 @@ public class Notifications {
@Value("${api_user:juick}")
private String serviceUser;
-
private User collectTokens(Integer uid) {
User user = userService.getUserByUID(uid).orElse(AnonymousUser.INSTANCE);
user.setUnreadCount(messagesService.getUnread(user).size());
@@ -99,11 +101,15 @@ public class Notifications {
if (mid > 0) {
// reply
Message msg = messagesService.getMessage(mid).orElseThrow(IllegalStateException::new);
- List<User> users;
+ List<User> users = Collections.emptyList();
if (rid > 0) {
Message op = messagesService.getMessage(mid).orElseThrow(IllegalStateException::new);
Message reply = messagesService.getReply(mid, rid);
- users = subscriptionService.getUsersSubscribedToComments(op, reply);
+ if (reply != null) {
+ users = subscriptionService.getUsersSubscribedToComments(op, reply);
+ } else {
+ logger.warn("Reply not found: {}/{}", mid, rid);
+ }
} else {
users = subscriptionService.getSubscribedUsers(msg.getUser().getUid(), msg);
}