From 9ad08dc78e0cdbe2cdebf10a96c800e72d48e48b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 22 Jan 2023 14:14:58 +0300 Subject: Refactor messages service, remove 2 unneeded SQL queries --- src/main/java/com/juick/www/api/Post.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/com/juick/www/api') diff --git a/src/main/java/com/juick/www/api/Post.java b/src/main/java/com/juick/www/api/Post.java index 97311c21..4f1c2cad 100644 --- a/src/main/java/com/juick/www/api/Post.java +++ b/src/main/java/com/juick/www/api/Post.java @@ -224,7 +224,7 @@ public class Post { @RequestParam Integer mid, @RequestParam(required = false, defaultValue = "0") Integer rid, @RequestParam String body) { - User author = rid == 0 ? messagesService.getMessageAuthor(mid) : messagesService.getReply(mid, rid).getUser(); + User author = rid == 0 ? messagesService.getMessage(mid).orElseThrow(HttpBadRequestException::new).getUser() : messagesService.getReply(mid, rid).getUser(); if (visitor.equals(author)) { if (messagesService.updateMessage(mid, rid, body, false)) { Message result = rid == 0 ? -- cgit v1.2.3