From f8008abe5aaa21198f3dceb9901d48677e904ed3 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 7 Jun 2019 13:07:13 +0300 Subject: Telegram: do not add the same id to anonymous chats multiple times --- src/main/java/com/juick/server/www/controllers/SocialLogin.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/juick/server/www') diff --git a/src/main/java/com/juick/server/www/controllers/SocialLogin.java b/src/main/java/com/juick/server/www/controllers/SocialLogin.java index 8081c54b..e845247e 100644 --- a/src/main/java/com/juick/server/www/controllers/SocialLogin.java +++ b/src/main/java/com/juick/server/www/controllers/SocialLogin.java @@ -53,6 +53,7 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.ExecutionException; @@ -303,7 +304,11 @@ public class SocialLogin { return "redirect:/" + Utils.getPreviousPageByRequest(request).orElse(StringUtils.EMPTY); } else { String username = StringUtils.defaultString(params.get("username"), params.get("first_name")); - telegramService.createTelegramUser(tgUser, username); + List chats = telegramService.getAnonymous(); + if (!chats.contains(tgUser)) { + logger.info("added chat with {}", username); + telegramService.createTelegramUser(tgUser, username); + } return "redirect:/signup?type=durov&hash=" + userService.getSignUpHashByTelegramID(tgUser, username); } } else { -- cgit v1.2.3