aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-05-11 13:14:40 +0300
committerGravatar Vitaly Takmazov2018-05-11 13:14:40 +0300
commit6f85b661374ea0f3320dcff966fa7d76762ce742 (patch)
treec5d4757e8e82ba708211b3edc3d21943ce762552 /juick-server/src/main/java/com
parent007f78c1712e0dc1402c85914e40e9752deaae73 (diff)
AnonymousUser.INSTANCE where possible
Diffstat (limited to 'juick-server/src/main/java/com')
-rw-r--r--juick-server/src/main/java/com/juick/server/MessengerManager.java3
-rw-r--r--juick-server/src/main/java/com/juick/server/TelegramBotManager.java3
2 files changed, 4 insertions, 2 deletions
diff --git a/juick-server/src/main/java/com/juick/server/MessengerManager.java b/juick-server/src/main/java/com/juick/server/MessengerManager.java
index 303e08ce..8bfcafd0 100644
--- a/juick-server/src/main/java/com/juick/server/MessengerManager.java
+++ b/juick-server/src/main/java/com/juick/server/MessengerManager.java
@@ -15,6 +15,7 @@ import com.github.messenger4j.webhook.event.TextMessageEvent;
import com.juick.Message;
import com.juick.User;
import com.juick.server.component.MessageEvent;
+import com.juick.server.helpers.AnonymousUser;
import com.juick.service.MessagesService;
import com.juick.service.MessengerService;
import com.juick.service.SubscriptionService;
@@ -76,7 +77,7 @@ public class MessengerManager implements ApplicationListener<MessageEvent> {
final String senderId = event.senderId();
final Instant timestamp = event.timestamp();
- User user_from = userService.getUserByUID(messengerService.getUserId(senderId)).orElse(new User());
+ User user_from = userService.getUserByUID(messengerService.getUserId(senderId)).orElse(AnonymousUser.INSTANCE);
logger.info("Found juick user {}", user_from.getUid());
if (user_from.isAnonymous()) {
try {
diff --git a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
index c9097cb2..6e6198a8 100644
--- a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
+++ b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
@@ -19,6 +19,7 @@ package com.juick.server;
import com.juick.User;
import com.juick.server.component.*;
+import com.juick.server.helpers.AnonymousUser;
import com.juick.server.helpers.CommandResult;
import com.juick.server.util.HttpUtils;
import com.juick.service.MessagesService;
@@ -113,7 +114,7 @@ public class TelegramBotManager implements NotificationListener {
return;
}
}
- User user_from = userService.getUserByUID(telegramService.getUser(message.chat().id())).orElse(new User());
+ User user_from = userService.getUserByUID(telegramService.getUser(message.chat().id())).orElse(AnonymousUser.INSTANCE);
logger.info("Found juick user {}", user_from.getUid());
List<Long> chats = telegramService.getChats();