aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r--src/main/java/com/juick/http/www/SignUp.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main/java/com/juick/http/www/SignUp.java b/src/main/java/com/juick/http/www/SignUp.java
index 2fae9b69..64b62e48 100644
--- a/src/main/java/com/juick/http/www/SignUp.java
+++ b/src/main/java/com/juick/http/www/SignUp.java
@@ -52,6 +52,8 @@ public class SignUp {
account = getVKNameByHash(sql, hash);
} else if (type.equals("xmpp")) {
account = getJIDByHash(sql, hash);
+ } else if (type.equals("durov")) {
+ account = getTelegramNameByHash(sql, hash);
}
if (account == null) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
@@ -73,6 +75,8 @@ public class SignUp {
out.print("<img src=\"//static.juick.com/settings/vk.png\" alt=\"VKontakte\"/>");
} else if (type.charAt(0) == 'x') {
out.print("<img src=\"//static.juick.com/settings/xmpp.png\" alt=\"XMPP\"/>");
+ } else if (type.charAt(0) == 'd') {
+ out.print("<img src=\"//telegram.org/favicon.ico?3\" alt=\"Telegram\"/>");
}
out.println(account + "</h1>");
@@ -144,6 +148,7 @@ public class SignUp {
if (!(type.charAt(0) == 'f' && setFacebookUser(sql, hash, uid))
&& !(type.charAt(0) == 'v' && setVKUser(sql, hash, uid))
+ && !(type.charAt(0) == 'd' && setTelegramUser(sql, hash, uid))
&& !(type.charAt(0) == 'x' && setJIDUser(sql, hash, uid))) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
@@ -167,6 +172,7 @@ public class SignUp {
if (!(type.charAt(0) == 'f' && setFacebookUser(sql, hash, uid))
&& !(type.charAt(0) == 'v' && setVKUser(sql, hash, uid))
+ && !(type.charAt(0) == 'd' && setTelegramUser(sql, hash, uid))
&& !(type.charAt(0) == 'x' && setJIDUser(sql, hash, uid))) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
@@ -235,6 +241,26 @@ public class SignUp {
return ret;
}
+ private String getTelegramNameByHash(Connection sql, String hash) {
+ String ret = null;
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT tg_name FROM telegram WHERE loginhash=?");
+ stmt.setString(1, hash);
+ rs = stmt.executeQuery();
+ if (rs.first()) {
+ ret = "<a href=\"https://telegram.me/" + rs.getString(1) + "\" rel=\"nofollow\">" + rs.getString(1) + "</a>";
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ return ret;
+ }
private boolean setFacebookUser(Connection sql, String hash, int uid) {
boolean ret = false;
@@ -290,6 +316,22 @@ public class SignUp {
}
return ret;
}
+ private boolean setTelegramUser(Connection sql, String hash, int uid) {
+ boolean ret = false;
+ PreparedStatement stmt = null;
+ try {
+ stmt = sql.prepareStatement("UPDATE telegram SET user_id=?,loginhash=NULL WHERE loginhash=?");
+ stmt.setInt(1, uid);
+ stmt.setString(2, hash);
+ stmt.executeUpdate();
+ ret = true;
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(null, stmt);
+ }
+ return ret;
+ }
private String getJIDByHash(Connection sql, String hash) {
String ret = null;