aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-common/src/main/java/com/juick/server/CommandsManager.java3
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java3
2 files changed, 6 insertions, 0 deletions
diff --git a/juick-common/src/main/java/com/juick/server/CommandsManager.java b/juick-common/src/main/java/com/juick/server/CommandsManager.java
index 9ff0fdbb..b9f27940 100644
--- a/juick-common/src/main/java/com/juick/server/CommandsManager.java
+++ b/juick-common/src/main/java/com/juick/server/CommandsManager.java
@@ -308,6 +308,9 @@ public class CommandsManager {
public CommandResult commandSubscribeUser(User user, URI attachment, String... args) {
boolean subscribe = args[0].equalsIgnoreCase("s");
User toUser = userService.getUserByName(args[1]);
+ if (toUser.isAnonymous()) {
+ return CommandResult.fromString("User not found");
+ }
if (subscribe) {
if (subscriptionService.subscribeUser(user, toUser)) {
// TODO: already subscribed case
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index 0df39eb6..2c524eec 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -815,6 +815,9 @@ public class ServerTests {
assertThat(result.getNewMessage().get().getTags().size(), equalTo(2));
assertThat(result.getNewMessage().get().getTags().get(0).getName(), equalTo("Киев"));
assertThat(result.getNewMessage().get().getText(), equalTo(data));
+ result = commandsManager.processCommand(user, "S @unknown-user", emptyUri);
+ assertThat(result.getNewMessage(), is(Optional.empty()));
+ assertThat(result.getText(), is("User not found"));
}
@Test
public void mailParserTest() throws Exception {