From 61a28570ca25ae789cca09736ddc427e172ac213 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 29 Aug 2018 15:10:51 +0300 Subject: getUserByName is non nullable --- juick-common/src/main/java/com/juick/server/CommandsManager.java | 4 ++-- juick-common/src/main/java/com/juick/service/UserService.java | 2 +- .../main/java/com/juick/service/security/JuickUserDetailsService.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'juick-common/src/main/java') 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 58c07255..50cdb202 100644 --- a/juick-common/src/main/java/com/juick/server/CommandsManager.java +++ b/juick-common/src/main/java/com/juick/server/CommandsManager.java @@ -229,7 +229,7 @@ public class CommandsManager { help = "BL @username - add @username to your blacklist") public CommandResult blacklistUser(User user_from, URI attachment, String... arguments) { User blUser = userService.getUserByName(arguments[0]); - if (blUser != null) { + if (!blUser.isAnonymous()) { PrivacyQueriesService.PrivacyResult result = privacyQueriesService.blacklistUser(user_from, blUser); if (result == PrivacyQueriesService.PrivacyResult.Added) { return CommandResult.fromString("User added to your blacklist"); @@ -243,7 +243,7 @@ public class CommandsManager { help = "BL *tag - add *tag to your blacklist") public CommandResult blacklistTag(User user_from, URI attachment, String... arguments) { User blUser = userService.getUserByName(arguments[0]); - if (blUser != null) { + if (!blUser.isAnonymous()) { Tag tag = tagService.getTag(arguments[0], false); if (tag != null) { PrivacyQueriesService.PrivacyResult result = privacyQueriesService.blacklistTag(user_from, tag); diff --git a/juick-common/src/main/java/com/juick/service/UserService.java b/juick-common/src/main/java/com/juick/service/UserService.java index ef49a8ab..cfeaaa51 100644 --- a/juick-common/src/main/java/com/juick/service/UserService.java +++ b/juick-common/src/main/java/com/juick/service/UserService.java @@ -44,7 +44,7 @@ public interface UserService { Optional getUserByUID(int uid); - User getUserByName(String username); + @Nonnull User getUserByName(String username); User getUserByEmail(String email); diff --git a/juick-common/src/main/java/com/juick/service/security/JuickUserDetailsService.java b/juick-common/src/main/java/com/juick/service/security/JuickUserDetailsService.java index adb0ab44..59425fab 100644 --- a/juick-common/src/main/java/com/juick/service/security/JuickUserDetailsService.java +++ b/juick-common/src/main/java/com/juick/service/security/JuickUserDetailsService.java @@ -43,7 +43,7 @@ public class JuickUserDetailsService implements UserDetailsService { com.juick.User user = userService.getUserByName(username); - if (user != null) { + if (!user.isAnonymous()) { user.setAuthHash(userService.getHashByUID(user.getUid())); return new JuickUser(user); } -- cgit v1.2.3