aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/juick/server/www/controllers/SignUp.java12
-rw-r--r--src/main/java/com/juick/service/MessengerService.java14
-rw-r--r--src/main/java/com/juick/service/MessengerServiceImpl.java71
3 files changed, 2 insertions, 95 deletions
diff --git a/src/main/java/com/juick/server/www/controllers/SignUp.java b/src/main/java/com/juick/server/www/controllers/SignUp.java
index eac1c767..e4ea6958 100644
--- a/src/main/java/com/juick/server/www/controllers/SignUp.java
+++ b/src/main/java/com/juick/server/www/controllers/SignUp.java
@@ -22,7 +22,6 @@ import com.juick.server.util.UserUtils;
import com.juick.server.www.WebApp;
import com.juick.service.CrosspostService;
import com.juick.service.EmailService;
-import com.juick.service.MessengerService;
import com.juick.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@@ -46,8 +45,6 @@ public class SignUp {
@Inject
private CrosspostService crosspostService;
@Inject
- private MessengerService messengerService;
- @Inject
private EmailService emailService;
@Inject
private WebApp webApp;
@@ -76,9 +73,6 @@ public class SignUp {
case "durov":
account = crosspostService.getTelegramNameByHash(hash);
break;
- case "messenger":
- account = messengerService.getDisplayName(hash);
- break;
case "email":
account = emailService.getEmailByAuthCode(hash);
}
@@ -128,8 +122,7 @@ 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' && userService.getAllJIDs(visitor).size() > 0 && crosspostService.setJIDUser(hash, uid))
- && !(type.charAt(0) == 'm' && messengerService.linkMessengerUser(hash, uid))) {
+ && !(type.charAt(0) == 'x' && userService.getAllJIDs(visitor).size() > 0 && crosspostService.setJIDUser(hash, uid))) {
if (type.equals("email")) {
String email = emailService.getEmailByAuthCode(hash);
emailService.addEmail(uid, email);
@@ -153,8 +146,7 @@ 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) == 'm' && messengerService.linkMessengerUser(hash, uid))) {
+ && !(type.charAt(0) == 'd' && crosspostService.setTelegramUser(hash, uid))) {
if (type.equals("email")) {
String email = emailService.getEmailByAuthCode(hash);
emailService.addEmail(uid, email);
diff --git a/src/main/java/com/juick/service/MessengerService.java b/src/main/java/com/juick/service/MessengerService.java
deleted file mode 100644
index e07c73fe..00000000
--- a/src/main/java/com/juick/service/MessengerService.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.juick.service;
-
-import com.juick.User;
-
-import java.util.Optional;
-
-public interface MessengerService {
- Integer getUserId(String senderId);
- Optional<String> getSenderId(User user);
- boolean createMessengerUser(String senderId, String displayName);
- String getDisplayName(String hash);
- String getSignUpHash(String senderId, String username);
- boolean linkMessengerUser(String hash, int uid);
-}
diff --git a/src/main/java/com/juick/service/MessengerServiceImpl.java b/src/main/java/com/juick/service/MessengerServiceImpl.java
deleted file mode 100644
index 57101ffe..00000000
--- a/src/main/java/com/juick/service/MessengerServiceImpl.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.juick.service;
-
-import com.juick.User;
-import org.springframework.dao.EmptyResultDataAccessException;
-import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.UUID;
-
-@Repository
-public class MessengerServiceImpl extends BaseJdbcService implements MessengerService {
-
- @Transactional(readOnly = true)
- @Override
- public Integer getUserId(String senderId) {
- List<Integer> list = getJdbcTemplate().queryForList(
- "SELECT id FROM users INNER JOIN messenger " +
- "ON messenger.user_id = users.id WHERE messenger.sender_id=?", Integer.class, senderId);
-
- return list.isEmpty() ? 0 : list.get(0);
- }
- @Transactional(readOnly = true)
- @Override
- public Optional<String> getSenderId(User user) {
- List<String> list = getJdbcTemplate().queryForList(
- "SELECT sender_id FROM messenger " +
- "WHERE user_id=?", String.class, user.getUid());
-
- return list.isEmpty() ? Optional.empty() : Optional.of(list.get(0));
- }
-
- @Transactional
- @Override
- public boolean createMessengerUser(String senderId, String displayName) {
- return getJdbcTemplate().update(
- "INSERT INTO messenger(sender_id, display_name, loginhash) VALUES(?,?,?)",
- senderId, displayName, UUID.randomUUID().toString()) > 0;
- }
- @Transactional(readOnly = true)
- @Override
- public String getDisplayName(String hash) {
- try {
- return getJdbcTemplate().queryForObject("SELECT display_name FROM messenger WHERE loginhash=?", String.class, hash);
- } catch (EmptyResultDataAccessException e) {
- return null;
- }
- }
- @Transactional
- @Override
- public String getSignUpHash(final String senderId, final String username) {
- List<String> list = getJdbcTemplate().queryForList(
- "SELECT loginhash FROM messenger WHERE sender_id = ? AND user_id IS NULL",
- String.class,
- senderId);
-
- if (list.isEmpty()) {
- String hash = UUID.randomUUID().toString();
- getJdbcTemplate().update(
- "INSERT INTO messenger(sender_id, loginhash, display_name) VALUES (?, ?, ?)", senderId, hash, username);
- return hash;
- }
- return list.get(0);
- }
- @Transactional
- @Override
- public boolean linkMessengerUser(String hash, int uid) {
- return getJdbcTemplate().update("UPDATE messenger SET user_id=?, loginhash=NULL WHERE loginhash=?", uid, hash) > 0;
- }
-}