aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick')
-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);
}