aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main')
-rw-r--r--juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java b/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java
index 06fbf2fc..5b1b55e4 100644
--- a/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java
+++ b/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java
@@ -354,15 +354,17 @@ public class JuickProtocol {
public ProtocolReply commandSubscribeMessage(User user, String... args) {
boolean subscribe = args[0].equalsIgnoreCase("s");
int mid = NumberUtils.toInt(args[1], 0);
- if (subscribe) {
- if (subscriptionService.subscribeMessage(mid, user.getUid())) {
- return new ProtocolReply("Subscribed");
- }
- } else {
- if (subscriptionService.unSubscribeMessage(mid, user.getUid())) {
- return new ProtocolReply("Unsubscribed from #" + mid);
+ if (messagesService.getMessage(mid) != null) {
+ if (subscribe) {
+ if (subscriptionService.subscribeMessage(mid, user.getUid())) {
+ return new ProtocolReply("Subscribed");
+ }
+ } else {
+ if (subscriptionService.unSubscribeMessage(mid, user.getUid())) {
+ return new ProtocolReply("Unsubscribed from #" + mid);
+ }
+ return new ProtocolReply("You was not subscribed to #" + mid);
}
- return new ProtocolReply("You was not subscribed to #" + mid);
}
return new ProtocolReply("Error");
}