From 6f85b661374ea0f3320dcff966fa7d76762ce742 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 11 May 2018 13:14:40 +0300 Subject: AnonymousUser.INSTANCE where possible --- juick-server/src/main/java/com/juick/server/MessengerManager.java | 3 ++- juick-server/src/main/java/com/juick/server/TelegramBotManager.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'juick-server/src/main/java/com') 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 { 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 chats = telegramService.getChats(); -- cgit v1.2.3