aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/XMPPConnection.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-11-20 00:07:06 +0300
committerGravatar Vitaly Takmazov2018-11-20 00:07:06 +0300
commit930e6ab6d604963ae6a48c58fc1bd3735071d9ee (patch)
treebb236bf36ccab695bef4d45012135c2396c84f77 /src/main/java/com/juick/server/XMPPConnection.java
parent74740d5d989f11746266a994840f89e9f6784f73 (diff)
getMessage refactoring
Diffstat (limited to 'src/main/java/com/juick/server/XMPPConnection.java')
-rw-r--r--src/main/java/com/juick/server/XMPPConnection.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main/java/com/juick/server/XMPPConnection.java b/src/main/java/com/juick/server/XMPPConnection.java
index 5ea105af..0adc7796 100644
--- a/src/main/java/com/juick/server/XMPPConnection.java
+++ b/src/main/java/com/juick/server/XMPPConnection.java
@@ -288,7 +288,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
for (User user : users) {
jids.addAll(userService.getJIDsbyUID(user.getUid()));
}
- com.juick.Message fullMsg = messagesService.getMessage(jmsg.getMid());
+ com.juick.Message fullMsg = messagesService.getMessage(jmsg.getMid()).orElseThrow(IllegalStateException::new);
String txt = "@" + jmsg.getUser().getName() + ":" + MessageUtils.getTagsString(fullMsg) + "\n";
String attachmentUrl = MessageUtils.attachmentUrl(fullMsg);
if (StringUtils.isNotEmpty(attachmentUrl)) {
@@ -325,7 +325,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
String replyTo;
com.juick.Message replyMessage = jmsg.getReplyto() > 0 ? messagesService.getReply(jmsg.getMid(), jmsg.getReplyto())
- : messagesService.getMessage(jmsg.getMid());
+ : messagesService.getMessage(jmsg.getMid()).orElseThrow(IllegalStateException::new);
replyTo = replyMessage.getUser().getName();
com.juick.Message fullReply = messagesService.getReply(jmsg.getMid(), jmsg.getRid());
replyQuote = StringUtils.defaultString(fullReply.getReplyQuote());
@@ -594,13 +594,14 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
if (jmsg != null) {
if (MessageUtils.isReply(jmsg)) {
// to get quote and attachment
- com.juick.Message original = messagesService.getMessage(jmsg.getMid());
+ com.juick.Message original = messagesService.getMessage(jmsg.getMid()).orElseThrow(IllegalStateException::new);
com.juick.Message reply = messagesService.getReply(jmsg.getMid(), jmsg.getRid());
applicationEventPublisher.publishEvent(new MessageEvent(this, reply,
subscriptionService.getUsersSubscribedToComments(original, reply)));
} else if (!MessageUtils.isPM(jmsg)) {
applicationEventPublisher.publishEvent(new MessageEvent(this,
- messagesService.getMessage(jmsg.getMid()), subscriptionService.getSubscribedUsers(jmsg.getUser().getUid(), jmsg)));
+ messagesService.getMessage(jmsg.getMid()).orElseThrow(IllegalStateException::new),
+ subscriptionService.getSubscribedUsers(jmsg.getUser().getUid(), jmsg)));
}
} else {
URI attachment = URI.create(StringUtils.EMPTY);