aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/api/Notifications.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/server/api/Notifications.java')
-rw-r--r--src/main/java/com/juick/server/api/Notifications.java25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/main/java/com/juick/server/api/Notifications.java b/src/main/java/com/juick/server/api/Notifications.java
index 62275f5a..2971a07d 100644
--- a/src/main/java/com/juick/server/api/Notifications.java
+++ b/src/main/java/com/juick/server/api/Notifications.java
@@ -82,26 +82,23 @@ public class Notifications {
} else {
if (mid > 0) {
// reply
- Message msg = messagesService.getMessage(mid);
- if (msg != null) {
- List<User> users;
- if (rid > 0) {
- Message op = messagesService.getMessage(mid);
- Message reply = messagesService.getReply(mid, rid);
- users = subscriptionService.getUsersSubscribedToComments(op, reply);
- } else {
- users = subscriptionService.getSubscribedUsers(msg.getUser().getUid(), msg);
- }
-
- return ResponseEntity.ok(users.stream().map(User::getUid)
- .map(this::collectTokens).collect(Collectors.toList()));
+ Message msg = messagesService.getMessage(mid).orElseThrow(IllegalStateException::new);
+ List<User> users;
+ if (rid > 0) {
+ Message op = messagesService.getMessage(mid).orElseThrow(IllegalStateException::new);
+ Message reply = messagesService.getReply(mid, rid);
+ users = subscriptionService.getUsersSubscribedToComments(op, reply);
+ } else {
+ users = subscriptionService.getSubscribedUsers(msg.getUser().getUid(), msg);
}
+
+ return ResponseEntity.ok(users.stream().map(User::getUid)
+ .map(this::collectTokens).collect(Collectors.toList()));
} else {
// read
return ResponseEntity.ok(Collections.singletonList(collectTokens(uid)));
}
}
- throw new HttpBadRequestException();
}
@ApiIgnore