From bf5f2142d73a5745124d03f6b6f06c59873e47de Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 27 Dec 2017 16:23:28 +0300 Subject: Messenger bot --- .../src/main/java/com/juick/www/controllers/NewMessage.java | 2 +- .../src/main/java/com/juick/www/controllers/SignUp.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'juick-www/src/main/java/com') diff --git a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java index d188dfbe..9e022557 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java +++ b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java @@ -190,7 +190,7 @@ public class NewMessage { sharetwi += " http://juick.com/" + mid; model.addAttribute("sharetwi", sharetwi); } - if (!crosspostService.getFacebookToken(visitor.getUid()).isPresent()) { + if (!crosspostService.getFacebookTokens(visitor.getUid()).isPresent()) { model.addAttribute("facebook", 1); } model.addAttribute("tags", tagService.getUserTagStats(visitor.getUid()).stream() diff --git a/juick-www/src/main/java/com/juick/www/controllers/SignUp.java b/juick-www/src/main/java/com/juick/www/controllers/SignUp.java index c8c64ef5..a5851215 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/SignUp.java +++ b/juick-www/src/main/java/com/juick/www/controllers/SignUp.java @@ -20,6 +20,7 @@ import com.juick.server.util.HttpBadRequestException; import com.juick.server.util.HttpForbiddenException; import com.juick.server.util.UserUtils; import com.juick.service.CrosspostService; +import com.juick.service.MessengerService; import com.juick.service.UserService; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; @@ -42,6 +43,8 @@ public class SignUp { private UserService userService; @Inject private CrosspostService crosspostService; + @Inject + private MessengerService messengerService; @GetMapping("/signup") @@ -67,6 +70,9 @@ public class SignUp { case "durov": account = crosspostService.getTelegramNameByHash(hash); break; + case "messenger": + account = messengerService.getDisplayName(hash); + break; } if (account == null) { throw new HttpBadRequestException(); @@ -113,7 +119,8 @@ public class SignUp { if (!(type.charAt(0) == 'f' && crosspostService.setFacebookUser(hash, uid)) && !(type.charAt(0) == 'v' && crosspostService.setVKUser(hash, uid)) && !(type.charAt(0) == 'd' && crosspostService.setTelegramUser(hash, uid)) - && !(type.charAt(0) == 'x' && crosspostService.setJIDUser(hash, uid))) { + && !(type.charAt(0) == 'x' && crosspostService.setJIDUser(hash, uid)) + && !(type.charAt(0) == 'm' && messengerService.linkMessengerUser(hash, uid))) { throw new HttpBadRequestException(); } @@ -132,7 +139,8 @@ public class SignUp { if (!(type.charAt(0) == 'f' && crosspostService.setFacebookUser(hash, uid)) && !(type.charAt(0) == 'v' && crosspostService.setVKUser(hash, uid)) && !(type.charAt(0) == 'd' && crosspostService.setTelegramUser(hash, uid)) - && !(type.charAt(0) == 'x' && crosspostService.setJIDUser(hash, uid))) { + && !(type.charAt(0) == 'x' && crosspostService.setJIDUser(hash, uid)) + && !(type.charAt(0) == 'm' && messengerService.linkMessengerUser(hash, uid))) { throw new HttpBadRequestException(); } } -- cgit v1.2.3