diff options
author | Vitaly Takmazov | 2019-06-07 13:07:13 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-06-07 13:07:13 +0300 |
commit | f8008abe5aaa21198f3dceb9901d48677e904ed3 (patch) | |
tree | c249730e616719ca648f20cef7ce8db700545047 /src/main/java/com/juick/server/www | |
parent | 42a6528ee008bc5940f4c74587a316c37265721a (diff) |
Telegram: do not add the same id to anonymous chats multiple times
Diffstat (limited to 'src/main/java/com/juick/server/www')
-rw-r--r-- | src/main/java/com/juick/server/www/controllers/SocialLogin.java | 7 |
1 files changed, 6 insertions, 1 deletions
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<Long> 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 { |