aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-api/src/main/java/com/juick/api/Main.java12
-rw-r--r--juick-api/src/main/java/com/juick/api/Messages.java8
-rw-r--r--juick-api/src/main/java/com/juick/api/Notifications.java10
-rw-r--r--juick-api/src/main/java/com/juick/api/PM.java4
-rw-r--r--juick-api/src/main/java/com/juick/api/Subscriptions.java4
-rw-r--r--juick-api/src/main/java/com/juick/api/TelegramBotHook.java16
-rw-r--r--juick-api/src/main/java/com/juick/api/Users.java8
-rw-r--r--juick-core/src/main/java/com/juick/Message.java119
-rw-r--r--juick-core/src/main/java/com/juick/Tag.java17
-rw-r--r--juick-core/src/main/java/com/juick/User.java57
-rw-r--r--juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java12
-rw-r--r--juick-core/src/main/java/com/juick/json/MessageSerializer.java26
-rw-r--r--juick-core/src/main/java/com/juick/json/UserSerializer.java12
-rw-r--r--juick-core/src/main/java/com/juick/package-info.java16
-rw-r--r--juick-core/src/main/java/com/juick/xml/adapters/SimpleDateAdapter.java35
-rw-r--r--juick-core/src/main/java/com/juick/xmpp/extensions/JuickMessage.java36
-rw-r--r--juick-core/src/main/java/com/juick/xmpp/extensions/JuickUser.java12
-rw-r--r--juick-crosspost/src/main/java/com/juick/components/Crosspost.java24
-rw-r--r--juick-demo/src/main/java/com/juick/demo/Demo.java2
-rw-r--r--juick-notifications/src/main/java/com/juick/components/Notifications.java26
-rw-r--r--juick-rss/src/main/java/com/juick/rss/Main.java30
-rw-r--r--juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java14
-rw-r--r--juick-ws/src/main/java/com/juick/ws/XMPPConnection.java36
-rw-r--r--juick-www/src/main/java/com/juick/www/Discover.java4
-rw-r--r--juick-www/src/main/java/com/juick/www/Home.java24
-rw-r--r--juick-www/src/main/java/com/juick/www/Login.java6
-rw-r--r--juick-www/src/main/java/com/juick/www/Main.java26
-rw-r--r--juick-www/src/main/java/com/juick/www/NewMessage.java34
-rw-r--r--juick-www/src/main/java/com/juick/www/PM.java14
-rw-r--r--juick-www/src/main/java/com/juick/www/PageTemplates.java54
-rw-r--r--juick-www/src/main/java/com/juick/www/Settings.java54
-rw-r--r--juick-www/src/main/java/com/juick/www/SignUp.java4
-rw-r--r--juick-www/src/main/java/com/juick/www/TwitterAuth.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/User.java104
-rw-r--r--juick-www/src/main/java/com/juick/www/UserThread.java134
-rw-r--r--juick-www/src/main/java/com/juick/www/Utils.java4
-rw-r--r--juick-www/src/main/resources/views/pm_inbox.html8
-rw-r--r--juick-www/src/main/resources/views/pm_sent.html6
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java52
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java28
-rw-r--r--server-core/src/main/java/com/juick/server/MessagesQueries.java32
-rw-r--r--server-core/src/main/java/com/juick/server/PMQueries.java14
-rw-r--r--server-core/src/main/java/com/juick/server/PrivacyQueries.java8
-rw-r--r--server-core/src/main/java/com/juick/server/ShowQueries.java2
-rw-r--r--server-core/src/main/java/com/juick/server/SubscriptionsQueries.java20
-rw-r--r--server-core/src/main/java/com/juick/server/UserQueries.java52
-rw-r--r--server-core/src/main/java/com/juick/server/protocol/JuickProtocol.java48
-rw-r--r--server-core/src/main/java/com/juick/service/MessagesServiceImpl.java32
-rw-r--r--server-core/src/main/java/com/juick/service/PMQueriesServiceImpl.java14
-rw-r--r--server-core/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java12
-rw-r--r--server-core/src/main/java/com/juick/service/ShowQueriesServiceImpl.java8
-rw-r--r--server-core/src/main/java/com/juick/service/SubscriptionServiceImpl.java20
-rw-r--r--server-core/src/main/java/com/juick/service/UserServiceImpl.java52
-rw-r--r--src/test/java/com/juick/tests/ApiTests.java34
-rw-r--r--src/test/java/com/juick/tests/MessageTests.java6
-rw-r--r--src/test/java/com/juick/tests/SerializationTests.java (renamed from src/test/java/com/juick/tests/JsonTests.java)42
56 files changed, 825 insertions, 665 deletions
diff --git a/juick-api/src/main/java/com/juick/api/Main.java b/juick-api/src/main/java/com/juick/api/Main.java
index 80cbecd4..c102bf18 100644
--- a/juick-api/src/main/java/com/juick/api/Main.java
+++ b/juick-api/src/main/java/com/juick/api/Main.java
@@ -308,7 +308,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
xmsg.addChild(jmsg);
Nickname nick = new Nickname();
- nick.Nickname = "@" + jmsg.getUser().getUName();
+ nick.Nickname = "@" + jmsg.getUser().getName();
xmsg.addChild(nick);
if (attachmentFName != null) {
@@ -334,7 +334,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
for (String tag : tagsArr) {
tagsStr2 += " *" + tag;
}
- xmsg.body = "@" + jmsg.getUser().getUName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid;
+ xmsg.body = "@" + jmsg.getUser().getName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid;
xmsg.to = new JID("juick", "s2s.juick.com", null);
xmpp.send(xmsg);
@@ -391,8 +391,8 @@ public class Main extends HttpServlet implements Stream.StreamListener {
}
body = body.replace("\r", "");
- if ((msg.ReadOnly && msg.getUser().getUID() != vuid) || UserQueries.isInBLAny(sql, msg.getUser().getUID(), vuid)
- || (reply != null && UserQueries.isInBLAny(sql, reply.getUser().getUID(), vuid))) {
+ if ((msg.ReadOnly && msg.getUser().getUid() != vuid) || UserQueries.isInBLAny(sql, msg.getUser().getUid(), vuid)
+ || (reply != null && UserQueries.isInBLAny(sql, reply.getUser().getUid(), vuid))) {
response.sendError(403);
return;
}
@@ -436,7 +436,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
}
Nickname nick = new Nickname();
- nick.Nickname = "@" + jmsg.getUser().getUName();
+ nick.Nickname = "@" + jmsg.getUser().getName();
xmsg.addChild(nick);
if (attachmentFName != null) {
@@ -458,7 +458,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
xmsg.addChild(xoob);
}
- xmsg.body = "Reply by @" + jmsg.getUser().getUName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew;
+ xmsg.body = "Reply by @" + jmsg.getUser().getName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew;
xmsg.to = new JID("juick", "s2s.juick.com", null);
xmpp.send(xmsg);
diff --git a/juick-api/src/main/java/com/juick/api/Messages.java b/juick-api/src/main/java/com/juick/api/Messages.java
index d9d506f3..de845d45 100644
--- a/juick-api/src/main/java/com/juick/api/Messages.java
+++ b/juick-api/src/main/java/com/juick/api/Messages.java
@@ -71,16 +71,16 @@ public class Messages {
User user = UserQueries.getUserByName(sql, uname);
if (user != null) {
if (!StringUtils.isEmpty(media)) {
- mids = MessagesQueries.getUserPhotos(sql, user.getUID(), 0, before_mid);
+ mids = MessagesQueries.getUserPhotos(sql, user.getUid(), 0, before_mid);
} else if (!StringUtils.isEmpty(tag)) {
Tag tagObject = TagQueries.getTag(sql, tag, false);
if (tagObject != null) {
- mids = MessagesQueries.getUserTag(sql, user.getUID(), tagObject.TID, 0, before_mid);
+ mids = MessagesQueries.getUserTag(sql, user.getUid(), tagObject.TID, 0, before_mid);
} else {
response.sendError(404);
}
} else {
- mids = MessagesQueries.getUserBlog(sql, user.getUID(), 0, before_mid);
+ mids = MessagesQueries.getUserBlog(sql, user.getUid(), 0, before_mid);
}
} else {
response.sendError(404);
@@ -144,7 +144,7 @@ public class Messages {
throws ServletException, IOException {
int mid = NumberUtils.toInt(request.getParameter("mid"), 0);
com.juick.User user = MessagesQueries.getMessageAuthor(sql, mid);
- if (user != null && user.getUID() == vuid && MessagesQueries.setMessagePrivacy(sql, mid)) {
+ if (user != null && user.getUid() == vuid && MessagesQueries.setMessagePrivacy(sql, mid)) {
Main.replyJSON(request, response, "{\"status\":\"ok\"}");
} else {
response.sendError(400);
diff --git a/juick-api/src/main/java/com/juick/api/Notifications.java b/juick-api/src/main/java/com/juick/api/Notifications.java
index bec365ba..60fe95f3 100644
--- a/juick-api/src/main/java/com/juick/api/Notifications.java
+++ b/juick-api/src/main/java/com/juick/api/Notifications.java
@@ -29,7 +29,7 @@ public class Notifications {
public void doGet(HttpServletRequest request, HttpServletResponse response, int vuid) throws IOException {
User visitor = UserQueries.getUserByUID(jdbc, vuid).orElse(new User());
- if ((visitor.getUID() == 0) || !(visitor.getUName().equals("juick"))) {
+ if ((visitor.getUid() == 0) || !(visitor.getName().equals("juick"))) {
response.sendError(403);
return;
}
@@ -57,13 +57,13 @@ public class Notifications {
Message msg = MessagesQueries.getMessage(jdbc, mid);
if (msg != null) {
List<User> users;
- if (msg.getRID() > 0) {
- users = SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, msg.getUser().getUID());
+ if (msg.getRid() > 0) {
+ users = SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, msg.getUser().getUid());
} else {
- users = SubscriptionsQueries.getSubscribedUsers(jdbc, msg.getUser().getUID(), mid);
+ users = SubscriptionsQueries.getSubscribedUsers(jdbc, msg.getUser().getUid(), mid);
}
- List<Integer> uids = users.stream().map(User::getUID).collect(Collectors.toList());
+ List<Integer> uids = users.stream().map(User::getUid).collect(Collectors.toList());
switch (type) {
case "gcm":
diff --git a/juick-api/src/main/java/com/juick/api/PM.java b/juick-api/src/main/java/com/juick/api/PM.java
index 44c43f89..d8f17366 100644
--- a/juick-api/src/main/java/com/juick/api/PM.java
+++ b/juick-api/src/main/java/com/juick/api/PM.java
@@ -94,11 +94,11 @@ public class PM {
mm.to = new JID(jid);
mm.type = Message.Type.chat;
if (PMQueries.havePMinRoster(sql, vuid, jid)) {
- mm.from = new JID(jmsg.getUser().getUName(), "juick.com", "Juick");
+ mm.from = new JID(jmsg.getUser().getName(), "juick.com", "Juick");
mm.body = body;
} else {
mm.from = new JID("juick", "juick.com", "Juick");
- mm.body = "Private message from @" + jmsg.getUser().getUName() + ":\n" + body;
+ mm.body = "Private message from @" + jmsg.getUser().getName() + ":\n" + body;
}
xmpp.send(mm);
}
diff --git a/juick-api/src/main/java/com/juick/api/Subscriptions.java b/juick-api/src/main/java/com/juick/api/Subscriptions.java
index 4c767dc9..f8bd162f 100644
--- a/juick-api/src/main/java/com/juick/api/Subscriptions.java
+++ b/juick-api/src/main/java/com/juick/api/Subscriptions.java
@@ -26,7 +26,7 @@ public class Subscriptions {
}
public void doGet(HttpServletRequest request, HttpServletResponse response, int vuid) throws IOException {
User visitor = UserQueries.getUserByUID(jdbc, vuid).orElse(new User());
- if ((visitor.getUID() == 0) && !(visitor.getUName().equals("juick"))) {
+ if ((visitor.getUid() == 0) && !(visitor.getName().equals("juick"))) {
response.sendError(403);
return;
}
@@ -39,7 +39,7 @@ public class Subscriptions {
// thread
Message msg = MessagesQueries.getMessage(jdbc, mid);
if (msg != null) {
- List<User> users = SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, msg.getUser().getUID());
+ List<User> users = SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, msg.getUser().getUid());
Main.replyJSON(request, response, userSerializer.serializeList(users));
}
}
diff --git a/juick-api/src/main/java/com/juick/api/TelegramBotHook.java b/juick-api/src/main/java/com/juick/api/TelegramBotHook.java
index 2ec380db..e089250b 100644
--- a/juick-api/src/main/java/com/juick/api/TelegramBotHook.java
+++ b/juick-api/src/main/java/com/juick/api/TelegramBotHook.java
@@ -72,10 +72,10 @@ public class TelegramBotHook {
com.juick.Message jmsg = ms.deserialize(new JSONObject(text));
logger.info("got jmsg: " + ms.serialize(jmsg).toString());
String msgUrl = formatUrl(jmsg);
- if (jmsg.getRID() == 0) {
+ if (jmsg.getRid() == 0) {
String msg = formatPost(jmsg);
- List<Long> users = getSubscribers(jmsg.getUser().getUID());
+ List<Long> users = getSubscribers(jmsg.getUser().getUid());
List<Long> chats = getChats();
// registered subscribed users
@@ -84,9 +84,9 @@ public class TelegramBotHook {
chats.stream().filter(u -> getUser(u) == 0).forEach(c -> telegramNotify(c, msg, msgUrl));
} else {
// get quote
- com.juick.Message msg = MessagesQueries.getReply(jdbc, jmsg.getMID(), jmsg.getRID());
+ com.juick.Message msg = MessagesQueries.getReply(jdbc, jmsg.getMid(), jmsg.getRid());
String fmsg = formatPost(msg);
- getSubscribersToComments(jmsg.getMID(), jmsg.getUser().getUID()).stream()
+ getSubscribersToComments(jmsg.getMid(), jmsg.getUser().getUid()).stream()
.forEach(c -> telegramNotify(c, fmsg, msgUrl));
}
}
@@ -141,7 +141,7 @@ public class TelegramBotHook {
}
logger.info(String.format("got telegram msg %s", message.toString()));
User user_from = UserQueries.getUserByUID(jdbc, getUser(message.chat().id())).orElse(new User());
- logger.info(String.format("Found juick user %d", user_from.getUID()));
+ logger.info(String.format("Found juick user %d", user_from.getUid()));
List<Long> chats = getChats();
String username = message.from().username();
@@ -154,14 +154,14 @@ public class TelegramBotHook {
createTelegramUser(message.from().id(), username);
telegramSignupNotify(message.from().id().longValue(), UserQueries.getSignUpHashByTelegramID(jdbc, message.from().id().longValue(), username));
} else {
- if (user_from.getUID() == 0) {
+ if (user_from.getUid() == 0) {
telegramSignupNotify(message.from().id().longValue(), UserQueries.getSignUpHashByTelegramID(jdbc, message.from().id().longValue(), username));
} else {
String text = message.text();
if (text != null) {
if (text.equalsIgnoreCase("/login")) {
- String msg = String.format("Hi, %s!\nTap to log in", user_from.getUName());
- String msgUrl = "http://juick.com/login?" + UserQueries.getHashByUID(jdbc, user_from.getUID());
+ String msg = String.format("Hi, %s!\nTap to log in", user_from.getName());
+ String msgUrl = "http://juick.com/login?" + UserQueries.getHashByUID(jdbc, user_from.getUid());
telegramNotify(message.from().id().longValue(), msg, msgUrl);
} /* else {
ProtocolReply reply = protocol.getReply(user_from, text);
diff --git a/juick-api/src/main/java/com/juick/api/Users.java b/juick-api/src/main/java/com/juick/api/Users.java
index 2be288bc..a98af7a8 100644
--- a/juick-api/src/main/java/com/juick/api/Users.java
+++ b/juick-api/src/main/java/com/juick/api/Users.java
@@ -80,8 +80,8 @@ public class Users {
} else {
if (UserUtils.checkUserNameValid(uname)) {
com.juick.User u = UserQueries.getUserByName(sql, uname);
- if (u != null && u.getUID() > 0) {
- uid = u.getUID();
+ if (u != null && u.getUid() > 0) {
+ uid = u.getUid();
}
}
}
@@ -110,8 +110,8 @@ public class Users {
} else {
if (UserUtils.checkUserNameValid(uname)) {
com.juick.User u = UserQueries.getUserByName(sql, uname);
- if (u != null && u.getUID() > 0) {
- uid = u.getUID();
+ if (u != null && u.getUid() > 0) {
+ uid = u.getUid();
}
}
}
diff --git a/juick-core/src/main/java/com/juick/Message.java b/juick-core/src/main/java/com/juick/Message.java
index 8afd1d7b..d60abc5e 100644
--- a/juick-core/src/main/java/com/juick/Message.java
+++ b/juick-core/src/main/java/com/juick/Message.java
@@ -20,7 +20,10 @@ package com.juick;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.juick.xml.adapters.SimpleDateAdapter;
+import javax.xml.bind.annotation.*;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.*;
import java.util.stream.Collectors;
@@ -28,31 +31,37 @@ import java.util.stream.Collectors;
*
* @author Ugnich Anton
*/
+@XmlRootElement(name = "juick", namespace = "http://juick.com/message")
+@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public class Message implements Comparable {
- private int MID = 0;
- private int RID = 0;
-
- @JsonProperty("replyto")
- public int ReplyTo = 0;
- private String Text = null;
- private User User = null;
- @JsonProperty("tags")
- public List<Tag> Tags = new ArrayList<>();
+ private int mid = 0;
+ private int rid = 0;
+ private int replyto = 0;
+ private String text = null;
+ private User user = null;
+ private List<Tag> Tags = new ArrayList<>();
private Date date;
+ @XmlTransient
public int TimeAgo = 0;
@JsonIgnore
- public int Privacy = 1;
+ private int privacy = 1;
+ @XmlTransient
public boolean FriendsOnly = false;
+ @XmlTransient
public boolean ReadOnly = false;
+ @XmlTransient
public boolean Hidden = false;
@JsonIgnore
+ @XmlTransient
public boolean VisitorCanComment = true;
+ @XmlTransient
public int Replies = 0;
public String RepliesBy = null;
public String AttachmentType = null;
public String Photo = null;
public String Video = null;
public Place Place = null;
+ @XmlTransient
public int Likes = 0;
private boolean liked = false;
public List<Message> childs = new ArrayList<>();
@@ -64,15 +73,15 @@ public class Message implements Comparable {
}
public Message(Message msg) {
- setMID(msg.getMID());
- setRID(msg.getRID());
- ReplyTo = msg.ReplyTo;
+ setMid(msg.getMid());
+ setRid(msg.getRid());
+ replyto = msg.replyto;
setText(msg.getText());
setUser(msg.getUser());
Tags = msg.Tags;
setDate(msg.getDate());
TimeAgo = msg.TimeAgo;
- Privacy = msg.Privacy;
+ privacy = msg.privacy;
FriendsOnly = msg.FriendsOnly;
ReadOnly = msg.ReadOnly;
Hidden = msg.Hidden;
@@ -101,7 +110,7 @@ public class Message implements Comparable {
return false;
}
Message jmsg = (Message) obj;
- return (this.getMID() == jmsg.getMID() && this.getRID() == jmsg.getRID());
+ return (this.getMid() == jmsg.getMid() && this.getRid() == jmsg.getRid());
}
@Override
@@ -111,16 +120,16 @@ public class Message implements Comparable {
}
Message jmsg = (Message) obj;
- if (this.getMID() != jmsg.getMID()) {
- if (this.getMID() > jmsg.getMID()) {
+ if (this.getMid() != jmsg.getMid()) {
+ if (this.getMid() > jmsg.getMid()) {
return -1;
} else {
return 1;
}
}
- if (this.getRID() != jmsg.getRID()) {
- if (this.getRID() < jmsg.getRID()) {
+ if (this.getRid() != jmsg.getRid()) {
+ if (this.getRid() < jmsg.getRid()) {
return -1;
} else {
return 1;
@@ -151,9 +160,9 @@ public class Message implements Comparable {
if (AttachmentType != null) {
String url = "http://i.juick.com/";
url += AttachmentType.equals("mp4") ? "video" : "photos-1024";
- url += "/" + getMID();
- if (getRID() > 0) {
- url += "-" + getRID();
+ url += "/" + getMid();
+ if (getRid() > 0) {
+ url += "-" + getRid();
}
url += "." + AttachmentType;
return url;
@@ -171,13 +180,13 @@ public class Message implements Comparable {
if (FriendsOnly) {
ret += " *friends";
}
- if (Privacy == -2) {
+ if (privacy == -2) {
ret += " *private";
}
- if (Privacy == -1) {
+ if (privacy == -1) {
ret += " *friends";
}
- if (Privacy == 2) {
+ if (privacy == 2) {
ret += " *public";
}
if (ReadOnly) {
@@ -188,42 +197,48 @@ public class Message implements Comparable {
}
@JsonProperty("mid")
- public int getMID() {
- return MID;
+ @XmlAttribute(name = "mid")
+ public int getMid() {
+ return mid;
}
- public void setMID(int MID) {
- this.MID = MID;
+ public void setMid(int mid) {
+ this.mid = mid;
}
@JsonProperty("rid")
- public int getRID() {
- return RID;
+ @XmlAttribute(name = "rid")
+ public int getRid() {
+ return rid;
}
- public void setRID(int RID) {
- this.RID = RID;
+ public void setRid(int rid) {
+ this.rid = rid;
}
+ @XmlElement(name = "user", namespace = "http://juick.com/user")
public com.juick.User getUser() {
- return User;
+ return user;
}
public void setUser(com.juick.User user) {
- User = user;
+ this.user = user;
}
@JsonProperty("body")
+ @XmlElement(name = "body")
public String getText() {
- return Text;
+ return text;
}
public void setText(String text) {
- Text = text;
+ this.text = text;
}
@JsonProperty("timestamp")
@JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss", timezone="UTC")
+ @XmlAttribute(name = "ts")
+ @XmlJavaTypeAdapter(SimpleDateAdapter.class)
public Date getDate() {
return date;
}
@@ -248,6 +263,7 @@ public class Message implements Comparable {
this.Recommendation = recommendation;
}
+ @XmlTransient
public boolean isLiked() {
return liked;
}
@@ -262,4 +278,33 @@ public class Message implements Comparable {
public void setReplyQuote(String quote) {
replyQuote = quote;
}
+
+ @JsonProperty("replyto")
+ @XmlAttribute(name = "replyto")
+ public int getReplyto() {
+ return replyto;
+ }
+
+ public void setReplyto(int replyto) {
+ this.replyto = replyto;
+ }
+
+ @JsonProperty("tags")
+ @XmlElement(name = "tag")
+ public List<Tag> getTags() {
+ return Tags;
+ }
+
+ public void setTags(List<Tag> tags) {
+ Tags = tags;
+ }
+
+ @XmlAttribute
+ public int getPrivacy() {
+ return privacy;
+ }
+
+ public void setPrivacy(int privacy) {
+ this.privacy = privacy;
+ }
}
diff --git a/juick-core/src/main/java/com/juick/Tag.java b/juick-core/src/main/java/com/juick/Tag.java
index fa518e84..4ba3a812 100644
--- a/juick-core/src/main/java/com/juick/Tag.java
+++ b/juick-core/src/main/java/com/juick/Tag.java
@@ -20,18 +20,28 @@ package com.juick;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonValue;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlValue;
import java.util.Objects;
/**
* @author Ugnich Anton
*/
+@XmlRootElement(name = "tag", namespace = "http://juick.com/message")
+@XmlAccessorType(XmlAccessType.PROPERTY)
public class Tag {
- private final String name;
+
+ private String name;
public int TID = 0;
public int SynonymID = 0;
public int UsageCnt = 0;
+ public Tag() {
+
+ }
public Tag(String name) {
this.name = name;
@@ -44,6 +54,7 @@ public class Tag {
}
@JsonIgnore
+ @XmlValue
public String getName() {
return name;
}
@@ -53,4 +64,8 @@ public class Tag {
public String toString() {
return name;
}
+
+ public void setName(String name) {
+ this.name = name;
+ }
}
diff --git a/juick-core/src/main/java/com/juick/User.java b/juick-core/src/main/java/com/juick/User.java
index b8936bab..83dcda5f 100644
--- a/juick-core/src/main/java/com/juick/User.java
+++ b/juick-core/src/main/java/com/juick/User.java
@@ -20,27 +20,29 @@ package com.juick;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
+import javax.xml.bind.annotation.*;
+
/**
* @author Ugnich Anton
*/
+@XmlRootElement(name = "user", namespace = "http://juick.com/user")
+@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public class User {
- private int UID = 0;
- private String UName = null;
- @JsonIgnore
- public Object Avatar = null;
+ private int uid = 0;
+ private String name = null;
+ private Object Avatar = null;
private String FullName = null;
private String JID = null;
private int MessagesCount = 0;
private String AuthHash = null;
- @JsonIgnore
- public boolean Banned = false;
+ private boolean Banned = false;
public User() {
}
public User(User u) {
- setUID(u.getUID());
- setUName(u.getUName());
+ setUid(u.getUid());
+ setName(u.getName());
Avatar = u.Avatar;
setFullName(u.getFullName());
setJID(u.getJID());
@@ -52,28 +54,31 @@ public class User {
@Override
public boolean equals(Object obj) {
return obj == this ||
- (obj instanceof User && ((User) obj).getUID() == this.getUID());
+ (obj instanceof User && ((User) obj).getUid() == this.getUid());
}
@JsonProperty("uid")
- public int getUID() {
- return UID;
+ @XmlAttribute(name = "uid")
+ public int getUid() {
+ return uid;
}
- public void setUID(int UID) {
- this.UID = UID;
+ public void setUid(int uid) {
+ this.uid = uid;
}
@JsonProperty("uname")
- public String getUName() {
- return UName;
+ @XmlAttribute(name = "uname")
+ public String getName() {
+ return name;
}
- public void setUName(String UName) {
- this.UName = UName;
+ public void setName(String name) {
+ this.name = name;
}
@JsonProperty("fullname")
+ @XmlTransient
public String getFullName() {
return FullName;
}
@@ -101,6 +106,7 @@ public class User {
}
@JsonProperty("unreadCount")
+ @XmlTransient
public Integer getUnreadCount() {
return MessagesCount;
}
@@ -108,4 +114,21 @@ public class User {
public void setUnreadCount(Integer count) {
MessagesCount = count;
}
+
+ @XmlTransient
+ public boolean isBanned() {
+ return Banned;
+ }
+
+ public void setBanned(boolean banned) {
+ Banned = banned;
+ }
+
+ public Object getAvatar() {
+ return Avatar;
+ }
+
+ public void setAvatar(Object avatar) {
+ Avatar = avatar;
+ }
}
diff --git a/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java b/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java
index 6c712d28..be2c6838 100644
--- a/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java
+++ b/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java
@@ -1,17 +1,15 @@
package com.juick.formatters;
-import com.juick.Message;
-
/**
* Created by vitalyster on 12.10.2016.
*/
public class PlainTextFormatter {
public static String formatPost(com.juick.Message jmsg) {
StringBuilder sb = new StringBuilder();
- boolean isReply = jmsg.getRID() > 0;
+ boolean isReply = jmsg.getRid() > 0;
String title = isReply ? "Reply by @" : "@";
String subtitle = isReply ? jmsg.getReplyQuote() : jmsg.getTagsString();
- sb.append(title).append(jmsg.getUser().getUName()).append(":\n")
+ sb.append(title).append(jmsg.getUser().getName()).append(":\n")
.append(subtitle).append("\n").append(jmsg.getText()).append("\n");
if (jmsg.Photo != null) {
sb.append(jmsg.Photo);
@@ -20,9 +18,9 @@ public class PlainTextFormatter {
}
public static String formatUrl(com.juick.Message jmsg) {
- if (jmsg.getRID() > 0) {
- return String.format("https://juick.com/%d#%d", jmsg.getMID(), jmsg.getRID());
+ if (jmsg.getRid() > 0) {
+ return String.format("https://juick.com/%d#%d", jmsg.getMid(), jmsg.getRid());
}
- return "https://juick.com/" + jmsg.getMID();
+ return "https://juick.com/" + jmsg.getMid();
}
}
diff --git a/juick-core/src/main/java/com/juick/json/MessageSerializer.java b/juick-core/src/main/java/com/juick/json/MessageSerializer.java
index 3ef903f0..ebc3b0b0 100644
--- a/juick-core/src/main/java/com/juick/json/MessageSerializer.java
+++ b/juick-core/src/main/java/com/juick/json/MessageSerializer.java
@@ -51,12 +51,12 @@ public class MessageSerializer extends JSONSerializer<Message> {
@Override
public Message deserialize(JSONObject json) throws JSONException, ParseException {
com.juick.Message jmsg = new com.juick.Message();
- jmsg.setMID(json.getInt("mid"));
+ jmsg.setMid(json.getInt("mid"));
if (json.has("rid")) {
- jmsg.setRID(json.getInt("rid"));
+ jmsg.setRid(json.getInt("rid"));
}
if (json.has("replyto")) {
- jmsg.ReplyTo = json.getInt("replyto");
+ jmsg.setReplyto(json.getInt("replyto"));
}
jmsg.FriendsOnly = json.has("friendsonly");
@@ -70,7 +70,7 @@ public class MessageSerializer extends JSONSerializer<Message> {
if (json.has("tags")) {
JSONArray tags = json.getJSONArray("tags");
for (int n = 0; n < tags.length(); n++) {
- jmsg.Tags.add(new Tag(tags.getString(n).replace("&quot;", "\"")));
+ jmsg.getTags().add(new Tag(tags.getString(n).replace("&quot;", "\"")));
}
}
@@ -90,14 +90,14 @@ public class MessageSerializer extends JSONSerializer<Message> {
JSONObject json = new JSONObject();
try {
- if (msg.getMID() > 0) {
- json.put("mid", msg.getMID());
+ if (msg.getMid() > 0) {
+ json.put("mid", msg.getMid());
}
- if (msg.getRID() > 0) {
- json.put("rid", msg.getRID());
+ if (msg.getRid() > 0) {
+ json.put("rid", msg.getRid());
}
- if (msg.ReplyTo > 0) {
- json.put("replyto", msg.ReplyTo);
+ if (msg.getReplyto() > 0) {
+ json.put("replyto", msg.getReplyto());
}
if (msg.FriendsOnly) {
json.put("friendsonly", 1);
@@ -114,8 +114,8 @@ public class MessageSerializer extends JSONSerializer<Message> {
if (msg.getUser() != null) {
json.put("user", userSerializer.serialize(msg.getUser()));
}
- if (msg.Tags != null && msg.Tags.size() > 0) {
- json.put("tags", new JSONArray(msg.Tags.stream().map(Tag::getName).collect(Collectors.toList())));
+ if (msg.getTags() != null && msg.getTags().size() > 0) {
+ json.put("tags", new JSONArray(msg.getTags().stream().map(Tag::getName).collect(Collectors.toList())));
}
if (msg.Replies > 0) {
json.put("replies", msg.Replies);
@@ -124,7 +124,7 @@ public class MessageSerializer extends JSONSerializer<Message> {
json.put("place", placeSerializer.serialize(msg.Place));
}
if (msg.AttachmentType != null) {
- String fname = msg.getMID() + (msg.getRID() > 0 ? "-" + msg.getRID() : "") + "." + msg.AttachmentType;
+ String fname = msg.getMid() + (msg.getRid() > 0 ? "-" + msg.getRid() : "") + "." + msg.AttachmentType;
JSONObject photo = new JSONObject();
String protocol = getUriScheme() == URIScheme.Plain ? "http:" : "https:";
photo.put("thumbnail", protocol + "//i.juick.com/ps/" + fname);
diff --git a/juick-core/src/main/java/com/juick/json/UserSerializer.java b/juick-core/src/main/java/com/juick/json/UserSerializer.java
index 390f4bf6..08d21d39 100644
--- a/juick-core/src/main/java/com/juick/json/UserSerializer.java
+++ b/juick-core/src/main/java/com/juick/json/UserSerializer.java
@@ -30,8 +30,8 @@ public class UserSerializer extends JSONSerializer<User> {
@Override
public User deserialize(JSONObject json) throws JSONException {
User juser = new User();
- juser.setUID(json.getInt("uid"));
- juser.setUName(json.getString("uname"));
+ juser.setUid(json.getInt("uid"));
+ juser.setName(json.getString("uname"));
if (json.has("fullname")) {
juser.setFullName(json.getString("fullname"));
}
@@ -43,11 +43,11 @@ public class UserSerializer extends JSONSerializer<User> {
JSONObject json = new JSONObject();
try {
- if (user.getUID() > 0) {
- json.put("uid", user.getUID());
+ if (user.getUid() > 0) {
+ json.put("uid", user.getUid());
}
- if (user.getUName() != null) {
- json.put("uname", user.getUName());
+ if (user.getName() != null) {
+ json.put("uname", user.getName());
}
if (user.getFullName() != null) {
json.put("fullname", user.getFullName());
diff --git a/juick-core/src/main/java/com/juick/package-info.java b/juick-core/src/main/java/com/juick/package-info.java
new file mode 100644
index 00000000..1ebddc60
--- /dev/null
+++ b/juick-core/src/main/java/com/juick/package-info.java
@@ -0,0 +1,16 @@
+/**
+ * Created by vitalyster on 15.11.2016.
+ */
+@XmlSchema(
+ namespace="http://juick.com/message",
+ elementFormDefault = XmlNsForm.QUALIFIED,
+ xmlns={
+ @XmlNs(prefix="", namespaceURI="http://juick.com/message"),
+ @XmlNs(prefix="user", namespaceURI="http://juick.com/user")
+ }
+)
+package com.juick;
+
+import javax.xml.bind.annotation.XmlNs;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlSchema; \ No newline at end of file
diff --git a/juick-core/src/main/java/com/juick/xml/adapters/SimpleDateAdapter.java b/juick-core/src/main/java/com/juick/xml/adapters/SimpleDateAdapter.java
new file mode 100644
index 00000000..9cb56909
--- /dev/null
+++ b/juick-core/src/main/java/com/juick/xml/adapters/SimpleDateAdapter.java
@@ -0,0 +1,35 @@
+package com.juick.xml.adapters;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+/**
+ * Created by vitalyster on 15.11.2016.
+ */
+
+public class SimpleDateAdapter extends XmlAdapter<String, Date> {
+
+ private final SimpleDateFormat dateFormat;
+ public SimpleDateAdapter() {
+ dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ }
+
+ @Override
+ public String marshal(Date v) throws Exception {
+ synchronized (dateFormat) {
+ return dateFormat.format(v);
+ }
+ }
+
+ @Override
+ public Date unmarshal(String v) throws Exception {
+ synchronized (dateFormat) {
+ return dateFormat.parse(v);
+ }
+ }
+
+}
diff --git a/juick-core/src/main/java/com/juick/xmpp/extensions/JuickMessage.java b/juick-core/src/main/java/com/juick/xmpp/extensions/JuickMessage.java
index d259bc43..2c3875c5 100644
--- a/juick-core/src/main/java/com/juick/xmpp/extensions/JuickMessage.java
+++ b/juick-core/src/main/java/com/juick/xmpp/extensions/JuickMessage.java
@@ -60,19 +60,19 @@ public class JuickMessage extends com.juick.Message implements StanzaChild {
final String sMID = parser.getAttributeValue(null, "mid");
if (sMID != null) {
- jmsg.setMID(Integer.parseInt(sMID));
+ jmsg.setMid(Integer.parseInt(sMID));
}
final String sRID = parser.getAttributeValue(null, "rid");
if (sRID != null) {
- jmsg.setRID(Integer.parseInt(sRID));
+ jmsg.setRid(Integer.parseInt(sRID));
}
final String sReplyTo = parser.getAttributeValue(null, "replyto");
if (sReplyTo != null) {
- jmsg.ReplyTo = Integer.parseInt(sReplyTo);
+ jmsg.setReplyto(Integer.parseInt(sReplyTo));
}
final String sPrivacy = parser.getAttributeValue(null, "privacy");
if (sPrivacy != null) {
- jmsg.Privacy = Integer.parseInt(sPrivacy);
+ jmsg.setPrivacy(Integer.parseInt(sPrivacy));
}
final String sFriendsOnly = parser.getAttributeValue(null, "friendsonly");
if (sFriendsOnly != null) {
@@ -96,7 +96,7 @@ public class JuickMessage extends com.juick.Message implements StanzaChild {
} else if (tag.equals(JuickUser.TagName) && xmlns != null && xmlns.equals(JuickUser.XMLNS)) {
jmsg.setUser(new JuickUser().parse(parser));
} else if (tag.equals("tag")) {
- jmsg.Tags.add(new Tag(XmlUtils.getTagText(parser)));
+ jmsg.getTags().add(new Tag(XmlUtils.getTagText(parser)));
} else {
XmlUtils.skip(parser);
}
@@ -109,16 +109,16 @@ public class JuickMessage extends com.juick.Message implements StanzaChild {
String ret = "";
ret = "<" + TagName + " xmlns=\"" + XMLNS + "\"";
- if (getMID() > 0) {
- ret += " mid=\"" + getMID() + "\"";
+ if (getMid() > 0) {
+ ret += " mid=\"" + getMid() + "\"";
}
- if (getRID() > 0) {
- ret += " rid=\"" + getRID() + "\"";
+ if (getRid() > 0) {
+ ret += " rid=\"" + getRid() + "\"";
}
- if (ReplyTo > 0) {
- ret += " replyto=\"" + ReplyTo + "\"";
+ if (getReplyto() > 0) {
+ ret += " replyto=\"" + getReplyto() + "\"";
}
- ret += " privacy=\"" + Privacy + "\"";
+ ret += " privacy=\"" + getPrivacy() + "\"";
if (FriendsOnly) {
ret += " friendsonly=\"1\"";
}
@@ -138,7 +138,7 @@ public class JuickMessage extends com.juick.Message implements StanzaChild {
if (getText() != null) {
ret += "<body>" + XmlUtils.escape(getText()) + "</body>";
}
- for (com.juick.Tag Tag : Tags) {
+ for (com.juick.Tag Tag : getTags()) {
ret += "<tag>" + XmlUtils.escape(Tag.getName()) + "</tag>";
}
ret += "</" + TagName + ">";
@@ -152,7 +152,7 @@ public class JuickMessage extends com.juick.Message implements StanzaChild {
return false;
}
JuickMessage jmsg = (JuickMessage) obj;
- return (this.getMID() == jmsg.getMID() && this.getRID() == jmsg.getRID());
+ return (this.getMid() == jmsg.getMid() && this.getRid() == jmsg.getRid());
}
@Override
@@ -162,16 +162,16 @@ public class JuickMessage extends com.juick.Message implements StanzaChild {
}
JuickMessage jmsg = (JuickMessage) obj;
- if (this.getMID() != jmsg.getMID()) {
- if (this.getMID() > jmsg.getMID()) {
+ if (this.getMid() != jmsg.getMid()) {
+ if (this.getMid() > jmsg.getMid()) {
return -1;
} else {
return 1;
}
}
- if (this.getRID() != jmsg.getRID()) {
- if (this.getRID() < jmsg.getRID()) {
+ if (this.getRid() != jmsg.getRid()) {
+ if (this.getRid() < jmsg.getRid()) {
return -1;
} else {
return 1;
diff --git a/juick-core/src/main/java/com/juick/xmpp/extensions/JuickUser.java b/juick-core/src/main/java/com/juick/xmpp/extensions/JuickUser.java
index edc6749a..7473134c 100644
--- a/juick-core/src/main/java/com/juick/xmpp/extensions/JuickUser.java
+++ b/juick-core/src/main/java/com/juick/xmpp/extensions/JuickUser.java
@@ -49,20 +49,20 @@ public class JuickUser extends com.juick.User implements StanzaChild {
JuickUser juser = new JuickUser();
String strUID = parser.getAttributeValue(null, "uid");
if (strUID != null) {
- juser.setUID(Integer.parseInt(strUID));
+ juser.setUid(Integer.parseInt(strUID));
}
- juser.setUName(parser.getAttributeValue(null, "uname"));
+ juser.setName(parser.getAttributeValue(null, "uname"));
XmlUtils.skip(parser);
return juser;
}
public static String toString(com.juick.User user) {
String str = "<" + TagName + " xmlns='" + XMLNS + "'";
- if (user.getUID() > 0) {
- str += " uid='" + user.getUID() + "'";
+ if (user.getUid() > 0) {
+ str += " uid='" + user.getUid() + "'";
}
- if (user.getUName() != null && user.getUName().length() > 0) {
- str += " uname='" + XmlUtils.escape(user.getUName()) + "'";
+ if (user.getName() != null && user.getName().length() > 0) {
+ str += " uname='" + XmlUtils.escape(user.getName()) + "'";
}
str += "/>";
return str;
diff --git a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java
index c82fc542..8ccca67c 100644
--- a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java
+++ b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java
@@ -127,7 +127,7 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea
@Override
public void onMessage(final com.juick.xmpp.Message msg) {
JuickMessage jmsg = (JuickMessage) msg.getChild(JuickMessage.XMLNS);
- if (msg.to != null && msg.to.Username != null && jmsg != null && jmsg.getRID() == 0) {
+ if (msg.to != null && msg.to.Username != null && jmsg != null && jmsg.getRid() == 0) {
if (msg.to.Username.equals("twitter")) {
twitterPost(jmsg);
} else if (msg.to.Username.equals("fb")) {
@@ -139,12 +139,12 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea
}
public boolean facebookPost(final com.juick.Message jmsg) {
- String token = crosspostService.getFacebookToken(jmsg.getUser().getUID()).orElse("");
+ String token = crosspostService.getFacebookToken(jmsg.getUser().getUid()).orElse("");
if (token.isEmpty()) {
return false;
}
- logger.info("FB: #" + jmsg.getMID());
+ logger.info("FB: #" + jmsg.getMid());
String status = getMessageHashTags(jmsg) + "\n" + jmsg.getText();
@@ -155,7 +155,7 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea
+ "&message="
+ URLEncoder.encode(status, "UTF-8")
+ "&link=http%3A%2F%2Fjuick.com%2F"
- + jmsg.getMID();
+ + jmsg.getMid();
HttpsURLConnection conn = (HttpsURLConnection) new URL(FBURL).openConnection();
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
@@ -181,14 +181,14 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea
}
public boolean vkontaktePost(final com.juick.Message jmsg) {
- Pair<String, String> tokens = crosspostService.getVkTokens(jmsg.getUser().getUID()).orElse(Pair.of("", ""));
+ Pair<String, String> tokens = crosspostService.getVkTokens(jmsg.getUser().getUid()).orElse(Pair.of("", ""));
if (tokens.getLeft().isEmpty() || tokens.getRight().isEmpty()) {
return false;
}
- logger.info("VK: #" + jmsg.getMID());
+ logger.info("VK: #" + jmsg.getMid());
- String status = getMessageHashTags(jmsg) + "\n" + jmsg.getText() + "\nhttp://juick.com/" + jmsg.getMID();
+ String status = getMessageHashTags(jmsg) + "\n" + jmsg.getText() + "\nhttp://juick.com/" + jmsg.getMid();
boolean ret = false;
try {
@@ -218,20 +218,20 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea
}
public boolean twitterPost(final com.juick.Message jmsg) {
- Pair<String, String> tokens = crosspostService.getTwitterTokens(jmsg.getUser().getUID()).orElse(Pair.of("", ""));
+ Pair<String, String> tokens = crosspostService.getTwitterTokens(jmsg.getUser().getUid()).orElse(Pair.of("", ""));
if (tokens.getLeft().isEmpty() || tokens.getRight().isEmpty()) {
return false;
}
String token = percentEncode(tokens.getLeft());
String token_secret = percentEncode(tokens.getRight());
- logger.info("TWITTER: #" + jmsg.getMID());
+ logger.info("TWITTER: #" + jmsg.getMid());
String status = getMessageHashTags(jmsg) + jmsg.getText();
if (status.length() > 115) {
status = status.substring(0, 114) + "…";
}
- status += " http://juick.com/" + jmsg.getMID();
+ status += " http://juick.com/" + jmsg.getMid();
status = percentEncode(status);
boolean ret = false;
@@ -316,8 +316,8 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea
public String getMessageHashTags(final com.juick.Message jmsg) {
String hashtags = "";
- for (int i = 0; i < jmsg.Tags.size(); i++) {
- hashtags += "#" + jmsg.Tags.get(i) + " ";
+ for (int i = 0; i < jmsg.getTags().size(); i++) {
+ hashtags += "#" + jmsg.getTags().get(i) + " ";
}
return hashtags;
}
diff --git a/juick-demo/src/main/java/com/juick/demo/Demo.java b/juick-demo/src/main/java/com/juick/demo/Demo.java
index 0ed18079..b94c9830 100644
--- a/juick-demo/src/main/java/com/juick/demo/Demo.java
+++ b/juick-demo/src/main/java/com/juick/demo/Demo.java
@@ -57,7 +57,7 @@ public class Demo {
reader.setPrompt("ugnich>");
PrintWriter out = new PrintWriter(reader.getOutput());
User ugnich = UserQueries.getUserByUID(jdbc, ugnich_id).get();
- out.println(String.format("logged in as @%s", ugnich.getUName()));
+ out.println(String.format("logged in as @%s", ugnich.getName()));
out.flush();
String input;
JuickProtocol protocol = new JuickProtocol(jdbc, "http://localhost/");
diff --git a/juick-notifications/src/main/java/com/juick/components/Notifications.java b/juick-notifications/src/main/java/com/juick/components/Notifications.java
index b7e6b2b8..d37f7a25 100644
--- a/juick-notifications/src/main/java/com/juick/components/Notifications.java
+++ b/juick-notifications/src/main/java/com/juick/components/Notifications.java
@@ -128,20 +128,20 @@ public class Notifications implements InitializingBean, DisposableBean, Stream.S
@Override
public void onMessage(final com.juick.xmpp.Message msg) {
JuickMessage jmsg = (JuickMessage) msg.getChild(JuickMessage.XMLNS);
- boolean isPM = jmsg.getMID() == 0;
- boolean isReply = jmsg.getRID() > 0;
+ boolean isPM = jmsg.getMid() == 0;
+ boolean isReply = jmsg.getRid() > 0;
int pmTo = 0;
/*** ANDROID ***/
final List<String> regids = new ArrayList<>();
if (isPM) {
regids.addAll(rest.exchange(String.format("http://api.juick.com/notifications?type=gcm&uid=%s",
- jmsg.getUser().getUID()),
+ jmsg.getUser().getUid()),
HttpMethod.GET, null, new ParameterizedTypeReference<List<String>>() {
}).getBody());
} else {
regids.addAll(rest.exchange(String.format("http://api.juick.com/notifications?type=gcm&uid=%s&mid=%s",
- jmsg.getUser().getUID(), jmsg.getMID()),
+ jmsg.getUser().getUid(), jmsg.getMid()),
HttpMethod.GET, null, new ParameterizedTypeReference<List<String>>() {
}).getBody());
}
@@ -170,12 +170,12 @@ public class Notifications implements InitializingBean, DisposableBean, Stream.S
final List<String> urls = new ArrayList<>();
if (isPM) {
urls.addAll(rest.exchange(String.format("http://api.juick.com/notifications?type=mpns&uid=%s",
- jmsg.getUser().getUID()),
+ jmsg.getUser().getUid()),
HttpMethod.GET, null, new ParameterizedTypeReference<List<String>>() {
}).getBody());
} else {
urls.addAll(rest.exchange(String.format("http://api.juick.com/notifications?type=mpns&uid=%s&mid=%s",
- jmsg.getUser().getUID(), jmsg.getMID()),
+ jmsg.getUser().getUid(), jmsg.getMid()),
HttpMethod.GET, null, new ParameterizedTypeReference<List<String>>() {
}).getBody());
}
@@ -185,8 +185,8 @@ public class Notifications implements InitializingBean, DisposableBean, Stream.S
} else {
try {
String wnsToken = getWnsAccessToken();
- String text1 = "@" + jmsg.getUser().getUName();
- if (!jmsg.Tags.isEmpty()) {
+ String text1 = "@" + jmsg.getUser().getName();
+ if (!jmsg.getTags().isEmpty()) {
text1 += ":" + XmlUtils.escape(jmsg.getTagsString());
}
String text2 = XmlUtils.escape(jmsg.getText());
@@ -194,13 +194,13 @@ public class Notifications implements InitializingBean, DisposableBean, Stream.S
+ "<toast>"
+ "<visual>"
+ "<binding template=\"ToastImageAndText02\">"
- + "<image id=\"1\" src=\"http://i.juick.com/as/" + jmsg.getUser().getUID() + ".png\" />"
+ + "<image id=\"1\" src=\"http://i.juick.com/as/" + jmsg.getUser().getUid() + ".png\" />"
+ "<text id=\"1\">" + text1 + "</text>"
+ "<text id=\"2\">" + text2 + "</text>"
+ "</binding>"
+ "</visual>"
+ "<commands>"
- + "<command arguments=\"?mid=" + jmsg.getMID() + "\" />"
+ + "<command arguments=\"?mid=" + jmsg.getMid() + "\" />"
+ "</commands>"
+ "</toast>";
logger.trace(xml);
@@ -217,12 +217,12 @@ public class Notifications implements InitializingBean, DisposableBean, Stream.S
final List<String> tokens = new ArrayList<>();
if (isPM) {
tokens.addAll(rest.exchange(String.format("http://api.juick.com/notifications?type=apns&uid=%s",
- jmsg.getUser().getUID()),
+ jmsg.getUser().getUid()),
HttpMethod.GET, null, new ParameterizedTypeReference<List<String>>() {
}).getBody());
} else {
tokens.addAll(rest.exchange(String.format("http://api.juick.com/notifications?type=apns&uid=%s&mid=%s",
- jmsg.getUser().getUID(), jmsg.getMID()),
+ jmsg.getUser().getUid(), jmsg.getMid()),
HttpMethod.GET, null, new ParameterizedTypeReference<List<String>>() {
}).getBody());
}
@@ -230,7 +230,7 @@ public class Notifications implements InitializingBean, DisposableBean, Stream.S
ApnsService service = APNS.newService().withCert("/etc/juick/ios.p12", "juick")
.withSandboxDestination().build();
for (String token : tokens) {
- String payload = APNS.newPayload().alertTitle("@" + jmsg.getUser().getUName()).alertBody(jmsg.getText()).build();
+ String payload = APNS.newPayload().alertTitle("@" + jmsg.getUser().getName()).alertBody(jmsg.getText()).build();
logger.info("APNS: " + token);
service.push(token, payload);
}
diff --git a/juick-rss/src/main/java/com/juick/rss/Main.java b/juick-rss/src/main/java/com/juick/rss/Main.java
index 471753b7..bf8348fb 100644
--- a/juick-rss/src/main/java/com/juick/rss/Main.java
+++ b/juick-rss/src/main/java/com/juick/rss/Main.java
@@ -126,13 +126,13 @@ public class Main extends HttpServlet {
for (Message msg : msgs) {
out.println("<item>");
- out.println("<link>http://juick.com/" + msg.getUser().getUName() + "/" + msg.getMID() + "</link>");
- out.println("<guid>http://juick.com/" + msg.getUser().getUName() + "/" + msg.getMID() + "</guid>");
+ out.println("<link>http://juick.com/" + msg.getUser().getName() + "/" + msg.getMid() + "</link>");
+ out.println("<guid>http://juick.com/" + msg.getUser().getName() + "/" + msg.getMid() + "</guid>");
- out.print("<title><![CDATA[@" + msg.getUser().getUName() + ":");
- if (!msg.Tags.isEmpty()) {
- for (int n = 0; n < msg.Tags.size(); n++) {
- out.print(" *" + msg.Tags.get(n));
+ out.print("<title><![CDATA[@" + msg.getUser().getName() + ":");
+ if (!msg.getTags().isEmpty()) {
+ for (int n = 0; n < msg.getTags().size(); n++) {
+ out.print(" *" + msg.getTags().get(n));
}
}
out.println("]]></title>");
@@ -140,22 +140,22 @@ public class Main extends HttpServlet {
out.println("<pubDate>" + sdfRSS.format(msg.getDate()) + "</pubDate>");
- out.println("<comments>http://juick.com/" + msg.getUser().getUName() + "/" + msg.getMID() + "</comments>");
- if (!msg.Tags.isEmpty()) {
- for (int n = 0; n < msg.Tags.size(); n++) {
- out.println("<category>" + escapeHtml(msg.Tags.get(n).getName()) + "</category>");
+ out.println("<comments>http://juick.com/" + msg.getUser().getName() + "/" + msg.getMid() + "</comments>");
+ if (!msg.getTags().isEmpty()) {
+ for (int n = 0; n < msg.getTags().size(); n++) {
+ out.println("<category>" + escapeHtml(msg.getTags().get(n).getName()) + "</category>");
}
}
if (msg.AttachmentType != null) {
if (msg.AttachmentType.equals("jpg")) {
- out.println("<media:content url='http://i.juick.com/photos-1024/" + msg.getMID() + ".jpg' type='image/jpeg'/>");
- out.println("<media:thumbnail url='http://i.juick.com/ps/" + msg.getMID() + ".jpg'/>");
+ out.println("<media:content url='http://i.juick.com/photos-1024/" + msg.getMid() + ".jpg' type='image/jpeg'/>");
+ out.println("<media:thumbnail url='http://i.juick.com/ps/" + msg.getMid() + ".jpg'/>");
} else if (msg.AttachmentType.equals("png")) {
- out.println("<media:content url='http://i.juick.com/photos-1024/" + msg.getMID() + ".png' type='image/png'/>");
- out.println("<media:thumbnail url='http://i.juick.com/ps/" + msg.getMID() + ".png'/>");
+ out.println("<media:content url='http://i.juick.com/photos-1024/" + msg.getMid() + ".png' type='image/png'/>");
+ out.println("<media:thumbnail url='http://i.juick.com/ps/" + msg.getMid() + ".png'/>");
}
}
- out.println("<juick:user uid='" + msg.getUser().getUID() + "'/>");
+ out.println("<juick:user uid='" + msg.getUser().getUid() + "'/>");
out.println("</item>");
}
diff --git a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
index ac53b2ad..0ef5374c 100644
--- a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
+++ b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
@@ -56,7 +56,7 @@ public class WebsocketComponent extends TextWebSocketHandler {
visitor = UserQueries.getUserByHash(jdbc, hash);
} else {
try {
- logger.info(String.format("wrong hash for %d from %s", visitor.getUID(), hXRealIP));
+ logger.info(String.format("wrong hash for %d from %s", visitor.getUid(), hXRealIP));
session.close(new CloseStatus(403, "Forbidden"));
} catch (IOException e) {
logger.warn("ws error", e);
@@ -65,19 +65,19 @@ public class WebsocketComponent extends TextWebSocketHandler {
break;
}
}
- logger.info(String.format("user %d connected to %s from %s", visitor.getUID(), hLocation.getPath(), hXRealIP));
+ logger.info(String.format("user %d connected to %s from %s", visitor.getUid(), hLocation.getPath(), hXRealIP));
int MID = 0;
SocketSubscribed sockSubscr = null;
if (hLocation.getPath().equals("/")) {
- logger.info(String.format("user %d connected", visitor.getUID()));
+ logger.info(String.format("user %d connected", visitor.getUid()));
sockSubscr = new SocketSubscribed(session, hXRealIP, visitor, false);
} else if (hLocation.getPath().equals("/_all")) {
- logger.info(String.format("user %d connected to legacy _all (%s)", visitor.getUID(), hLocation.getPath()));
+ logger.info(String.format("user %d connected to legacy _all (%s)", visitor.getUid(), hLocation.getPath()));
sockSubscr = new SocketSubscribed(session, hXRealIP, visitor, true);
sockSubscr.allMessages = true;
} else if (hLocation.getPath().equals("/_replies")) {
- logger.info(String.format("user %d connected to legacy _replies (%s)", visitor.getUID(), hLocation.getPath()));
+ logger.info(String.format("user %d connected to legacy _replies (%s)", visitor.getUid(), hLocation.getPath()));
sockSubscr = new SocketSubscribed(session, hXRealIP, visitor, true);
sockSubscr.allReplies = true;
} else if (hLocation.getPath().matches("/\\d+$")) {
@@ -86,8 +86,8 @@ public class WebsocketComponent extends TextWebSocketHandler {
} catch (Exception e) {
}
if (MID > 0) {
- if (MessagesQueries.canViewThread(jdbc, MID, visitor.getUID())) {
- logger.info(String.format("user %d connected to legacy thread (%d) from %s", visitor.getUID(), MID, hXRealIP));
+ if (MessagesQueries.canViewThread(jdbc, MID, visitor.getUid())) {
+ logger.info(String.format("user %d connected to legacy thread (%d) from %s", visitor.getUid(), MID, hXRealIP));
sockSubscr = new SocketSubscribed(session, hXRealIP, visitor, true);
sockSubscr.MID = MID;
} else {
diff --git a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
index 04ea5378..7a6feee1 100644
--- a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
+++ b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
@@ -100,7 +100,7 @@ public class XMPPConnection implements InitializingBean, DisposableBean, Stream.
JuickMessage jmsg = (JuickMessage) msg.getChild(JuickMessage.XMLNS);
if (jmsg != null) {
logger.info("got jmsg: " + ms.serialize(jmsg).toString());
- if (jmsg.getMID() == 0) {
+ if (jmsg.getMid() == 0) {
int uid_to = 0;
try {
uid_to = Integer.parseInt(msg.to.Username);
@@ -109,11 +109,11 @@ public class XMPPConnection implements InitializingBean, DisposableBean, Stream.
if (uid_to > 0) {
onJuickPM(uid_to, jmsg);
}
- } else if (jmsg.getRID() == 0) {
+ } else if (jmsg.getRid() == 0) {
onJuickMessagePost(jmsg);
} else {
// to get quote
- com.juick.Message reply = MessagesQueries.getReply(jdbc, jmsg.getMID(), jmsg.getRID());
+ com.juick.Message reply = MessagesQueries.getReply(jdbc, jmsg.getMid(), jmsg.getRid());
onJuickMessageReply(reply);
}
}
@@ -124,9 +124,9 @@ public class XMPPConnection implements InitializingBean, DisposableBean, Stream.
private void onJuickPM(final int uid_to, final com.juick.Message jmsg) {
String json = messageSerializer.serialize(jmsg).toString();
synchronized (wsHandler.getClients()) {
- wsHandler.getClients().stream().filter(c -> !c.legacy && c.visitor.getUID() == uid_to).forEach(c -> {
+ wsHandler.getClients().stream().filter(c -> !c.legacy && c.visitor.getUid() == uid_to).forEach(c -> {
try {
- logger.info("sending pm to " + c.visitor.getUID());
+ logger.info("sending pm to " + c.visitor.getUid());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
logger.warn("ws error", e);
@@ -137,15 +137,15 @@ public class XMPPConnection implements InitializingBean, DisposableBean, Stream.
private void onJuickMessagePost(final com.juick.Message jmsg) {
String json = messageSerializer.serialize(jmsg).toString();
- List<Integer> uids = SubscriptionsQueries.getSubscribedUsers(jdbc, jmsg.getUser().getUID(), jmsg.getMID())
- .stream().map(User::getUID).collect(Collectors.toList());
+ List<Integer> uids = SubscriptionsQueries.getSubscribedUsers(jdbc, jmsg.getUser().getUid(), jmsg.getMid())
+ .stream().map(User::getUid).collect(Collectors.toList());
synchronized (wsHandler.getClients()) {
wsHandler.getClients().stream().filter(c ->
- (!c.legacy && c.visitor.getUID() == 0) // anonymous users
- || (!c.legacy && uids.contains(c.visitor.getUID()))) // subscriptions
+ (!c.legacy && c.visitor.getUid() == 0) // anonymous users
+ || (!c.legacy && uids.contains(c.visitor.getUid()))) // subscriptions
.forEach(c -> {
try {
- logger.info("sending message to " + c.visitor.getUID());
+ logger.info("sending message to " + c.visitor.getUid());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
logger.warn("ws error", e);
@@ -155,7 +155,7 @@ public class XMPPConnection implements InitializingBean, DisposableBean, Stream.
c.legacy && c.allMessages) // legacy all posts
.forEach(c -> {
try {
- logger.info("sending message to legacy client " + c.visitor.getUID());
+ logger.info("sending message to legacy client " + c.visitor.getUid());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
logger.warn("ws error", e);
@@ -167,25 +167,25 @@ public class XMPPConnection implements InitializingBean, DisposableBean, Stream.
private void onJuickMessageReply(final com.juick.Message jmsg) {
String json = messageSerializer.serialize(jmsg).toString();
List<Integer> threadUsers =
- SubscriptionsQueries.getUsersSubscribedToComments(jdbc, jmsg.getMID(), jmsg.getUser().getUID())
- .stream().map(User::getUID).collect(Collectors.toList());
+ SubscriptionsQueries.getUsersSubscribedToComments(jdbc, jmsg.getMid(), jmsg.getUser().getUid())
+ .stream().map(User::getUid).collect(Collectors.toList());
synchronized (wsHandler.getClients()) {
wsHandler.getClients().stream().filter(c ->
- (!c.legacy && c.visitor.getUID() == 0) // anonymous users
- || (!c.legacy && threadUsers.contains(c.visitor.getUID()))) // subscriptions
+ (!c.legacy && c.visitor.getUid() == 0) // anonymous users
+ || (!c.legacy && threadUsers.contains(c.visitor.getUid()))) // subscriptions
.forEach(c -> {
try {
- logger.info("sending reply to " + c.visitor.getUID());
+ logger.info("sending reply to " + c.visitor.getUid());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
logger.warn("ws error", e);
}
});
wsHandler.getClients().stream().filter(c ->
- (c.legacy && c.allReplies) || (c.legacy && c.MID == jmsg.getMID())) // legacy replies
+ (c.legacy && c.allReplies) || (c.legacy && c.MID == jmsg.getMid())) // legacy replies
.forEach(c -> {
try {
- logger.info("sending reply to legacy client " + c.visitor.getUID());
+ logger.info("sending reply to legacy client " + c.visitor.getUid());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
logger.warn("ws error", e);
diff --git a/juick-www/src/main/java/com/juick/www/Discover.java b/juick-www/src/main/java/com/juick/www/Discover.java
index 4fd8c3b6..860ad893 100644
--- a/juick-www/src/main/java/com/juick/www/Discover.java
+++ b/juick-www/src/main/java/com/juick/www/Discover.java
@@ -72,7 +72,7 @@ public class Discover {
}
}
- int visitor_uid = visitor.getUID();
+ int visitor_uid = visitor.getUid();
String title = "*" + StringEscapeUtils.escapeHtml4(paramTag.getName());
List<Integer> mids = MessagesQueries.getTag(sql, paramTag.TID, visitor_uid, paramBefore, (visitor_uid == 0) ? 40 : 20);
@@ -91,7 +91,7 @@ public class Discover {
out.println("<section id=\"content\">");
if (mids.size() > 0) {
- int vuid = visitor.getUID();
+ int vuid = visitor.getUid();
int ad_mid = AdsQueries.getAdMID(sql, vuid);
if (ad_mid > 0 && mids.indexOf(ad_mid) == -1) {
mids.add(0, ad_mid);
diff --git a/juick-www/src/main/java/com/juick/www/Home.java b/juick-www/src/main/java/com/juick/www/Home.java
index d8688b68..870c2d55 100644
--- a/juick-www/src/main/java/com/juick/www/Home.java
+++ b/juick-www/src/main/java/com/juick/www/Home.java
@@ -53,9 +53,9 @@ public class Home {
title = "Поиск: " + StringEscapeUtils.escapeHtml4(paramSearch);
mids = MessagesQueries.getSearch(sql, sqlSearch, Utils.encodeSphinx(paramSearch), paramBefore);
} else if (paramShow == null) {
- if (visitor.getUID() > 0) {
+ if (visitor.getUid() > 0) {
title = "Популярные";
- mids = MessagesQueries.getPopular(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getPopular(sql, visitor.getUid(), paramBefore);
} else {
title = "Микроблоги Juick: популярные записи";
mids = MessagesQueries.getPopular(sql, 0, paramBefore);
@@ -66,27 +66,27 @@ public class Home {
return;
} else if (paramShow.equals("my") && visitor != null) {
title = "Моя лента";
- mids = MessagesQueries.getMyFeed(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getMyFeed(sql, visitor.getUid(), paramBefore);
} else if (paramShow.equals("private") && visitor != null) {
title = "Приватные";
- mids = MessagesQueries.getPrivate(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getPrivate(sql, visitor.getUid(), paramBefore);
} else if (paramShow.equals("discuss") && visitor != null) {
title = "Обсуждения";
- mids = MessagesQueries.getDiscussions(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getDiscussions(sql, visitor.getUid(), paramBefore);
} else if (paramShow.equals("recommended") && visitor != null) {
title = "Рекомендации";
- mids = MessagesQueries.getRecommended(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getRecommended(sql, visitor.getUid(), paramBefore);
} else if (paramShow.equals("photos")) {
title = "Фотографии";
if (visitor != null) {
- mids = MessagesQueries.getPhotos(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getPhotos(sql, visitor.getUid(), paramBefore);
} else {
mids = MessagesQueries.getPhotos(sql, 0, paramBefore);
}
} else if (paramShow.equals("all")) {
title = "Все сообщения";
if (visitor != null) {
- mids = MessagesQueries.getAll(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getAll(sql, visitor.getUid(), paramBefore);
} else {
mids = MessagesQueries.getAll(sql, 0, paramBefore);
}
@@ -110,7 +110,7 @@ public class Home {
out.println("<!--noindex-->");
}
- if (visitor.getUID() > 0) {
+ if (visitor.getUid() > 0) {
out.println("<form action=\"/post\" method=\"post\" enctype=\"multipart/form-data\">");
out.println("<section id=\"newmessage\">");
out.println(" <textarea name=\"body\" placeholder=\"Новое сообщение...\"></textarea>");
@@ -129,7 +129,7 @@ public class Home {
if (mids.size() > 0) {
int ad_mid = 0;
if (paramShow == null || paramShow.equals("top") || paramShow.equals("all")) {
- int vuid = visitor.getUID();
+ int vuid = visitor.getUid();
ad_mid = AdsQueries.getAdMID(sql, vuid);
if (ad_mid > 0 && mids.indexOf(ad_mid) == -1) {
mids.add(0, ad_mid);
@@ -139,7 +139,7 @@ public class Home {
}
}
- PageTemplates.printMessages(out, sql, null, mids, visitor, visitor.getUID() == 0 ? 2 : 3, ad_mid);
+ PageTemplates.printMessages(out, sql, null, mids, visitor, visitor.getUid() == 0 ? 2 : 3, ad_mid);
}
if (mids.size() >= 20) {
@@ -160,7 +160,7 @@ public class Home {
out.println("</section>");
- PageTemplates.pageHomeColumn(out, sql, visitor, paramShow == null && paramBefore == 0 && paramSearch == null && visitor.getUID() == 0);
+ PageTemplates.pageHomeColumn(out, sql, visitor, paramShow == null && paramBefore == 0 && paramSearch == null && visitor.getUid() == 0);
PageTemplates.pageFooter(request, out, visitor, true);
PageTemplates.pageEnd(out);
diff --git a/juick-www/src/main/java/com/juick/www/Login.java b/juick-www/src/main/java/com/juick/www/Login.java
index 55cfa03c..19cc855b 100644
--- a/juick-www/src/main/java/com/juick/www/Login.java
+++ b/juick-www/src/main/java/com/juick/www/Login.java
@@ -34,7 +34,7 @@ public class Login {
protected void doGetLoginForm(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() > 0) {
+ if (visitor.getUid() > 0) {
Utils.sendTemporaryRedirect(response, "/");
return;
}
@@ -228,8 +228,8 @@ public class Login {
protected void doGetLogout(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() > 0) {
- sql.update("DELETE FROM logins WHERE user_id=?", visitor.getUID());
+ if (visitor.getUid() > 0) {
+ sql.update("DELETE FROM logins WHERE user_id=?", visitor.getUid());
}
Cookie c = new Cookie("hash", "-");
diff --git a/juick-www/src/main/java/com/juick/www/Main.java b/juick-www/src/main/java/com/juick/www/Main.java
index 35617295..4a873cf3 100644
--- a/juick-www/src/main/java/com/juick/www/Main.java
+++ b/juick-www/src/main/java/com/juick/www/Main.java
@@ -172,7 +172,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
}
} else if (uri.equals("/post")) {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() > 0) {
+ if (visitor.getUid() > 0) {
pagesNewMessage.doGetNewMessage(sql, request, response, visitor);
} else {
Utils.sendTemporaryRedirect(response, "/login");
@@ -185,7 +185,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
}
} else if (uri.startsWith("/pm/")) {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() == 0) {
+ if (visitor.getUid() == 0) {
Utils.sendTemporaryRedirect(response, "/login");
} else {
switch (uri) {
@@ -269,7 +269,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
if (mid > 0) {
com.juick.User author = com.juick.server.MessagesQueries.getMessageAuthor(sql, mid);
if (author != null) {
- Utils.sendPermanentRedirect(response, "/" + author.getUName() + "/" + mid);
+ Utils.sendPermanentRedirect(response, "/" + author.getName() + "/" + mid);
return;
}
}
@@ -277,14 +277,14 @@ public class Main extends HttpServlet implements Stream.StreamListener {
} else if (uri.matches("^/[^/]+$")) {
com.juick.User user = com.juick.server.UserQueries.getUserByName(sql, request.getRequestURI().substring(1));
if (user != null) {
- Utils.sendPermanentRedirect(response, "/" + user.getUName() + "/");
+ Utils.sendPermanentRedirect(response, "/" + user.getName() + "/");
} else {
Errors.doGet404(sql, request, response);
}
} else if (uri.matches("^/.+/.*")) {
String uriparts[] = uri.split("/");
com.juick.User user = com.juick.server.UserQueries.getUserByName(sql, uriparts[1]);
- if (user != null && user.getUName().equals(uriparts[1]) && !user.Banned) {
+ if (user != null && user.getName().equals(uriparts[1]) && !user.isBanned()) {
if (uriparts.length == 2) { // http://juick.com/username/
pagesUser.doGetBlog(sql, sqlSearch, request, response, user);
} else if (uriparts[2].equals("tags")) {
@@ -302,8 +302,8 @@ public class Main extends HttpServlet implements Stream.StreamListener {
if (mid > 0) {
com.juick.User author = com.juick.server.MessagesQueries.getMessageAuthor(sql, mid);
if (author != null) {
- if (!author.getUName().equals(user.getUName())) {
- Utils.sendPermanentRedirect(response, "/" + author.getUName() + "/" + mid);
+ if (!author.getName().equals(user.getName())) {
+ Utils.sendPermanentRedirect(response, "/" + author.getName() + "/" + mid);
} else {
pagesUserThread.doGetThread(sql, request, response, mid);
}
@@ -314,8 +314,8 @@ public class Main extends HttpServlet implements Stream.StreamListener {
Errors.doGet404(sql, request, response);
}
}
- } else if (user != null && !user.Banned) {
- Utils.sendPermanentRedirect(response, "/" + user.getUName() + "/" + (uriparts.length > 2 ? uriparts[2] : ""));
+ } else if (user != null && !user.isBanned()) {
+ Utils.sendPermanentRedirect(response, "/" + user.getName() + "/" + (uriparts.length > 2 ? uriparts[2] : ""));
} else {
Errors.doGet404(sql, request, response);
}
@@ -341,7 +341,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
switch (uri) {
case "/post": {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() > 0 && !visitor.Banned) {
+ if (visitor.getUid() > 0 && !visitor.isBanned()) {
pagesNewMessage.doPostMessage(sql, request, response, xmpp, visitor);
} else {
response.sendError(403);
@@ -350,7 +350,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
}
case "/comment": {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() > 0 && !visitor.Banned) {
+ if (visitor.getUid() > 0 && !visitor.isBanned()) {
pagesNewMessage.doPostComment(sql, request, response, xmpp, visitor);
} else {
response.sendError(403);
@@ -359,7 +359,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
}
case "/like": {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() > 0 && !visitor.Banned) {
+ if (visitor.getUid() > 0 && !visitor.isBanned()) {
pagesNewMessage.doPostRecomm(sql, request, response, xmpp, visitor);
} else {
response.sendError(403);
@@ -368,7 +368,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
}
case "/pm/send": {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() > 0 && !visitor.Banned) {
+ if (visitor.getUid() > 0 && !visitor.isBanned()) {
pm.doPostPM(sql, request, response, xmpp, visitor);
} else {
response.sendError(403);
diff --git a/juick-www/src/main/java/com/juick/www/NewMessage.java b/juick-www/src/main/java/com/juick/www/NewMessage.java
index aaa3e550..310ede73 100644
--- a/juick-www/src/main/java/com/juick/www/NewMessage.java
+++ b/juick-www/src/main/java/com/juick/www/NewMessage.java
@@ -101,7 +101,7 @@ public class NewMessage {
}
void printUserTags(JdbcTemplate sql, PrintWriter out, com.juick.User visitor) {
- List<Tag> tags = TagQueries.getUserTagsAll(sql, visitor.getUID());
+ List<Tag> tags = TagQueries.getUserTagsAll(sql, visitor.getUid());
if (tags.isEmpty()) {
return;
@@ -128,7 +128,7 @@ public class NewMessage {
String taglink = "";
try {
taglink = "<a onclick=\"return addTag('" + StringEscapeUtils.escapeHtml4(tags.get(i).getName()) + "')\" href=\"/" +
- visitor.getUName() + "/?tag=" + URLEncoder.encode(tags.get(i).getName(), "utf-8") +
+ visitor.getName() + "/?tag=" + URLEncoder.encode(tags.get(i).getName(), "utf-8") +
"\" title=\"" + tags.get(i).UsageCnt + "\">" + StringEscapeUtils.escapeHtml4(tags.get(i).getName()) + "</a>";
} catch (UnsupportedEncodingException e) {
}
@@ -197,8 +197,8 @@ public class NewMessage {
}
String attachmentType = attachmentFName != null ? attachmentFName.substring(attachmentFName.length() - 3) : null;
- int mid = MessagesQueries.createMessage(sql, visitor.getUID(), body, attachmentType, tags);
- SubscriptionsQueries.subscribeMessage(sql, mid, visitor.getUID());
+ int mid = MessagesQueries.createMessage(sql, visitor.getUid(), body, attachmentType, tags);
+ SubscriptionsQueries.subscribeMessage(sql, mid, visitor.getUid());
Message xmsg = new Message();
xmsg.from = new JID("juick", "juick.com", null);
@@ -209,7 +209,7 @@ public class NewMessage {
xmsg.addChild(jmsg);
Nickname nick = new Nickname();
- nick.Nickname = "@" + jmsg.getUser().getUName();
+ nick.Nickname = "@" + jmsg.getUser().getName();
xmsg.addChild(nick);
if (attachmentFName != null) {
@@ -236,7 +236,7 @@ public class NewMessage {
for (String tag : tagsArr) {
tagsStr2 += " *" + tag;
}
- xmsg.body = "@" + jmsg.getUser().getUName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid;
+ xmsg.body = "@" + jmsg.getUser().getName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid;
xmsg.to = new JID("juick", "s2s.juick.com", null);
xmpp.send(xmsg);
@@ -289,12 +289,12 @@ public class NewMessage {
out.println("<section id=\"content\">");
out.println("<h1>Сообщение опубликовано</h1>");
out.println("<p>Поделитесь своим новым постом в социальных сетях:</p>");
- if (CrosspostQueries.getTwitterTokens(sql, visitor.getUID()).isPresent()) {
+ if (CrosspostQueries.getTwitterTokens(sql, visitor.getUid()).isPresent()) {
out.println("<p class=\"social\"><a href=\"https://twitter.com/intent/tweet?text=" + URLEncoder.encode(sharetwi, "utf-8") + "\" class=\"ico32-twi sharenew\">Отправить в Twitter</a></p>");
}
out.println("<p class=\"social\"><a href=\"http://www.livejournal.com/update.bml?subject=" + URLEncoder.encode(hashtags, "utf-8") + "&event=" + sharelj + "&prop_taglist=" + URLEncoder.encode(tagscomma, "utf-8") + "\" target=\"_blank\" class=\"ico32-lj sharenew\">Отправить в LiveJournal</a></p>");
out.println("<p class=\"social\"><a href=\"https://vk.com/share.php?url=" + url + "\" class=\"ico32-vk sharenew\">Отправить в ВКонтакте</a></p>");
- if (CrosspostQueries.getFacebookToken(sql, visitor.getUID()).isPresent()) {
+ if (CrosspostQueries.getFacebookToken(sql, visitor.getUid()).isPresent()) {
out.println("<p class=\"social\"><a href=\"https://www.facebook.com/sharer/sharer.php?u=" + url + "\" class=\"ico32-fb sharenew\">Отправить в Facebook</a></p>");
}
out.println("<p class=\"social\"><a href=\"https://plus.google.com/share?url=" + url + "\" class=\"ico32-gp sharenew\">Отправить в Google+</a></p>");
@@ -337,7 +337,7 @@ public class NewMessage {
}
body = body.replace("\r", "");
- if ((msg.ReadOnly && msg.getUser().getUID() != visitor.getUID()) || UserQueries.isInBLAny(sql, msg.getUser().getUID(), visitor.getUID()) || (reply != null && UserQueries.isInBLAny(sql, reply.getUser().getUID(), visitor.getUID()))) {
+ if ((msg.ReadOnly && msg.getUser().getUid() != visitor.getUid()) || UserQueries.isInBLAny(sql, msg.getUser().getUid(), visitor.getUid()) || (reply != null && UserQueries.isInBLAny(sql, reply.getUser().getUid(), visitor.getUid()))) {
response.sendError(403);
return;
}
@@ -363,8 +363,8 @@ public class NewMessage {
}
String attachmentType = attachmentFName != null ? attachmentFName.substring(attachmentFName.length() - 3) : null;
- int ridnew = MessagesQueries.createReply(sql, mid, rid, visitor.getUID(), body, attachmentType);
- SubscriptionsQueries.subscribeMessage(sql, mid, visitor.getUID());
+ int ridnew = MessagesQueries.createReply(sql, mid, rid, visitor.getUid(), body, attachmentType);
+ SubscriptionsQueries.subscribeMessage(sql, mid, visitor.getUid());
Message xmsg = new Message();
xmsg.from = new JID("juick", "juick.com", null);
@@ -380,7 +380,7 @@ public class NewMessage {
}
Nickname nick = new Nickname();
- nick.Nickname = "@" + jmsg.getUser().getUName();
+ nick.Nickname = "@" + jmsg.getUser().getName();
xmsg.addChild(nick);
if (attachmentFName != null) {
@@ -404,7 +404,7 @@ public class NewMessage {
if (xmpp != null) {
- xmsg.body = "Reply by @" + jmsg.getUser().getUName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew;
+ xmsg.body = "Reply by @" + jmsg.getUser().getName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew;
xmsg.to = new JID("juick", "s2s.juick.com", null);
xmpp.send(xmsg);
@@ -418,7 +418,7 @@ public class NewMessage {
logger.warn("XMPP unavailable");
}
- Utils.sendTemporaryRedirect(response, "/" + msg.getUser().getUName() + "/" + mid + "#" + ridnew);
+ Utils.sendTemporaryRedirect(response, "/" + msg.getUser().getName() + "/" + mid + "#" + ridnew);
}
public void doPostRecomm(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, Stream xmpp, com.juick.User visitor) throws ServletException, IOException {
@@ -432,12 +432,12 @@ public class NewMessage {
response.sendError(404);
return;
}
- if (msg.getUser().getUID() == visitor.getUID()) {
+ if (msg.getUser().getUid() == visitor.getUid()) {
response.sendError(403);
return;
}
- boolean res = MessagesQueries.recommendMessage(sql, mid, visitor.getUID());
+ boolean res = MessagesQueries.recommendMessage(sql, mid, visitor.getUid());
if (res) {
if (xmpp != null) {
@@ -445,7 +445,7 @@ public class NewMessage {
xmsg.from = new JID("juick", "juick.com", null);
xmsg.to = new JID("recomm", "s2s.juick.com", null);
JuickMessage jmsg = new JuickMessage();
- jmsg.setMID(mid);
+ jmsg.setMid(mid);
jmsg.setUser(new JuickUser(visitor));
xmsg.addChild(jmsg);
xmpp.send(xmsg);
diff --git a/juick-www/src/main/java/com/juick/www/PM.java b/juick-www/src/main/java/com/juick/www/PM.java
index 8190d65b..2e35ec1c 100644
--- a/juick-www/src/main/java/com/juick/www/PM.java
+++ b/juick-www/src/main/java/com/juick/www/PM.java
@@ -50,7 +50,7 @@ public class PM {
protected void doGetInbox(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException, PebbleException {
String title = "PM: Inbox";
- List<com.juick.Message> msgs = PMQueries.getLastPMInbox(sql, visitor.getUID());
+ List<com.juick.Message> msgs = PMQueries.getLastPMInbox(sql, visitor.getUid());
msgs.forEach(m -> m.setText(Utils.formatMessage(m.getText())));
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
@@ -67,7 +67,7 @@ public class PM {
protected void doGetSent(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException, PebbleException {
String title = "PM: Sent";
- List<com.juick.Message> msgs = PMQueries.getLastPMSent(sql, visitor.getUID());
+ List<com.juick.Message> msgs = PMQueries.getLastPMSent(sql, visitor.getUid());
String uname = request.getParameter("uname");
if (!UserUtils.checkUserNameValid(uname)) {
@@ -103,12 +103,12 @@ public class PM {
return;
}
- if (UserQueries.isInBLAny(sql, uid, visitor.getUID())) {
+ if (UserQueries.isInBLAny(sql, uid, visitor.getUid())) {
response.sendError(403);
return;
}
- if (PMQueries.createPM(sql, visitor.getUID(), uid, body)) {
+ if (PMQueries.createPM(sql, visitor.getUid(), uid, body)) {
if (xmpp != null) {
Message msg = new Message();
msg.from = new JID("juick", "juick.com", null);
@@ -127,12 +127,12 @@ public class PM {
Message mm = new Message();
mm.to = new JID(jid);
mm.type = Message.Type.chat;
- if (PMQueries.havePMinRoster(sql, visitor.getUID(), jid)) {
- mm.from = new JID(jmsg.getUser().getUName(), "juick.com", "Juick");
+ if (PMQueries.havePMinRoster(sql, visitor.getUid(), jid)) {
+ mm.from = new JID(jmsg.getUser().getName(), "juick.com", "Juick");
mm.body = body;
} else {
mm.from = new JID("juick", "juick.com", "Juick");
- mm.body = "Private message from @" + jmsg.getUser().getUName() + ":\n" + body;
+ mm.body = "Private message from @" + jmsg.getUser().getName() + ":\n" + body;
}
xmpp.send(mm);
}
diff --git a/juick-www/src/main/java/com/juick/www/PageTemplates.java b/juick-www/src/main/java/com/juick/www/PageTemplates.java
index f8873739..4f7e17b7 100644
--- a/juick-www/src/main/java/com/juick/www/PageTemplates.java
+++ b/juick-www/src/main/java/com/juick/www/PageTemplates.java
@@ -72,7 +72,7 @@ public class PageTemplates {
out.println("<![endif]-->");
out.println("</head>");
out.flush();
- if (visitor.getUID() > 0) {
+ if (visitor.getUid() > 0) {
out.println("<body id=\"body\" data-hash=\"" + visitor.getAuthHash() + "\">");
} else {
out.println("<body id=\"body\">");
@@ -93,7 +93,7 @@ public class PageTemplates {
}
out.println("/></form></div>");
out.println(" <section id=\"headdiv\">");
- if (visitor.getUID() > 0) {
+ if (visitor.getUid() > 0) {
out.print(" <nav id=\"user\"><ul>");
out.print("<li><a href=\"/?show=my\">Моя лента</a></li>");
out.print("<li><a href=\"/pm/inbox\">Приватные</a></li>");
@@ -102,7 +102,7 @@ public class PageTemplates {
out.println("</ul></nav>");
out.print(" <nav id=\"actions\"><ul>");
out.print("<li><a href=\"/#post\">Написать</a></li>");
- out.print("<li><a href=\"/" + visitor.getUName() + "\">@" + visitor.getUName() + "</a></li>");
+ out.print("<li><a href=\"/" + visitor.getName() + "\">@" + visitor.getName() + "</a></li>");
out.print("<li><a href=\"/logout\">Выйти</a></li>");
out.println("</ul></nav>");
} else {
@@ -151,7 +151,7 @@ public class PageTemplates {
String queryString = request.getQueryString();
String requestURI = request.getRequestURI();
- if (sapeon && sape != null && (visitor.getUID() == 0 || visitor.getUID() == 1) && queryString == null) {
+ if (sapeon && sape != null && (visitor.getUid() == 0 || visitor.getUid() == 1) && queryString == null) {
String links = sape.getPageLinks(requestURI, request.getCookies()).render();
if (links != null && !links.isEmpty()) {
out.print("<br/>Спонсоры: " + links);
@@ -284,7 +284,7 @@ public class PageTemplates {
for (int i = 0; i < msgs.size(); i++) {
com.juick.Message msg = msgs.get(i);
- if (msg.getMID() == ad_mid) {
+ if (msg.getMid() == ad_mid) {
msgs.remove(i);
msgs.add(0, msg);
break;
@@ -294,43 +294,43 @@ public class PageTemplates {
List<Integer> blUIDs = new ArrayList<Integer>(20);
if (visitor != null) {
for (Message msg : msgs) {
- blUIDs.add(msg.getUser().getUID());
+ blUIDs.add(msg.getUser().getUid());
}
- blUIDs = UserQueries.checkBL(sql, visitor.getUID(), blUIDs);
+ blUIDs = UserQueries.checkBL(sql, visitor.getUid(), blUIDs);
}
for (Message msg : msgs) {
- List<Tag> tags = MessagesQueries.getMessageTags(sql, msg.getMID());
+ List<Tag> tags = MessagesQueries.getMessageTags(sql, msg.getMid());
String tagsStr = formatTags(tags);
if (msg.ReadOnly) {
tagsStr += "<a>readonly</a>";
}
- if (msg.Privacy < 0) {
+ if (msg.getPrivacy() < 0) {
tagsStr += "<a>friends</a>";
}
- if (msg.getMID() == ad_mid) {
+ if (msg.getMid() == ad_mid) {
tagsStr += "<a>реклама</a>";
}
String txt;
- if (msg.Tags.stream().anyMatch(t -> t.getName().equals("code"))) {
+ if (msg.getTags().stream().anyMatch(t -> t.getName().equals("code"))) {
txt = Utils.formatMessageCode(msg.getText());
} else {
txt = Utils.formatMessage(msg.getText());
}
- out.println("<article data-mid=\"" + msg.getMID() + "\">");
+ out.println("<article data-mid=\"" + msg.getMid() + "\">");
out.println(" <header class=\"u\">");
- out.println(" @<a href=\"/" + msg.getUser().getUName() + "/\">" + msg.getUser().getUName() + "</a>:");
- out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.getUser().getUName() + "/\"><img src=\"//i.juick.com/a/" + msg.getUser().getUID() + ".png\" alt=\"" + msg.getUser().getUName() + "\"/></a></div>");
- out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.getUser().getUName() + "/" + msg.getMID() + "\"><time datetime=\"" + sdfSQL.format(msg.getDate()) + "Z\" title=\"" + sdfSQL.format(msg.getDate()) + " GMT\">" + formatDate(msg.TimeAgo, msg.getDate()) + "</time></a></div>");
+ out.println(" @<a href=\"/" + msg.getUser().getName() + "/\">" + msg.getUser().getName() + "</a>:");
+ out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.getUser().getName() + "/\"><img src=\"//i.juick.com/a/" + msg.getUser().getUid() + ".png\" alt=\"" + msg.getUser().getName() + "\"/></a></div>");
+ out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.getUser().getName() + "/" + msg.getMid() + "\"><time datetime=\"" + sdfSQL.format(msg.getDate()) + "Z\" title=\"" + sdfSQL.format(msg.getDate()) + " GMT\">" + formatDate(msg.TimeAgo, msg.getDate()) + "</time></a></div>");
out.println(" <div class=\"msg-tags\">" + tagsStr + "</div>");
out.println(" </header>");
if (msg.AttachmentType != null) {
- String fname = msg.getMID() + "." + msg.AttachmentType;
+ String fname = msg.getMid() + "." + msg.AttachmentType;
out.println(" <p class=\"ir\"><a href=\"//i.juick.com/photos-512/" + fname + "\" data-fname=\"" + fname + "\"><img src=\"//i.juick.com/photos-512/" + fname + "\" alt=\"\"/></a></p>");
}
out.println(" <p>" + txt + "</p>");
@@ -338,21 +338,21 @@ public class PageTemplates {
out.println(" <div class=\"irbr\"></div>");
}
out.print(" <nav class=\"l\">");
- msg.ReadOnly |= blUIDs.contains(msg.getUser().getUID());
- if (visitor.getUID() == 0) {
+ msg.ReadOnly |= blUIDs.contains(msg.getUser().getUid());
+ if (visitor.getUid() == 0) {
out.print("<a href=\"#\" class=\"a-login\">Мне нравится</a>");
} else {
- out.print("<a href=\"/post?body=!+%23" + msg.getMID() + "\" class=\"a-like\">Мне нравится</a>");
+ out.print("<a href=\"/post?body=!+%23" + msg.getMid() + "\" class=\"a-like\">Мне нравится</a>");
}
- if (visitor.getUID() == 0 && !msg.ReadOnly) {
- out.print("<a href=\"/"+ msg.getMID() + "\" class=\"a-login\">Комментировать</a> ");
- } else if (visitor.getUID() > 0 && (!msg.ReadOnly || visitor.getUID() == msg.getUser().getUID())) {
- out.print("<a class=\"a-comment\" href=\"/" + msg.getMID() + "\">Комментировать</a> ");
+ if (visitor.getUid() == 0 && !msg.ReadOnly) {
+ out.print("<a href=\"/"+ msg.getMid() + "\" class=\"a-login\">Комментировать</a> ");
+ } else if (visitor.getUid() > 0 && (!msg.ReadOnly || visitor.getUid() == msg.getUser().getUid())) {
+ out.print("<a class=\"a-comment\" href=\"/" + msg.getMid() + "\">Комментировать</a> ");
}
- if (visitor.getUID() > 0 && msg.Privacy < 0 && msg.getUser().getUID() == visitor.getUID()) {
+ if (visitor.getUid() > 0 && msg.getPrivacy() < 0 && msg.getUser().getUid() == visitor.getUid()) {
out.print(" <a href=\"#\" class=\"a-privacy\">Открыть доступ</a>");
}
- if (visitor.getUID() > 0 && visitor.getUID() == 3694) {
+ if (visitor.getUid() > 0 && visitor.getUid() == 3694) {
out.print(" <a href=\"#\" class=\"a-popular-plus\">+</a>");
out.print(" <a href=\"#\" class=\"a-popular-minus\">-</a>");
out.print(" <a href=\"#\" class=\"a-popular-delete\">x</a>");
@@ -361,10 +361,10 @@ public class PageTemplates {
out.print(" <nav class=\"s\">");
if (msg.Likes > 0) {
- out.print("<a href=\"/" + msg.getUser().getUName() + "/" + msg.getMID() + "\" class=\"likes\"><i data-icon=\"ei-heart\" data-size=\"s\"></i>&nbsp;" + msg.Likes + "</a>");
+ out.print("<a href=\"/" + msg.getUser().getName() + "/" + msg.getMid() + "\" class=\"likes\"><i data-icon=\"ei-heart\" data-size=\"s\"></i>&nbsp;" + msg.Likes + "</a>");
}
if (msg.Replies > 0) {
- out.print("<a href=\"/" + msg.getUser().getUName() + "/" + msg.getMID() + "\" class=\"replies\"><i data-icon=\"ei-comment\" data-size=\"s\"></i>&nbsp;" + msg.Replies + "</a>");
+ out.print("<a href=\"/" + msg.getUser().getName() + "/" + msg.getMid() + "\" class=\"replies\"><i data-icon=\"ei-comment\" data-size=\"s\"></i>&nbsp;" + msg.Replies + "</a>");
}
out.println("</nav>");
out.print("</article>");
diff --git a/juick-www/src/main/java/com/juick/www/Settings.java b/juick-www/src/main/java/com/juick/www/Settings.java
index 6be16acc..5c25564f 100644
--- a/juick-www/src/main/java/com/juick/www/Settings.java
+++ b/juick-www/src/main/java/com/juick/www/Settings.java
@@ -71,7 +71,7 @@ public class Settings {
protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, PebbleException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() == 0) {
+ if (visitor.getUid() == 0) {
response.sendRedirect("/login");
}
List<String> pages = Arrays.asList("main", "password", "about", "auth-email", "privacy");
@@ -95,17 +95,17 @@ public class Settings {
List<String> hours = IntStream.rangeClosed(0, 23).boxed()
.map(i -> StringUtils.leftPad(String.format("%d", i), 2, "0")).collect(Collectors.toList());
context.put("hours", hours);
- context.put("fbstatus", CrosspostQueries.isFBCrossPostEnabled(sql, visitor.getUID()));
- context.put("twitter_name", CrosspostQueries.getTwitterName(sql, visitor.getUID()));
- context.put("telegram_name", CrosspostQueries.getTelegramName(sql, visitor.getUID()));
+ context.put("fbstatus", CrosspostQueries.isFBCrossPostEnabled(sql, visitor.getUid()));
+ context.put("twitter_name", CrosspostQueries.getTwitterName(sql, visitor.getUid()));
+ context.put("telegram_name", CrosspostQueries.getTelegramName(sql, visitor.getUid()));
context.put("notify_options", SubscriptionsQueries.getNotifyOptions(sql, visitor));
context.put("userinfo", UserQueries.getUserInfo(sql, visitor));
if (page.equals("auth-email")) {
try {
String account = sql.queryForObject("SELECT account FROM auth WHERE user_id=? AND protocol='email' AND authcode=?",
- String.class, visitor.getUID(), request.getParameter("code"));
- sql.update("INSERT INTO emails(user_id,email) VALUES (?,?)", visitor.getUID(), account);
- sql.update("DELETE FROM auth WHERE user_id=? AND authcode=?", visitor.getUID(), request.getParameter("code"));
+ String.class, visitor.getUid(), request.getParameter("code"));
+ sql.update("INSERT INTO emails(user_id,email) VALUES (?,?)", visitor.getUid(), account);
+ sql.update("DELETE FROM auth WHERE user_id=? AND authcode=?", visitor.getUid(), request.getParameter("code"));
context.put("result", "OK!");
} catch (EmptyResultDataAccessException e) {
context.put("result", "Sorry, code unknown.");
@@ -117,7 +117,7 @@ public class Settings {
protected void doPost(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, PebbleException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() == 0) {
+ if (visitor.getUid() == 0) {
response.sendError(400);
return;
}
@@ -134,7 +134,7 @@ public class Settings {
case "password":
if (UserQueries.updatePassword(sql, visitor, request.getParameter("password"))) {
result = "<p>Password has been changed.</p>";
- String hash = com.juick.server.UserQueries.getHashByUID(sql, visitor.getUID());
+ String hash = com.juick.server.UserQueries.getHashByUID(sql, visitor.getUid());
Cookie c = new Cookie("hash", hash);
c.setMaxAge(365 * 24 * 60 * 60);
response.addCookie(c);
@@ -158,8 +158,8 @@ public class Settings {
String avatarTmpPath = Utils.receiveMultiPartFile(request, "avatar");
if (StringUtils.isNotEmpty(avatarTmpPath)) {
String originalExtension = FilenameUtils.getExtension(avatarTmpPath);
- String originalName = String.format("%s.%s", visitor.getUID(), originalExtension);
- String targetName = String.format("%s.png", visitor.getUID());
+ String originalName = String.format("%s.%s", visitor.getUid(), originalExtension);
+ String targetName = String.format("%s.png", visitor.getUid());
Path ao = Paths.get(imgPath, "ao", originalName);
Path a = Paths.get(imgPath, "a", targetName);
Path as = Paths.get(imgPath, "as", targetName);
@@ -168,16 +168,16 @@ public class Settings {
Thumbnails.of(ao.toFile()).size(32, 32).toFile(as.toFile());
}
if (UserQueries.updateUserInfo(sql, visitor, info)) {
- result = String.format("<p>Your info is updated.</p><p><a href='/%s/'>Back to blog</a>.</p>", visitor.getUName());
+ result = String.format("<p>Your info is updated.</p><p><a href='/%s/'>Back to blog</a>.</p>", visitor.getName());
}
break;
case "jid-del":
String[] params = request.getParameter("delete").split(";", 2);
int res = -1;
if (params[0].equals("xmpp")) {
- res = sql.update("DELETE FROM jids WHERE user_id=? AND jid=?", visitor.getUID(), params[1]);
+ res = sql.update("DELETE FROM jids WHERE user_id=? AND jid=?", visitor.getUid(), params[1]);
} else if (params[0].equals("xmpp-unauth")) {
- res = sql.update("DELETE FROM auth WHERE user_id=? AND protocol='xmpp' AND account=?", visitor.getUID(), params[1]);
+ res = sql.update("DELETE FROM auth WHERE user_id=? AND protocol='xmpp' AND account=?", visitor.getUid(), params[1]);
}
if (res == 1) {
result = "<p>Deleted. <a href=\"/settings\">Back</a>.</p>";
@@ -198,11 +198,11 @@ public class Settings {
case "email-add":
try {
sql.queryForObject("SELECT authcode FROM auth WHERE user_id=? AND protocol='email' " +
- "AND account=?", String.class, visitor.getUID(), request.getParameter("account"));
+ "AND account=?", String.class, visitor.getUid(), request.getParameter("account"));
} catch (EmptyResultDataAccessException e) {
String authCode = UserUtils.generateHash(8);
if (sql.update("INSERT INTO auth(user_id,protocol,account,authcode) VALUES (?,'email',?,?)",
- visitor.getUID(), request.getParameter("account"), authCode) > 0) {
+ visitor.getUid(), request.getParameter("account"), authCode) > 0) {
Session session = Session.getDefaultInstance(System.getProperties());
try {
MimeMessage message = new MimeMessage(session);
@@ -225,18 +225,18 @@ public class Settings {
}
break;
case "email-del":
- if (sql.update("DELETE FROM emails WHERE user_id=? AND email=?", visitor.getUID(), request.getParameter("account")) > 0) {
+ if (sql.update("DELETE FROM emails WHERE user_id=? AND email=?", visitor.getUid(), request.getParameter("account")) > 0) {
result = "<p>Deleted. <a href=\"/settings\">Back</a>.</p>";
} else {
result = "<p>An error occured while deleting.</p>";
}
break;
case "email-subscr":
- sql.update("UPDATE emails SET subscr_hour=NULL WHERE user_id=?", visitor.getUID());
+ sql.update("UPDATE emails SET subscr_hour=NULL WHERE user_id=?", visitor.getUid());
String email = request.getParameter("account");
if (StringUtils.isNotEmpty(email)) {
sql.update("UPDATE emails SET subscr_hour=? WHERE user_id=? AND email=?",
- request.getParameter("time"), visitor.getUID(), email);
+ request.getParameter("time"), visitor.getUid(), email);
result = String.format("<p>Saved! Will send to <strong>%s</strong> at <strong>%s:00 GMT</strong>." +
"</p><p><a href=\"/settings\">Back</a></p>", email, request.getParameter("time"));
} else {
@@ -244,8 +244,8 @@ public class Settings {
}
break;
case "twitter-del":
- sql.update("DELETE FROM twitter WHERE user_id=?", visitor.getUID());
- sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=1741", visitor.getUID());
+ sql.update("DELETE FROM twitter WHERE user_id=?", visitor.getUid());
+ sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=1741", visitor.getUid());
for (Cookie cookie : request.getCookies()) {
if (cookie.getName().equals("request_token")) {
cookie.setMaxAge(0);
@@ -259,21 +259,21 @@ public class Settings {
result = "<p><a href=\"/settings\">Back</a></p>";
break;
case "telegram-del":
- sql.update("DELETE FROM telegram WHERE user_id=?", visitor.getUID());
+ sql.update("DELETE FROM telegram WHERE user_id=?", visitor.getUid());
result = "<p><a href=\"/settings\">Back</a></p>";
break;
case "facebook-disable":
- sql.update("UPDATE facebook SET crosspost=0 WHERE user_id=?", visitor.getUID());
- sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=5863", visitor.getUID());
+ sql.update("UPDATE facebook SET crosspost=0 WHERE user_id=?", visitor.getUid());
+ sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=5863", visitor.getUid());
result = "<p><a href=\"/settings\">Back</a></p>";
break;
case "facebook-enable":
- sql.update("UPDATE facebook SET crosspost=1 WHERE user_id=?", visitor.getUID());
- sql.update("INSERT INTO subscr_users(user_id,suser_id,jid,active) VALUES (?,5863,'juick@facebook.juick.com',1)", visitor.getUID());
+ sql.update("UPDATE facebook SET crosspost=1 WHERE user_id=?", visitor.getUid());
+ sql.update("INSERT INTO subscr_users(user_id,suser_id,jid,active) VALUES (?,5863,'juick@facebook.juick.com',1)", visitor.getUid());
result = "<p><a href=\"/settings\">Back</a></p>";
break;
case "vk-del":
- sql.update("DELETE FROM vk WHERE user_id=?", visitor.getUID());
+ sql.update("DELETE FROM vk WHERE user_id=?", visitor.getUid());
result = "<p><a href=\"/settings\">Back</a></p>";
break;
default:
diff --git a/juick-www/src/main/java/com/juick/www/SignUp.java b/juick-www/src/main/java/com/juick/www/SignUp.java
index 43c82a9a..ea40c810 100644
--- a/juick-www/src/main/java/com/juick/www/SignUp.java
+++ b/juick-www/src/main/java/com/juick/www/SignUp.java
@@ -97,7 +97,7 @@ public class SignUp {
String action = request.getParameter("action");
if (action.charAt(0) == 'l') {
- if (visitor.getUID() == 0) {
+ if (visitor.getUid() == 0) {
String username = request.getParameter("username");
String password = request.getParameter("password");
if (username == null || password == null || username.length() > 32 || password.isEmpty()) {
@@ -106,7 +106,7 @@ public class SignUp {
}
uid = com.juick.server.UserQueries.checkPassword(sql, username, password);
} else {
- uid = visitor.getUID();
+ uid = visitor.getUid();
}
if (uid <= 0) {
diff --git a/juick-www/src/main/java/com/juick/www/TwitterAuth.java b/juick-www/src/main/java/com/juick/www/TwitterAuth.java
index d4be4335..173ad7b7 100644
--- a/juick-www/src/main/java/com/juick/www/TwitterAuth.java
+++ b/juick-www/src/main/java/com/juick/www/TwitterAuth.java
@@ -48,7 +48,7 @@ public class TwitterAuth {
}
}
com.juick.User user = UserQueries.getUserByHash(sql, hash);
- if ( user == null || user.getUID() == 0) {
+ if ( user == null || user.getUid() == 0) {
response.sendError(403);
return;
}
diff --git a/juick-www/src/main/java/com/juick/www/User.java b/juick-www/src/main/java/com/juick/www/User.java
index 967d06c7..3cc38b37 100644
--- a/juick-www/src/main/java/com/juick/www/User.java
+++ b/juick-www/src/main/java/com/juick/www/User.java
@@ -58,7 +58,7 @@ public class User {
Errors.doGet404(sql, request, response);
return;
} else if (!paramTag.getName().equals(paramTagStr)) {
- String url = "/" + user.getUName() + "/?tag=" + URLEncoder.encode(paramTag.getName(), "UTF-8");
+ String url = "/" + user.getName() + "/?tag=" + URLEncoder.encode(paramTag.getName(), "UTF-8");
Utils.sendPermanentRedirect(response, url);
return;
}
@@ -79,10 +79,10 @@ public class User {
}
int privacy = 0;
- if (visitor.getUID() > 0) {
- if (user.getUID() == visitor.getUID() || visitor.getUID() == 1) {
+ if (visitor.getUid() > 0) {
+ if (user.getUid() == visitor.getUid() || visitor.getUid() == 1) {
privacy = -3;
- } else if (UserQueries.isInWL(sql, user.getUID(), visitor.getUID())) {
+ } else if (UserQueries.isInWL(sql, user.getUid(), visitor.getUid())) {
privacy = -2;
}
}
@@ -90,34 +90,34 @@ public class User {
String title;
if (paramShow == null) {
if (paramTag != null) {
- title = "Блог " + user.getUName() + ": *" + StringEscapeUtils.escapeHtml4(paramTag.getName());
- mids = MessagesQueries.getUserTag(sql, user.getUID(), paramTag.TID, privacy, paramBefore);
+ title = "Блог " + user.getName() + ": *" + StringEscapeUtils.escapeHtml4(paramTag.getName());
+ mids = MessagesQueries.getUserTag(sql, user.getUid(), paramTag.TID, privacy, paramBefore);
} else if (paramSearch != null) {
- title = "Блог " + user.getUName() + ": " + StringEscapeUtils.escapeHtml4(paramSearch);
- mids = MessagesQueries.getUserSearch(sql, sqlSearch, user.getUID(), Utils.encodeSphinx(paramSearch), privacy, paramBefore);
+ title = "Блог " + user.getName() + ": " + StringEscapeUtils.escapeHtml4(paramSearch);
+ mids = MessagesQueries.getUserSearch(sql, sqlSearch, user.getUid(), Utils.encodeSphinx(paramSearch), privacy, paramBefore);
} else {
- title = "Блог " + user.getUName();
- mids = MessagesQueries.getUserBlog(sql, user.getUID(), privacy, paramBefore);
+ title = "Блог " + user.getName();
+ mids = MessagesQueries.getUserBlog(sql, user.getUid(), privacy, paramBefore);
}
} else if (paramShow.equals("recomm")) {
- title = "Рекомендации " + user.getUName();
- mids = MessagesQueries.getUserRecommendations(sql, user.getUID(), paramBefore);
+ title = "Рекомендации " + user.getName();
+ mids = MessagesQueries.getUserRecommendations(sql, user.getUid(), paramBefore);
} else if (paramShow.equals("photos")) {
- title = "Фотографии " + user.getUName();
- mids = MessagesQueries.getUserPhotos(sql, user.getUID(), privacy, paramBefore);
+ title = "Фотографии " + user.getName();
+ mids = MessagesQueries.getUserPhotos(sql, user.getUid(), privacy, paramBefore);
} else {
Errors.doGet404(sql, request, response);
return;
}
- if (visitor.getUID() == 0) {
- pageUserRefCookie(request, response, user.getUID());
+ if (visitor.getUid() == 0) {
+ pageUserRefCookie(request, response, user.getUid());
}
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String head = "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"@" +
- user.getUName() + "\" href=\"//rss.juick.com/" + user.getUName() + "/blog\"/>";
+ user.getName() + "\" href=\"//rss.juick.com/" + user.getName() + "/blog\"/>";
if (paramTag != null && TagQueries.getTagNoIndex(sql, paramTag.TID)) {
head += "<meta name=\"robots\" content=\"noindex,nofollow\"/>";
} else if (paramBefore > 0 || paramShow != null) {
@@ -136,7 +136,7 @@ public class User {
StringEscapeUtils.escapeHtml4(paramTag.getName()) + "</b></a></p>");
}
- PageTemplates.printMessages(out, sql, user, mids, visitor, visitor.getUID() == 0 ? 4 : 5, 0);
+ PageTemplates.printMessages(out, sql, user, mids, visitor, visitor.getUid() == 0 ? 4 : 5, 0);
if (mids.size() >= 20) {
String nextpage = "?before=" + mids.get(mids.size() - 1);
@@ -163,14 +163,14 @@ public class User {
protected void doGetTags(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() == 0) {
- pageUserRefCookie(request, response, user.getUID());
+ if (visitor.getUid() == 0) {
+ pageUserRefCookie(request, response, user.getUid());
}
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String head = "<meta name=\"robots\" content=\"noindex,nofollow\"/>";
- PageTemplates.pageHead(out, visitor, "Теги " + user.getUName(), head);
+ PageTemplates.pageHead(out, visitor, "Теги " + user.getName(), head);
PageTemplates.pageNavigation(out, visitor, null);
pageUserColumn(out, sql, user, visitor);
@@ -186,28 +186,28 @@ public class User {
protected void doGetFriends(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() == 0) {
- pageUserRefCookie(request, response, user.getUID());
+ if (visitor.getUid() == 0) {
+ pageUserRefCookie(request, response, user.getUid());
}
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String head = "<meta name=\"robots\" content=\"noindex\"/>";
- PageTemplates.pageHead(out, visitor, "Подписки " + user.getUName(), head);
+ PageTemplates.pageHead(out, visitor, "Подписки " + user.getName(), head);
PageTemplates.pageNavigation(out, visitor, null);
pageUserColumn(out, sql, user, visitor);
out.println("<section id=\"content\">");
out.println("<table class=\"users\"><tr>");
- List<com.juick.User> friends = UserQueries.getUserFriends(sql, user.getUID());
+ List<com.juick.User> friends = UserQueries.getUserFriends(sql, user.getUid());
for (int i = 0; i < friends.size(); i++) {
if (i % 3 == 0 && i > 0) {
out.print("</tr><tr>");
}
- out.print("<td><a href=\"/" + friends.get(i).getUName()
- + "/\"><img src=\"//i.juick.com/as/" + friends.get(i).getUID() + ".png\"/>"
- + friends.get(i).getUName() + "</a></td>");
+ out.print("<td><a href=\"/" + friends.get(i).getName()
+ + "/\"><img src=\"//i.juick.com/as/" + friends.get(i).getUid() + ".png\"/>"
+ + friends.get(i).getName() + "</a></td>");
}
out.println("</tr></table>");
@@ -221,28 +221,28 @@ public class User {
protected void doGetReaders(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() == 0) {
- pageUserRefCookie(request, response, user.getUID());
+ if (visitor.getUid() == 0) {
+ pageUserRefCookie(request, response, user.getUid());
}
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String head = "<meta name=\"robots\" content=\"noindex\"/>";
- PageTemplates.pageHead(out, visitor, "Читатели " + user.getUName(), head);
+ PageTemplates.pageHead(out, visitor, "Читатели " + user.getName(), head);
PageTemplates.pageNavigation(out, visitor, null);
pageUserColumn(out, sql, user, visitor);
out.println("<section id=\"content\">");
out.println("<table class=\"users\"><tr>");
- List<com.juick.User> readers = UserQueries.getUserReaders(sql, user.getUID());
+ List<com.juick.User> readers = UserQueries.getUserReaders(sql, user.getUid());
for (int i = 0; i < readers.size(); i++) {
if (i % 3 == 0 && i > 0) {
out.print("</tr><tr>");
}
- out.print("<td><a href=\"/" + readers.get(i).getUName()
- + "/\"><img src=\"//i.juick.com/as/" + readers.get(i).getUID() + ".png\"/>"
- + readers.get(i).getUName() + "</a></td>");
+ out.print("<td><a href=\"/" + readers.get(i).getName()
+ + "/\"><img src=\"//i.juick.com/as/" + readers.get(i).getUid() + ".png\"/>"
+ + readers.get(i).getName() + "</a></td>");
}
out.println("</tr></table>");
@@ -267,21 +267,21 @@ public class User {
public static void pageUserColumn(PrintWriter out, JdbcTemplate sql, com.juick.User user, com.juick.User visitor) {
out.println("<aside id=\"column\">");
- out.println(" <div id=\"ctitle\"><a href=\"./\"><img src=\"//i.juick.com/as/" + user.getUID() + ".png\" alt=\"\"/>" + user.getUName() + "</a></div>");
- if (visitor.getUID() > 0 && visitor.getUID() != user.getUID()) {
+ out.println(" <div id=\"ctitle\"><a href=\"./\"><img src=\"//i.juick.com/as/" + user.getUid() + ".png\" alt=\"\"/>" + user.getName() + "</a></div>");
+ if (visitor.getUid() > 0 && visitor.getUid() != user.getUid()) {
out.println(" <ul id=\"ctoolbar\">");
- if (UserQueries.isSubscribed(sql, visitor.getUID(), user.getUID())) {
- out.println(" <li><a href=\"/post?body=U+%40" + user.getUName() + "\" title=\"Подписан\"><div style=\"background-position: -48px 0\"></div></a></li>");
+ if (UserQueries.isSubscribed(sql, visitor.getUid(), user.getUid())) {
+ out.println(" <li><a href=\"/post?body=U+%40" + user.getName() + "\" title=\"Подписан\"><div style=\"background-position: -48px 0\"></div></a></li>");
} else {
- out.println(" <li><a href=\"/post?body=S+%40" + user.getUName() + "\" title=\"Подписаться\"><div style=\"background-position: -16px 0\"></div></a></li>");
+ out.println(" <li><a href=\"/post?body=S+%40" + user.getName() + "\" title=\"Подписаться\"><div style=\"background-position: -16px 0\"></div></a></li>");
}
- if (UserQueries.isInBL(sql, visitor.getUID(), user.getUID())) {
- out.println(" <li><a href=\"/post?body=BL+%40" + user.getUName() + "\" title=\"Разблокировать\"><div style=\"background-position: -96px 0\"></div></a></li>");
+ if (UserQueries.isInBL(sql, visitor.getUid(), user.getUid())) {
+ out.println(" <li><a href=\"/post?body=BL+%40" + user.getName() + "\" title=\"Разблокировать\"><div style=\"background-position: -96px 0\"></div></a></li>");
} else {
- out.println(" <li><a href=\"/post?body=BL+%40" + user.getUName() + "\" title=\"Заблокировать\"><div style=\"background-position: -80px 0\"></div></a></li>");
+ out.println(" <li><a href=\"/post?body=BL+%40" + user.getName() + "\" title=\"Заблокировать\"><div style=\"background-position: -80px 0\"></div></a></li>");
}
- if (!UserQueries.isInBLAny(sql, user.getUID(), visitor.getUID())) {
- out.println(" <li><a href=\"/pm/sent?uname=" + user.getUName() + "\" title=\"Написать приватное сообщение\"><div style=\"background-position: -112px 0\"></div></a></li>");
+ if (!UserQueries.isInBLAny(sql, user.getUid(), visitor.getUid())) {
+ out.println(" <li><a href=\"/pm/sent?uname=" + user.getName() + "\" title=\"Написать приватное сообщение\"><div style=\"background-position: -112px 0\"></div></a></li>");
}
out.println(" </ul>");
} else {
@@ -299,13 +299,13 @@ public class User {
out.println(" <p class=\"tags\">" + pageUserTags(sql, user, visitor, 20) + "<a href=\"./tags\" rel=\"nofollow\">...</a></p>");
out.println(" <hr/>");
out.println(" <div id=\"ustats\"><ul>");
- out.println(" <li><a href=\"./friends\">Я читаю: " + UserQueries.getStatsIRead(sql, user.getUID()) + "</a></li>");
- out.println(" <li><a href=\"./readers\">Мои подписчики: " + UserQueries.getStatsMyReaders(sql, user.getUID()) + "</a></li>");
- out.println(" <li>Сообщений: " + UserQueries.getStatsMessages(sql, user.getUID()) + "</li>");
- out.println(" <li>Комментариев: " + UserQueries.getStatsReplies(sql, user.getUID()) + "</li>");
+ out.println(" <li><a href=\"./friends\">Я читаю: " + UserQueries.getStatsIRead(sql, user.getUid()) + "</a></li>");
+ out.println(" <li><a href=\"./readers\">Мои подписчики: " + UserQueries.getStatsMyReaders(sql, user.getUid()) + "</a></li>");
+ out.println(" <li>Сообщений: " + UserQueries.getStatsMessages(sql, user.getUid()) + "</li>");
+ out.println(" <li>Комментариев: " + UserQueries.getStatsReplies(sql, user.getUid()) + "</li>");
out.println(" </ul>");
- List<com.juick.User> iread = UserQueries.getUserReadLeastPopular(sql, user.getUID(), 8);
+ List<com.juick.User> iread = UserQueries.getUserReadLeastPopular(sql, user.getUid(), 8);
if (!iread.isEmpty()) {
out.println("<table class=\"iread\"><tr>");
for (int i = 0; i < iread.size(); i++) {
@@ -313,7 +313,7 @@ public class User {
out.println("</tr><tr>");
}
com.juick.User u = iread.get(i);
- out.println("<td><a href=\"/" + u.getUName() + "/\"><img src=\"//i.juick.com/a/" + u.getUID() + ".png\" alt=\"" + u.getUName() + "\"/></a></td>");
+ out.println("<td><a href=\"/" + u.getName() + "/\"><img src=\"//i.juick.com/a/" + u.getUid() + ".png\" alt=\"" + u.getName() + "\"/></a></td>");
}
out.println("</tr></table>");
}
@@ -323,7 +323,7 @@ public class User {
}
public static String pageUserTags(JdbcTemplate sql, com.juick.User user, com.juick.User visitor, int cnt) {
- List<Tag> tags = TagQueries.getUserTagsAll(sql, user.getUID()).stream()
+ List<Tag> tags = TagQueries.getUserTagsAll(sql, user.getUid()).stream()
.sorted((e1, e2) -> Integer.compare(e2.UsageCnt, e1.UsageCnt)).collect(Collectors.toList());
int maxUsageCnt = tags.stream().map(t -> t.UsageCnt).max(Integer::max).orElse(0);
String ret = "";
diff --git a/juick-www/src/main/java/com/juick/www/UserThread.java b/juick-www/src/main/java/com/juick/www/UserThread.java
index 5f9f7e9a..3dee9697 100644
--- a/juick-www/src/main/java/com/juick/www/UserThread.java
+++ b/juick-www/src/main/java/com/juick/www/UserThread.java
@@ -40,7 +40,7 @@ public class UserThread {
protected void doGetThread(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, int MID) throws ServletException, IOException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (!MessagesQueries.canViewThread(sql, MID, visitor.getUID())) {
+ if (!MessagesQueries.canViewThread(sql, MID, visitor.getUid())) {
response.sendError(403);
return;
}
@@ -52,27 +52,27 @@ public class UserThread {
if (paramView != null) {
if (paramView.equals("list")) {
listview = true;
- if (visitor.getUID() > 0) {
- UserQueries.setUserOptionInt(sql, visitor.getUID(), "repliesview", 1);
+ if (visitor.getUid() > 0) {
+ UserQueries.setUserOptionInt(sql, visitor.getUid(), "repliesview", 1);
}
- } else if (paramView.equals("tree") && visitor.getUID() > 0) {
- UserQueries.setUserOptionInt(sql, visitor.getUID(), "repliesview", 0);
+ } else if (paramView.equals("tree") && visitor.getUid() > 0) {
+ UserQueries.setUserOptionInt(sql, visitor.getUid(), "repliesview", 0);
}
- } else if (visitor.getUID() > 0 && UserQueries.getUserOptionInt(sql, visitor.getUID(), "repliesview", 0) == 1) {
+ } else if (visitor.getUid() > 0 && UserQueries.getUserOptionInt(sql, visitor.getUid(), "repliesview", 0) == 1) {
listview = true;
}
- String title = msg.getUser().getUName() + ": " + msg.getTagsString();
+ String title = msg.getUser().getName() + ": " + msg.getTagsString();
- if (visitor.getUID() > 0) {
- User.pageUserRefCookie(request, response, msg.getUser().getUID());
+ if (visitor.getUid() > 0) {
+ User.pageUserRefCookie(request, response, msg.getUser().getUid());
}
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
- String headers = "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"@" + msg.getUser().getUName() + "\" href=\"//rss.juick.com/" + msg.getUser().getUName() + "/blog\"/>";
+ String headers = "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"@" + msg.getUser().getName() + "\" href=\"//rss.juick.com/" + msg.getUser().getName() + "/blog\"/>";
if (paramView != null) {
- headers += "<link rel=\"canonical\" href=\"http://juick.com/" + msg.getUser().getUName() + "/" + msg.getMID() + "\"/>";
+ headers += "<link rel=\"canonical\" href=\"http://juick.com/" + msg.getUser().getName() + "/" + msg.getMid() + "\"/>";
}
if (msg.Hidden) {
headers += "<meta name=\"robots\" content=\"noindex\"/>";
@@ -80,7 +80,7 @@ public class UserThread {
PageTemplates.pageHead(out, visitor, title, headers);
PageTemplates.pageNavigation(out, visitor, null);
- out.println("<section id=\"content\" data-mid=\"" + msg.getMID() + "\" style=\"margin-left: 0; width: 100%\">");
+ out.println("<section id=\"content\" data-mid=\"" + msg.getMid() + "\" style=\"margin-left: 0; width: 100%\">");
printMessage(out, sql, msg, visitor);
printReplies(out, sql, msg, visitor, listview);
out.println("</section>");
@@ -92,20 +92,20 @@ public class UserThread {
}
public static com.juick.Message printMessage(PrintWriter out, JdbcTemplate sql, com.juick.Message msg, com.juick.User visitor) {
- msg.VisitorCanComment = visitor.getUID() > 0;
+ msg.VisitorCanComment = visitor.getUid() > 0;
- List<Tag> tags = MessagesQueries.getMessageTags(sql, msg.getMID());
+ List<Tag> tags = MessagesQueries.getMessageTags(sql, msg.getMid());
String tagsStr = PageTemplates.formatTags(tags);
if (msg.ReadOnly) {
tagsStr += "<a>readonly</a>";
msg.VisitorCanComment = false;
}
- if (msg.Privacy < 0) {
+ if (msg.getPrivacy() < 0) {
tagsStr += "<a>friends</a>";
}
String txt;
- if (msg.Tags.stream().anyMatch(t -> t.getName().equals("code"))) {
+ if (msg.getTags().stream().anyMatch(t -> t.getName().equals("code"))) {
txt = Utils.formatMessageCode(msg.getText());
} else {
txt = Utils.formatMessage(msg.getText());
@@ -116,24 +116,24 @@ public class UserThread {
}
out.println("<ul>");
- out.println(" <li id=\"msg-" + msg.getMID() + "\" data-mid=\"" + msg.getMID() + "\" class=\"msg msgthread\">");
+ out.println(" <li id=\"msg-" + msg.getMid() + "\" data-mid=\"" + msg.getMid() + "\" class=\"msg msgthread\">");
out.println(" <div class=\"msg-cont\">");
out.println(" <div class=\"msg-menu\"><a href=\"#\"></a></div>");
out.println(" <div class=\"msg-ts\">" + PageTemplates.formatJSLocalTime(msg.getDate()) + "</div>");
- out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.getUser().getUName() + "/\"><img src=\"//i.juick.com/a/" + msg.getUser().getUID() + ".png\" alt=\"" + msg.getUser().getUName() + "\"/></a></div>");
- out.println(" <div class=\"msg-header\">@<a href=\"/" + msg.getUser().getUName() + "/\">" + msg.getUser().getUName() + "</a>:" + tagsStr + "</div>");
+ out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.getUser().getName() + "/\"><img src=\"//i.juick.com/a/" + msg.getUser().getUid() + ".png\" alt=\"" + msg.getUser().getName() + "\"/></a></div>");
+ out.println(" <div class=\"msg-header\">@<a href=\"/" + msg.getUser().getName() + "/\">" + msg.getUser().getName() + "</a>:" + tagsStr + "</div>");
out.println(" <div class=\"msg-txt\">" + txt + "</div>");
if (msg.AttachmentType != null) {
- out.println(" <div class=\"msg-media\"><a href=\"//i.juick.com/p/" + msg.getMID() + "." + msg.AttachmentType + "\"><img src=\"//i.juick.com/photos-512/" + msg.getMID() + "." + msg.AttachmentType + "\" alt=\"\"/></a></div>");
+ out.println(" <div class=\"msg-media\"><a href=\"//i.juick.com/p/" + msg.getMid() + "." + msg.AttachmentType + "\"><img src=\"//i.juick.com/photos-512/" + msg.getMid() + "." + msg.AttachmentType + "\" alt=\"\"/></a></div>");
}
boolean visitorInBL = false;
- if (visitor.getUID() > 0) {
- if (visitor.getUID() == msg.getUser().getUID()) {
+ if (visitor.getUid() > 0) {
+ if (visitor.getUid() == msg.getUser().getUid()) {
msg.VisitorCanComment = true;
} else {
- visitorInBL = UserQueries.isInBL(sql, msg.getUser().getUID(), visitor.getUID());
+ visitorInBL = UserQueries.isInBL(sql, msg.getUser().getUid(), visitor.getUid());
if (visitorInBL) {
msg.VisitorCanComment = false;
}
@@ -141,12 +141,12 @@ public class UserThread {
}
if (msg.VisitorCanComment) {
- out.println(" <form action=\"/comment\" method=\"POST\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"mid\" value=\"" + msg.getMID() + "\"/>");
+ out.println(" <form action=\"/comment\" method=\"POST\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"mid\" value=\"" + msg.getMid() + "\"/>");
out.println(" <div class=\"msg-comment\"><div class=\"ta-wrapper\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"Написать комментарий\"></textarea></div></div>");
out.println(" </form>");
}
- List<String> recomm = MessagesQueries.getMessageRecommendations(sql, msg.getMID());
+ List<String> recomm = MessagesQueries.getMessageRecommendations(sql, msg.getMid());
if (!recomm.isEmpty()) {
out.print(" <div class=\"" + (msg.VisitorCanComment ? "msg-recomms" : "msg-comments") + "\">Рекомендовали (" + recomm.size() + "): ");
for (int i = 0; i < recomm.size(); i++) {
@@ -161,19 +161,19 @@ public class UserThread {
out.println(" </li>");
out.println(" <li id=\"mtoolbar\"><ul>");
- out.println(" <li><a href=\"/" + msg.getMID() + "\"><div style=\"background-position: -64px 0\"></div>" + msg.getMID() + "</a></li>");
- if (visitor.getUID() > 0) {
- if (visitor.getUID() != msg.getUser().getUID()) {
- if (MessagesQueries.isSubscribed(sql, visitor.getUID(), msg.getMID())) {
- out.println(" <li><a href=\"/post?body=U+%23" + msg.getMID() + "\"><div style=\"background-position: -48px 0\"></div>Подписан</a></li>");
+ out.println(" <li><a href=\"/" + msg.getMid() + "\"><div style=\"background-position: -64px 0\"></div>" + msg.getMid() + "</a></li>");
+ if (visitor.getUid() > 0) {
+ if (visitor.getUid() != msg.getUser().getUid()) {
+ if (MessagesQueries.isSubscribed(sql, visitor.getUid(), msg.getMid())) {
+ out.println(" <li><a href=\"/post?body=U+%23" + msg.getMid() + "\"><div style=\"background-position: -48px 0\"></div>Подписан</a></li>");
} else {
- out.println(" <li><a href=\"/post?body=S+%23" + msg.getMID() + "\"><div style=\"background-position: -16px 0\"></div>Подписаться</a></li>");
+ out.println(" <li><a href=\"/post?body=S+%23" + msg.getMid() + "\"><div style=\"background-position: -16px 0\"></div>Подписаться</a></li>");
}
if (!visitorInBL) {
- out.println(" <li><a href=\"/post?body=%21+%23" + msg.getMID() + "\"><div style=\"background-position: -32px 0\"></div>Рекомендовать</a></li>");
+ out.println(" <li><a href=\"/post?body=%21+%23" + msg.getMid() + "\"><div style=\"background-position: -32px 0\"></div>Рекомендовать</a></li>");
}
} else {
- out.println(" <li><a href=\"/post?body=D+%23" + msg.getMID() + "\"><div style=\"background-position: 0\"></div>Удалить</a></li>");
+ out.println(" <li><a href=\"/post?body=D+%23" + msg.getMid() + "\"><div style=\"background-position: 0\"></div>Удалить</a></li>");
}
}
out.println(" </ul></li>");
@@ -183,38 +183,38 @@ public class UserThread {
}
public static void printReplies(PrintWriter out, JdbcTemplate sql, com.juick.Message msg, com.juick.User visitor, boolean listview) {
- List<com.juick.Message> replies = MessagesQueries.getReplies(sql, msg.getMID());
+ List<com.juick.Message> replies = MessagesQueries.getReplies(sql, msg.getMid());
List<Integer> blUIDs = new ArrayList<Integer>();
for (int i = 0; i < replies.size(); i++) {
com.juick.Message reply = replies.get(i);
- if (reply.getUser().getUID() != msg.getUser().getUID() && !blUIDs.contains(reply.getUser().getUID())) {
- blUIDs.add(reply.getUser().getUID());
+ if (reply.getUser().getUid() != msg.getUser().getUid() && !blUIDs.contains(reply.getUser().getUid())) {
+ blUIDs.add(reply.getUser().getUid());
}
- if (reply.ReplyTo > 0) {
+ if (reply.getReplyto() > 0) {
boolean added = false;
for (int n = 0; n < replies.size(); n++) {
- if (replies.get(n).getRID() == reply.ReplyTo) {
+ if (replies.get(n).getRid() == reply.getReplyto()) {
replies.get(n).childs.add(reply);
added = true;
break;
}
}
if (!added) {
- reply.ReplyTo = 0;
+ reply.setReplyto(0);
}
}
}
if (!replies.isEmpty()) {
- if (visitor.getUID() > 0 && msg.getUser().getUID() == visitor.getUID()) {
+ if (visitor.getUid() > 0 && msg.getUser().getUid() == visitor.getUid()) {
for (Message reply : replies) {
reply.VisitorCanComment = true;
}
- } else if (visitor.getUID() > 0 && msg.VisitorCanComment) {
- blUIDs = UserQueries.checkBL(sql, visitor.getUID(), blUIDs);
+ } else if (visitor.getUid() > 0 && msg.VisitorCanComment) {
+ blUIDs = UserQueries.checkBL(sql, visitor.getUid(), blUIDs);
for (Message reply : replies) {
- reply.VisitorCanComment = reply.getUser().getUID() == visitor.getUID() || !blUIDs.contains(reply.getUser().getUID());
+ reply.VisitorCanComment = reply.getUser().getUid() == visitor.getUid() || !blUIDs.contains(reply.getUser().getUid());
}
} else {
for (Message reply : replies) {
@@ -268,9 +268,9 @@ public class UserThread {
for (int i = 0; i < replies.size(); i++) {
com.juick.Message msg = replies.get(i);
- if (msg.ReplyTo == ReplyTo) {
+ if (msg.getReplyto() == ReplyTo) {
- out.print(" <li id=\"" + msg.getRID() + "\" class=\"msg\" style=\"");
+ out.print(" <li id=\"" + msg.getRid() + "\" class=\"msg\" style=\"");
if (margin > 0) {
out.print("margin-left: " + margin + "px;");
}
@@ -280,26 +280,26 @@ public class UserThread {
out.println("\">");
out.println(" <div class=\"msg-cont\">");
out.println(" <div class=\"msg-header\">");
- if (!msg.getUser().Banned) {
- out.println(" @<a href=\"/" + msg.getUser().getUName() + "/\">" + msg.getUser().getUName() + "</a>:");
- out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.getUser().getUName() + "/\"><img src=\"//i.juick.com/a/" + msg.getUser().getUID() + ".png\" alt=\"" + msg.getUser().getUName() + "\"/></a></div>");
+ if (!msg.getUser().isBanned()) {
+ out.println(" @<a href=\"/" + msg.getUser().getName() + "/\">" + msg.getUser().getName() + "</a>:");
+ out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.getUser().getName() + "/\"><img src=\"//i.juick.com/a/" + msg.getUser().getUid() + ".png\" alt=\"" + msg.getUser().getName() + "\"/></a></div>");
} else {
out.println(" [удалено]:");
out.println(" <div class=\"msg-avatar\"><img src=\"//i.juick.com/av-96.png\"/></div>");
}
out.println(" <div class=\"msg-menu\"><a href=\"#\" class=\"a-thread-links\"></a></div>");
- out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.getMID() + "#" + msg.getRID() + "\" title=\"" + PageTemplates.sdfSQL.format(msg.getDate()) + " GMT\">" + PageTemplates.formatDate(msg.TimeAgo, msg.getDate()) + "</a></div>");
+ out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.getMid() + "#" + msg.getRid() + "\" title=\"" + PageTemplates.sdfSQL.format(msg.getDate()) + " GMT\">" + PageTemplates.formatDate(msg.TimeAgo, msg.getDate()) + "</a></div>");
out.println(" </div>");
out.println(" <div class=\"msg-txt\">" + Utils.formatMessage(msg.getText()) + "</div>");
if (msg.AttachmentType != null) {
- out.println(" <div class=\"msg-media\"><a href=\"//i.juick.com/p/" + msg.getMID() + "-" + msg.getRID() + "." + msg.AttachmentType + "\"><img src=\"//i.juick.com/photos-512/" + msg.getMID() + "-" + msg.getRID() + "." + msg.AttachmentType + "\" alt=\"\"/></a></div>");
+ out.println(" <div class=\"msg-media\"><a href=\"//i.juick.com/p/" + msg.getMid() + "-" + msg.getRid() + "." + msg.AttachmentType + "\"><img src=\"//i.juick.com/photos-512/" + msg.getMid() + "-" + msg.getRid() + "." + msg.AttachmentType + "\" alt=\"\"/></a></div>");
}
- out.print(" <div class=\"msg-links\">/" + msg.getRID());
- if (msg.ReplyTo > 0) {
- out.print(" в ответ на <a href=\"#" + msg.ReplyTo + "\">/" + msg.ReplyTo + "</a>");
+ out.print(" <div class=\"msg-links\">/" + msg.getRid());
+ if (msg.getReplyto() > 0) {
+ out.print(" в ответ на <a href=\"#" + msg.getReplyto() + "\">/" + msg.getReplyto() + "</a>");
}
if (msg.VisitorCanComment) {
- out.println(" &#183; <a href=\"/post?body=%23" + msg.getMID() + "/" + msg.getRID() + "%20\" class=\"a-thread-comment\">Ответить</a></div>");
+ out.println(" &#183; <a href=\"/post?body=%23" + msg.getMid() + "/" + msg.getRid() + "%20\" class=\"a-thread-comment\">Ответить</a></div>");
out.println(" <div class=\"msg-comment\" style=\"display: none\"></div>");
} else if (visitor == null) {
out.println(" &#183; <a href=\"#\" class=\"a-login\">Ответить</a></div>");
@@ -313,9 +313,9 @@ public class UserThread {
out.println(" </li>");
if (ReplyTo == 0 && childs > 1 && replies.size() > 10) {
- printTree(out, msg.childs, visitor, msg.getRID(), margin + 20, true);
+ printTree(out, msg.childs, visitor, msg.getRid(), margin + 20, true);
} else if (childs > 0) {
- printTree(out, msg.childs, visitor, msg.getRID(), margin + 20, hidden);
+ printTree(out, msg.childs, visitor, msg.getRid(), margin + 20, hidden);
}
}
}
@@ -323,32 +323,32 @@ public class UserThread {
public static void printList(PrintWriter out, List<com.juick.Message> replies, com.juick.User visitor) {
for (Message msg : replies) {
- out.print(" <li id=\"" + msg.getRID() + "\" class=\"msg\">");
+ out.print(" <li id=\"" + msg.getRid() + "\" class=\"msg\">");
out.println(" <div class=\"msg-cont\">");
out.println(" <div class=\"msg-header\">");
- if (!msg.getUser().Banned) {
- out.println(" @<a href=\"/" + msg.getUser().getUName() + "/\">" + msg.getUser().getUName() + "</a>:");
- out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.getUser().getUName() + "/\"><img src=\"//i.juick.com/a/" + msg.getUser().getUID() + ".png\" alt=\"" + msg.getUser().getUName() + "\"/></a></div>");
+ if (!msg.getUser().isBanned()) {
+ out.println(" @<a href=\"/" + msg.getUser().getName() + "/\">" + msg.getUser().getName() + "</a>:");
+ out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.getUser().getName() + "/\"><img src=\"//i.juick.com/a/" + msg.getUser().getUid() + ".png\" alt=\"" + msg.getUser().getName() + "\"/></a></div>");
} else {
out.println(" [удалено]:");
out.println(" <div class=\"msg-avatar\"><img src=\"//i.juick.com/av-96.png\"/></div>");
}
out.println(" <div class=\"msg-menu\"><a href=\"#\" class=\"a-thread-links\"></a></div>");
- out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.getMID() + "#" + msg.getRID() + "\" title=\"" + PageTemplates.sdfSQL.format(msg.getDate()) + " GMT\">" + PageTemplates.formatDate(msg.TimeAgo, msg.getDate()) + "</a></div>");
+ out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.getMid() + "#" + msg.getRid() + "\" title=\"" + PageTemplates.sdfSQL.format(msg.getDate()) + " GMT\">" + PageTemplates.formatDate(msg.TimeAgo, msg.getDate()) + "</a></div>");
out.println(" </div>");
out.println(" <div class=\"msg-txt\">" + Utils.formatMessage(msg.getText()) + "</div>");
if (msg.AttachmentType != null) {
- out.println(" <div class=\"msg-media\"><a href=\"//i.juick.com/p/" + msg.getMID() + "-" + msg.getRID() + "." + msg.AttachmentType + "\"><img src=\"//i.juick.com/photos-512/" + msg.getMID() + "-" + msg.getRID() + "." + msg.AttachmentType + "\" alt=\"\"/></a></div>");
+ out.println(" <div class=\"msg-media\"><a href=\"//i.juick.com/p/" + msg.getMid() + "-" + msg.getRid() + "." + msg.AttachmentType + "\"><img src=\"//i.juick.com/photos-512/" + msg.getMid() + "-" + msg.getRid() + "." + msg.AttachmentType + "\" alt=\"\"/></a></div>");
}
- out.print(" <div class=\"msg-links\">/" + msg.getRID());
- if (msg.ReplyTo > 0) {
- out.print(" в ответ на <a href=\"#" + msg.ReplyTo + "\">/" + msg.ReplyTo + "</a>");
+ out.print(" <div class=\"msg-links\">/" + msg.getRid());
+ if (msg.getReplyto() > 0) {
+ out.print(" в ответ на <a href=\"#" + msg.getReplyto() + "\">/" + msg.getReplyto() + "</a>");
}
if (msg.VisitorCanComment) {
out.println(" &#183; <a href=\"#\" class=\"a-thread-comment\">Ответить</a></div>");
out.println(" <div class=\"msg-comment\" style=\"display: none\"></div>");
- } else if (visitor.getUID() == 0) {
- out.println(" <div class=\"msg-links\"><a href=\"/post?body=%23" + msg.getMID() + "/" + msg.getRID() + "%20\" class=\"a-thread-comment\">Ответить</a></div>");
+ } else if (visitor.getUid() == 0) {
+ out.println(" <div class=\"msg-links\"><a href=\"/post?body=%23" + msg.getMid() + "/" + msg.getRid() + "%20\" class=\"a-thread-comment\">Ответить</a></div>");
}
out.println(" </div>");
out.println(" </li>");
diff --git a/juick-www/src/main/java/com/juick/www/Utils.java b/juick-www/src/main/java/com/juick/www/Utils.java
index c236ac62..988ecb17 100644
--- a/juick-www/src/main/java/com/juick/www/Utils.java
+++ b/juick-www/src/main/java/com/juick/www/Utils.java
@@ -86,8 +86,8 @@ public class Utils {
String hash = getCookie(request, "hash");
if (hash != null) {
com.juick.User visitor = com.juick.server.UserQueries.getUserByHash(sql, hash);
- if (response != null && visitor.getUID() > 0) {
- response.setHeader("X-Username", visitor.getUName());
+ if (response != null && visitor.getUid() > 0) {
+ response.setHeader("X-Username", visitor.getName());
}
return visitor;
} else {
diff --git a/juick-www/src/main/resources/views/pm_inbox.html b/juick-www/src/main/resources/views/pm_inbox.html
index d8fbf4ce..36b3e511 100644
--- a/juick-www/src/main/resources/views/pm_inbox.html
+++ b/juick-www/src/main/resources/views/pm_inbox.html
@@ -6,10 +6,10 @@
<li class="msg">
<div class="msg-cont">
<div class="msg-header">
- @<a href="/{{ msg.getUser().getUName() }}/">{{ msg.getUser().getUName() }}</a>:
+ @<a href="/{{ msg.getUser().getName() }}/">{{ msg.getUser().getName() }}</a>:
<div class="msg-avatar">
- <a href="/{{ msg.getUser().getUName() }}/">
- <img src="//i.juick.com/a/{{ msg.getUser().getUID() }}.png" alt="{{ msg.getUser().getUName() }}"/>
+ <a href="/{{ msg.getUser().getName() }}/">
+ <img src="//i.juick.com/a/{{ msg.getUser().getUID() }}.png" alt="{{ msg.getUser().getName() }}"/>
</a>
</div>
<div class="msg-ts">{{ msg.getDate() }}</div>
@@ -18,7 +18,7 @@
<div class="msg-txt">{{ msg.getText() | raw }}</div>
<form action="/pm/send" method="POST" enctype="multipart/form-data">
- <input type="hidden" name="uname" value="{{ msg.getUser().getUName() }}"/>
+ <input type="hidden" name="uname" value="{{ msg.getUser().getName() }}"/>
<div class="msg-comment">
<div class="ta-wrapper">
<textarea name="body" rows="1" class="replypm" placeholder="Написать ответ"></textarea>
diff --git a/juick-www/src/main/resources/views/pm_sent.html b/juick-www/src/main/resources/views/pm_sent.html
index e03b3a7d..7c6fb686 100644
--- a/juick-www/src/main/resources/views/pm_sent.html
+++ b/juick-www/src/main/resources/views/pm_sent.html
@@ -13,10 +13,10 @@
<li class="msg">
<div class="msg-cont">
<div class="msg-header">
- @<a href="/{{ msg.getUser().getUName() }}/">{{ msg.getUser().getUName() }}</a>:
+ @<a href="/{{ msg.getUser().getName() }}/">{{ msg.getUser().getName() }}</a>:
<div class="msg-avatar">
- <a href="/{{ msg.getUser().getUName() }}/">
- <img src="//i.juick.com/a/{{ msg.getUser().getUID() }}.png" alt="{{ msg.getUser().getUName() }}"/>
+ <a href="/{{ msg.getUser().getName() }}/">
+ <img src="//i.juick.com/a/{{ msg.getUser().getUID() }}.png" alt="{{ msg.getUser().getName() }}"/>
</a>
</div>
<div class="msg-ts">{{ msg.getDate() }}</div>
diff --git a/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java b/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java
index c603a4d3..9400aad7 100644
--- a/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java
+++ b/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java
@@ -106,9 +106,9 @@ public class ConnectionRouter extends Connection implements Runnable {
if (jid.Username != null && jid.Username.equals("recomm")) {
sendJuickRecommendation(jmsg);
} else {
- if (jmsg.getRID() > 0) {
+ if (jmsg.getRid() > 0) {
sendJuickComment(jmsg);
- } else if (jmsg.getMID() > 0) {
+ } else if (jmsg.getMid() > 0) {
sendJuickMessage(jmsg);
}
}
@@ -142,32 +142,32 @@ public class ConnectionRouter extends Connection implements Runnable {
List<String> jids = new ArrayList<>();
if (jmsg.FriendsOnly) {
- jids = SubscriptionsQueries.getJIDSubscribedToUser(xmpp.jdbc, jmsg.getUser().getUID(), jmsg.FriendsOnly);
+ jids = SubscriptionsQueries.getJIDSubscribedToUser(xmpp.jdbc, jmsg.getUser().getUid(), jmsg.FriendsOnly);
} else {
- List<User> users = SubscriptionsQueries.getSubscribedUsers(xmpp.jdbc, jmsg.getUser().getUID(), jmsg.getMID());
+ List<User> users = SubscriptionsQueries.getSubscribedUsers(xmpp.jdbc, jmsg.getUser().getUid(), jmsg.getMid());
for (User user : users) {
- for (String jid : UserQueries.getJIDsbyUID(xmpp.jdbc, user.getUID())) {
+ for (String jid : UserQueries.getJIDsbyUID(xmpp.jdbc, user.getUid())) {
jids.add(jid);
}
}
}
- String txt = "@" + jmsg.getUser().getUName() + ":" + jmsg.getTagsString() + "\n";
+ String txt = "@" + jmsg.getUser().getName() + ":" + jmsg.getTagsString() + "\n";
String attachment = jmsg.getAttachmentURL();
if (attachment != null) {
txt += attachment + "\n";
}
txt += jmsg.getText() + "\n\n";
- txt += "#" + jmsg.getMID() + " http://juick.com/" + jmsg.getMID();
+ txt += "#" + jmsg.getMid() + " http://juick.com/" + jmsg.getMid();
Nickname nick = new Nickname();
- nick.Nickname = "@" + jmsg.getUser().getUName();
+ nick.Nickname = "@" + jmsg.getUser().getName();
com.juick.xmpp.Message msg = new com.juick.xmpp.Message();
msg.from = xmpp.bot.getJid();
msg.body = txt;
msg.type = Message.Type.chat;
- msg.thread = "juick-" + jmsg.getMID();
+ msg.thread = "juick-" + jmsg.getMid();
msg.addChild(jmsg);
msg.addChild(nick);
if (attachment != null) {
@@ -187,19 +187,19 @@ public class ConnectionRouter extends Connection implements Runnable {
String replyQuote;
String replyTo;
- users = SubscriptionsQueries.getUsersSubscribedToComments(xmpp.jdbc, jmsg.getMID(), jmsg.getUser().getUID());
- com.juick.Message replyMessage = jmsg.ReplyTo > 0 ? MessagesQueries.getReply(xmpp.jdbc, jmsg.getMID(), jmsg.ReplyTo)
- : MessagesQueries.getMessage(xmpp.jdbc, jmsg.getMID());
- replyTo = replyMessage.getUser().getUName();
- com.juick.Message fullReply = MessagesQueries.getReply(xmpp.jdbc, jmsg.getMID(), jmsg.getRID());
+ users = SubscriptionsQueries.getUsersSubscribedToComments(xmpp.jdbc, jmsg.getMid(), jmsg.getUser().getUid());
+ com.juick.Message replyMessage = jmsg.getReplyto() > 0 ? MessagesQueries.getReply(xmpp.jdbc, jmsg.getMid(), jmsg.getReplyto())
+ : MessagesQueries.getMessage(xmpp.jdbc, jmsg.getMid());
+ replyTo = replyMessage.getUser().getName();
+ com.juick.Message fullReply = MessagesQueries.getReply(xmpp.jdbc, jmsg.getMid(), jmsg.getRid());
replyQuote = fullReply.getReplyQuote();
- String txt = "Reply by @" + jmsg.getUser().getUName() + ":\n" + replyQuote + "\n@" + replyTo + " ";
+ String txt = "Reply by @" + jmsg.getUser().getName() + ":\n" + replyQuote + "\n@" + replyTo + " ";
String attachment = jmsg.getAttachmentURL();
if (attachment != null) {
txt += attachment + "\n";
}
- txt += jmsg.getText() + "\n\n" + "#" + jmsg.getMID() + "/" + jmsg.getRID() + " http://juick.com/" + jmsg.getMID() + "#" + jmsg.getRID();
+ txt += jmsg.getText() + "\n\n" + "#" + jmsg.getMid() + "/" + jmsg.getRid() + " http://juick.com/" + jmsg.getMid() + "#" + jmsg.getRid();
com.juick.xmpp.Message msg = new com.juick.xmpp.Message();
msg.from = xmpp.bot.getJid();
@@ -207,7 +207,7 @@ public class ConnectionRouter extends Connection implements Runnable {
msg.type = Message.Type.chat;
msg.addChild(jmsg);
for (User user : users) {
- for (String jid : UserQueries.getJIDsbyUID(xmpp.jdbc, user.getUID())) {
+ for (String jid : UserQueries.getJIDsbyUID(xmpp.jdbc, user.getUid())) {
msg.to = new JID(jid);
xmpp.sendOut(msg);
}
@@ -217,18 +217,18 @@ public class ConnectionRouter extends Connection implements Runnable {
public void sendJuickRecommendation(JuickMessage recomm) {
List<User> users;
JuickMessage jmsg;
- jmsg = new JuickMessage(MessagesQueries.getMessage(xmpp.jdbc, recomm.getMID()));
+ jmsg = new JuickMessage(MessagesQueries.getMessage(xmpp.jdbc, recomm.getMid()));
users = SubscriptionsQueries.getUsersSubscribedToUserRecommendations(xmpp.jdbc,
- recomm.getUser().getUID(), recomm.getMID(), jmsg.getUser().getUID());
+ recomm.getUser().getUid(), recomm.getMid(), jmsg.getUser().getUid());
- String txt = "Recommended by @" + recomm.getUser().getUName() + ":\n";
- txt += "@" + jmsg.getUser().getUName() + ":" + jmsg.getTagsString() + "\n";
+ String txt = "Recommended by @" + recomm.getUser().getName() + ":\n";
+ txt += "@" + jmsg.getUser().getName() + ":" + jmsg.getTagsString() + "\n";
String attachment = jmsg.getAttachmentURL();
if (attachment != null) {
txt += attachment + "\n";
}
txt += jmsg.getText() + "\n\n";
- txt += "#" + jmsg.getMID();
+ txt += "#" + jmsg.getMid();
if (jmsg.Replies > 0) {
if (jmsg.Replies % 10 == 1 && jmsg.Replies % 100 != 11) {
txt += " (" + jmsg.Replies + " reply)";
@@ -236,16 +236,16 @@ public class ConnectionRouter extends Connection implements Runnable {
txt += " (" + jmsg.Replies + " replies)";
}
}
- txt += " http://juick.com/" + jmsg.getMID();
+ txt += " http://juick.com/" + jmsg.getMid();
Nickname nick = new Nickname();
- nick.Nickname = "@" + jmsg.getUser().getUName();
+ nick.Nickname = "@" + jmsg.getUser().getName();
com.juick.xmpp.Message msg = new com.juick.xmpp.Message();
msg.from = xmpp.bot.getJid();
msg.body = txt;
msg.type = Message.Type.chat;
- msg.thread = "juick-" + jmsg.getMID();
+ msg.thread = "juick-" + jmsg.getMid();
msg.addChild(jmsg);
msg.addChild(nick);
if (attachment != null) {
@@ -255,7 +255,7 @@ public class ConnectionRouter extends Connection implements Runnable {
}
for (User user : users) {
- for (String jid : UserQueries.getJIDsbyUID(xmpp.jdbc, user.getUID())) {
+ for (String jid : UserQueries.getJIDsbyUID(xmpp.jdbc, user.getUid())) {
msg.to = new JID(jid);
xmpp.sendOut(msg);
}
diff --git a/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java b/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java
index 7458d892..7bb1b230 100644
--- a/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java
+++ b/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java
@@ -177,8 +177,8 @@ public class JuickBot {
}
boolean success = false;
- if (!UserQueries.isInBLAny(xmpp.jdbc, uid_to, user_from.getUID())) {
- success = PMQueries.createPM(xmpp.jdbc, user_from.getUID(), uid_to, msg.body);
+ if (!UserQueries.isInBLAny(xmpp.jdbc, uid_to, user_from.getUid())) {
+ success = PMQueries.createPM(xmpp.jdbc, user_from.getUid(), uid_to, msg.body);
}
if (success) {
@@ -201,13 +201,13 @@ public class JuickBot {
Message mm = new Message();
mm.to = new JID(jid);
mm.type = Message.Type.chat;
- inroster = PMQueries.havePMinRoster(xmpp.jdbc, user_from.getUID(), jid);
+ inroster = PMQueries.havePMinRoster(xmpp.jdbc, user_from.getUid(), jid);
if (inroster) {
- mm.from = new JID(jmsg.getUser().getUName(), "juick.com", "Juick");
+ mm.from = new JID(jmsg.getUser().getName(), "juick.com", "Juick");
mm.body = msg.body;
} else {
mm.from = new JID("juick", "juick.com", "Juick");
- mm.body = "Private message from @" + jmsg.getUser().getUName() + ":\n" + msg.body;
+ mm.body = "Private message from @" + jmsg.getUser().getName() + ":\n" + msg.body;
}
xmpp.sendOut(mm);
}
@@ -277,7 +277,7 @@ public class JuickBot {
private void commandLogin(Message m, User user_from) throws Exception {
Message reply = new Message(jid, m.from, Message.Type.chat);
- reply.body = "http://juick.com/login?" + UserQueries.getHashByUID(xmpp.jdbc, user_from.getUID());
+ reply.body = "http://juick.com/login?" + UserQueries.getHashByUID(xmpp.jdbc, user_from.getUid());
xmpp.sendOut(reply);
}
@@ -295,8 +295,8 @@ public class JuickBot {
}
if (uid_to > 0) {
- if (!UserQueries.isInBLAny(xmpp.jdbc, uid_to, user_from.getUID())) {
- if (PMQueries.createPM(xmpp.jdbc, user_from.getUID(), uid_to, body)) {
+ if (!UserQueries.isInBLAny(xmpp.jdbc, uid_to, user_from.getUid())) {
+ if (PMQueries.createPM(xmpp.jdbc, user_from.getUid(), uid_to, body)) {
jids_to = UserQueries.getJIDsbyUID(xmpp.jdbc, uid_to);
ret = 200;
} else {
@@ -326,13 +326,13 @@ public class JuickBot {
Message mm = new Message();
mm.to = new JID(jid);
mm.type = Message.Type.chat;
- haveInRoster = PMQueries.havePMinRoster(xmpp.jdbc, user_from.getUID(), jid);
+ haveInRoster = PMQueries.havePMinRoster(xmpp.jdbc, user_from.getUid(), jid);
if (haveInRoster) {
- mm.from = new JID(user_from.getUName(), "juick.com", "Juick");
+ mm.from = new JID(user_from.getName(), "juick.com", "Juick");
mm.body = body;
} else {
mm.from = new JID("juick", "juick.com", "Juick");
- mm.body = "Private message from @" + user_from.getUName() + ":\n" + body;
+ mm.body = "Private message from @" + user_from.getName() + ":\n" + body;
}
xmpp.sendOut(mm);
}
@@ -350,8 +350,8 @@ public class JuickBot {
}
private void commandBLShow(Message m, User user_from) throws Exception {
- List<User> blusers = UserQueries.getUserBLUsers(xmpp.jdbc, user_from.getUID());
- List<String> bltags = TagQueries.getUserBLTags(xmpp.jdbc, user_from.getUID());
+ List<User> blusers = UserQueries.getUserBLUsers(xmpp.jdbc, user_from.getUid());
+ List<String> bltags = TagQueries.getUserBLTags(xmpp.jdbc, user_from.getUid());
String txt = "";
if (bltags.size() > 0) {
@@ -365,7 +365,7 @@ public class JuickBot {
}
if (blusers.size() > 0) {
for (User bluser : blusers) {
- txt += "@" + bluser.getUName() + "\n";
+ txt += "@" + bluser.getName() + "\n";
}
}
if (txt.isEmpty()) {
diff --git a/server-core/src/main/java/com/juick/server/MessagesQueries.java b/server-core/src/main/java/com/juick/server/MessagesQueries.java
index 8a5c094c..9d4284bc 100644
--- a/server-core/src/main/java/com/juick/server/MessagesQueries.java
+++ b/server-core/src/main/java/com/juick/server/MessagesQueries.java
@@ -47,19 +47,19 @@ public class MessagesQueries {
@Override
public Message mapRow(ResultSet rs, int rowNum) throws SQLException {
Message msg = new Message();
- msg.setMID(rs.getInt(1));
- msg.setRID(rs.getInt(2));
- msg.ReplyTo = rs.getInt(3);
+ msg.setMid(rs.getInt(1));
+ msg.setRid(rs.getInt(2));
+ msg.setReplyto(rs.getInt(3));
User user = new User();
- user.setUID(rs.getInt(4));
- user.setUName(rs.getString(5));
- user.Banned = rs.getBoolean(6);
+ user.setUid(rs.getInt(4));
+ user.setName(rs.getString(5));
+ user.setBanned(rs.getBoolean(6));
msg.setUser(user);
msg.TimeAgo = rs.getInt(7);
msg.setDate(rs.getTimestamp(8));
msg.ReadOnly = rs.getBoolean(9);
- msg.Privacy = rs.getInt(10);
- msg.FriendsOnly = msg.Privacy < 0;
+ msg.setPrivacy(rs.getInt(10));
+ msg.FriendsOnly = msg.getPrivacy() < 0;
msg.Replies = rs.getInt(11);
msg.AttachmentType = rs.getString(12);
if (rs.getDouble(13) != 0) {
@@ -72,7 +72,7 @@ public class MessagesQueries {
// parse tags string
String tagsStr = rs.getString(18);
if (tagsStr != null) {
- Arrays.stream(tagsStr.split(" ")).forEach(t -> msg.Tags.add(new Tag(t)));
+ Arrays.stream(tagsStr.split(" ")).forEach(t -> msg.getTags().add(new Tag(t)));
}
msg.RepliesBy = rs.getString(19);
msg.setText(rs.getString(20));
@@ -272,12 +272,12 @@ public class MessagesQueries {
+ "WHERE replies.message_id=? AND replies.reply_id=?",
(rs, num) -> {
Message msg = new Message();
- msg.setMID(mid);
- msg.setRID(rid);
+ msg.setMid(mid);
+ msg.setRid(rid);
msg.setUser(new User());
- msg.getUser().setUID(rs.getInt(1));
- msg.getUser().setUName(rs.getString(2));
- msg.ReplyTo = rs.getInt(3);
+ msg.getUser().setUid(rs.getInt(1));
+ msg.getUser().setName(rs.getString(2));
+ msg.setReplyto(rs.getInt(3));
msg.setDate(rs.getTimestamp(4));
msg.AttachmentType = rs.getString(5);
msg.setText(rs.getString(6));
@@ -299,8 +299,8 @@ public class MessagesQueries {
+ "ON messages.user_id=users.id WHERE messages.message_id=?",
new Object[]{mid}, (rs, num) -> {
User res = new com.juick.User();
- res.setUID(rs.getInt(1));
- res.setUName(rs.getString(2));
+ res.setUid(rs.getInt(1));
+ res.setName(rs.getString(2));
return res;
});
} catch (EmptyResultDataAccessException e) {
diff --git a/server-core/src/main/java/com/juick/server/PMQueries.java b/server-core/src/main/java/com/juick/server/PMQueries.java
index d7855002..c79c04b6 100644
--- a/server-core/src/main/java/com/juick/server/PMQueries.java
+++ b/server-core/src/main/java/com/juick/server/PMQueries.java
@@ -73,8 +73,8 @@ public class PMQueries {
+ "WHERE pm_streams.user_id_to=? "
+ "ORDER BY pm_streams.unread DESC, pm_streams.lastmessage DESC LIMIT " + cnt, (rs, rowNum) -> {
com.juick.User u = new com.juick.User();
- u.setUID(rs.getInt(1));
- u.setUName(rs.getString(2));
+ u.setUid(rs.getInt(1));
+ u.setName(rs.getString(2));
u.setUnreadCount(rs.getInt(3));
return u;
}, uid);
@@ -88,7 +88,7 @@ public class PMQueries {
com.juick.Message msg = new com.juick.Message();
int uuid = rs.getInt(1);
msg.setUser(new User());
- msg.getUser().setUID(uuid);
+ msg.getUser().setUid(uuid);
msg.setText(rs.getString(2));
msg.setDate(rs.getTimestamp(3));
return msg;
@@ -106,8 +106,8 @@ public class PMQueries {
(rs, num) -> {
com.juick.Message msg = new com.juick.Message();
msg.setUser(new User());
- msg.getUser().setUID(rs.getInt(1));
- msg.getUser().setUName(rs.getString(2));
+ msg.getUser().setUid(rs.getInt(1));
+ msg.getUser().setName(rs.getString(2));
msg.setText(rs.getString(3));
msg.TimeAgo = rs.getInt(4);
msg.setDate(rs.getTimestamp(5));
@@ -122,8 +122,8 @@ public class PMQueries {
(rs, num) -> {
com.juick.Message msg = new com.juick.Message();
msg.setUser(new User());
- msg.getUser().setUID(rs.getInt(1));
- msg.getUser().setUName(rs.getString(2));
+ msg.getUser().setUid(rs.getInt(1));
+ msg.getUser().setName(rs.getString(2));
msg.setText(rs.getString(3));
msg.TimeAgo = rs.getInt(4);
msg.setDate(rs.getTimestamp(5));
diff --git a/server-core/src/main/java/com/juick/server/PrivacyQueries.java b/server-core/src/main/java/com/juick/server/PrivacyQueries.java
index 53b13505..40fc82c4 100644
--- a/server-core/src/main/java/com/juick/server/PrivacyQueries.java
+++ b/server-core/src/main/java/com/juick/server/PrivacyQueries.java
@@ -12,20 +12,20 @@ public class PrivacyQueries {
Removed, Added
}
public static PrivacyResult blacklistUser(JdbcTemplate jdbc, User user, User target) {
- int result = jdbc.update("DELETE FROM bl_users WHERE user_id=? AND bl_user_id=?", user.getUID(), target.getUID());
+ int result = jdbc.update("DELETE FROM bl_users WHERE user_id=? AND bl_user_id=?", user.getUid(), target.getUid());
if (result > 0) {
return PrivacyResult.Removed;
} else {
- jdbc.update("INSERT INTO bl_users(user_id,bl_user_id) VALUES (?,?)", user.getUID(), target.getUID());
+ jdbc.update("INSERT INTO bl_users(user_id,bl_user_id) VALUES (?,?)", user.getUid(), target.getUid());
return PrivacyResult.Added;
}
}
public static PrivacyResult blacklistTag(JdbcTemplate jdbc, User user, Tag tag) {
- int result = jdbc.update("DELETE FROM bl_tags WHERE user_id=? AND tag_id=?", user.getUID(), tag.TID);
+ int result = jdbc.update("DELETE FROM bl_tags WHERE user_id=? AND tag_id=?", user.getUid(), tag.TID);
if (result > 0) {
return PrivacyResult.Removed;
} else {
- jdbc.update("INSERT INTO bl_tags(user_id,tag_id) VALUES (?,?)", user.getUID(), tag.TID);
+ jdbc.update("INSERT INTO bl_tags(user_id,tag_id) VALUES (?,?)", user.getUid(), tag.TID);
return PrivacyResult.Added;
}
}
diff --git a/server-core/src/main/java/com/juick/server/ShowQueries.java b/server-core/src/main/java/com/juick/server/ShowQueries.java
index b55117c1..fde388c3 100644
--- a/server-core/src/main/java/com/juick/server/ShowQueries.java
+++ b/server-core/src/main/java/com/juick/server/ShowQueries.java
@@ -18,7 +18,7 @@ public class ShowQueries {
"AND subscr_users.user_id NOT IN (SELECT bl_user_id FROM bl_users WHERE user_id=?) " +
"AND subscr_users.user_id!=? AND users.lastmessage>UNIX_TIMESTAMP()-259200 " +
"GROUP BY subscr_users.user_id ORDER BY count(*) DESC LIMIT 10",
- String.class, forUser.getUID(), forUser.getUID(), forUser.getUID(), forUser.getUID());
+ String.class, forUser.getUid(), forUser.getUid(), forUser.getUid(), forUser.getUid());
}
public static List<String> getTopUsers(JdbcTemplate sql) {
diff --git a/server-core/src/main/java/com/juick/server/SubscriptionsQueries.java b/server-core/src/main/java/com/juick/server/SubscriptionsQueries.java
index 9a09a5cd..08d704d9 100644
--- a/server-core/src/main/java/com/juick/server/SubscriptionsQueries.java
+++ b/server-core/src/main/java/com/juick/server/SubscriptionsQueries.java
@@ -36,12 +36,12 @@ public class SubscriptionsQueries {
User author = MessagesQueries.getMessageAuthor(sql, mid);
List<User> userids = UserQueries.getUserReaders(sql, uid);
Set<Integer> set = new HashSet<>();
- set.addAll(userids.stream().map(User::getUID).collect(Collectors.toList()));
+ set.addAll(userids.stream().map(User::getUid).collect(Collectors.toList()));
List<Integer> tags = MessagesQueries.getMessageTagsIDs(sql, mid);
if (tags.size() > 0) {
List<Integer> tagUsers = sql.queryForList("SELECT suser_id FROM subscr_tags " +
"WHERE tag_id IN (" + StringUtils.arrayToCommaDelimitedString(tags.toArray()) + ") AND suser_id!=? " +
- " AND suser_id NOT IN (SELECT user_id FROM bl_users WHERE bl_user_id=?)", Integer.class, uid, author.getUID());
+ " AND suser_id NOT IN (SELECT user_id FROM bl_users WHERE bl_user_id=?)", Integer.class, uid, author.getUid());
set.addAll(tagUsers);
}
return UserQueries.getUsersByID(sql, new ArrayList<>(set));
@@ -84,19 +84,19 @@ public class SubscriptionsQueries {
}
public static boolean subscribeUser(JdbcTemplate sql, User user, User toUser) {
return sql.update("INSERT IGNORE INTO subscr_users(user_id,suser_id) VALUES (?,?)",
- toUser.getUID(), user.getUID()) == 1;
+ toUser.getUid(), user.getUid()) == 1;
}
public static boolean unSubscribeUser(JdbcTemplate sql, User user, User fromUser) {
return sql.update("DELETE FROM subscr_users WHERE suser_id=? AND user_id=?",
- user.getUID(), fromUser.getUID()) > 0;
+ user.getUid(), fromUser.getUid()) > 0;
}
public static boolean subscribeTag(JdbcTemplate sql, User user, Tag toTag) {
return sql.update("INSERT IGNORE INTO subscr_tags(tag_id,suser_id) VALUES (?,?)",
- toTag.TID, user.getUID()) == 1;
+ toTag.TID, user.getUid()) == 1;
}
public static boolean unSubscribeTag(JdbcTemplate sql, User user, Tag toTag) {
return sql.update("DELETE FROM subscr_tags WHERE tag_id=? AND suser_id=?",
- toTag.TID, user.getUID()) > 0;
+ toTag.TID, user.getUid()) > 0;
}
public static NotifyOpts getNotifyOptions(JdbcTemplate sql, User user) {
@@ -108,7 +108,7 @@ public class SubscriptionsQueries {
options.setSubscriptionsEnabled(rs.getInt(2) > 0);
options.setRecommendationsEnabled(rs.getInt(3) > 0);
return options;
- }, user.getUID());
+ }, user.getUid());
} catch (EmptyResultDataAccessException e) {
return new NotifyOpts();
}
@@ -116,10 +116,10 @@ public class SubscriptionsQueries {
public static boolean setNotifyOptions(JdbcTemplate sql, User user, NotifyOpts options) {
return sql.update("UPDATE useroptions SET jnotify=? WHERE user_id=?", options.isRepliesEnabled() ? 1 : 0,
- user.getUID()) > 0 &&
+ user.getUid()) > 0 &&
sql.update("UPDATE useroptions SET subscr_notify=? WHERE user_id=?", options.isSubscriptionsEnabled() ? 1 : 0,
- user.getUID()) > 0 &&
+ user.getUid()) > 0 &&
sql.update("UPDATE useroptions SET recommendations=? WHERE user_id=?", options.isRecommendationsEnabled() ? 1 : 0,
- user.getUID()) > 0;
+ user.getUid()) > 0;
}
}
diff --git a/server-core/src/main/java/com/juick/server/UserQueries.java b/server-core/src/main/java/com/juick/server/UserQueries.java
index bc368390..7400e6b2 100644
--- a/server-core/src/main/java/com/juick/server/UserQueries.java
+++ b/server-core/src/main/java/com/juick/server/UserQueries.java
@@ -47,9 +47,9 @@ public class UserQueries {
@Override
public User mapRow(ResultSet rs, int rowNum) throws SQLException {
User user = new User();
- user.setUID(rs.getInt(1));
- user.setUName(rs.getString(2));
- user.Banned = rs.getBoolean(3);
+ user.setUid(rs.getInt(1));
+ user.setName(rs.getString(2));
+ user.setBanned(rs.getBoolean(3));
return user;
}
}
@@ -150,8 +150,8 @@ public class UserQueries {
+ "WHERE jids.jid IN (\"" + StringUtils.arrayToDelimitedString(jids.toArray(), "\",\"") + "\")",
(rs, rowNum) -> {
com.juick.User user = new com.juick.User();
- user.setUID(rs.getInt(1));
- user.setUName(rs.getString(2));
+ user.setUid(rs.getInt(1));
+ user.setName(rs.getString(2));
user.setJID(rs.getString(3));
return user;
});
@@ -220,7 +220,7 @@ public class UserQueries {
if (realPassword.equals(password)) {
User user = UserQueries.getUserByName(sql, username);
if (user != null) {
- return user.getUID();
+ return user.getUid();
} else {
return -1;
}
@@ -233,12 +233,12 @@ public class UserQueries {
}
public static boolean updatePassword(JdbcTemplate sql, User user, String newPassword) {
- return user.getUID() > 0 && sql.update("UPDATE users SET passw=? WHERE id=?", newPassword, user.getUID()) > 0;
+ return user.getUid() > 0 && sql.update("UPDATE users SET passw=? WHERE id=?", newPassword, user.getUid()) > 0;
}
public static String updateSecretEmail(JdbcTemplate sql, User user) {
String newHash = UserUtils.generateHash(16);
- if (sql.update("INSERT INTO mail(user_id,hash) VALUES (?,?) ON DUPLICATE KEY UPDATE hash=?", user.getUID(), newHash, newHash) > 0) {
+ if (sql.update("INSERT INTO mail(user_id,hash) VALUES (?,?) ON DUPLICATE KEY UPDATE hash=?", user.getUid(), newHash, newHash) > 0) {
return newHash;
}
return "";
@@ -265,7 +265,7 @@ public class UserQueries {
info.setUrl(rs.getString(3));
info.setDescription(rs.getString(4));
return info;
- }), user.getUID());
+ }), user.getUid());
} catch (EmptyResultDataAccessException e) {
return new UserInfo();
}
@@ -273,7 +273,7 @@ public class UserQueries {
public static boolean updateUserInfo(JdbcTemplate sql, User user, UserInfo info) {
return sql.update("INSERT INTO usersinfo(user_id,fullname,country,url,descr) VALUES (?,?,?,?,?) " +
- "ON DUPLICATE KEY UPDATE fullname=?,country=?,url=?,descr=?", user.getUID(), info.getFullName(),
+ "ON DUPLICATE KEY UPDATE fullname=?,country=?,url=?,descr=?", user.getUid(), info.getFullName(),
info.getCountry(), info.getUrl(), info.getDescription(), info.getFullName(),
info.getCountry(), info.getUrl(), info.getDescription()) > 0;
}
@@ -345,8 +345,8 @@ public class UserQueries {
"ON subscr_users.user_id=users.id ORDER BY cnt LIMIT ?",
(rs, num) -> {
com.juick.User u = new com.juick.User();
- u.setUID(rs.getInt(1));
- u.setUName(rs.getString(2));
+ u.setUid(rs.getInt(1));
+ u.setName(rs.getString(2));
return u;
}, uid, cnt);
}
@@ -357,8 +357,8 @@ public class UserQueries {
"WHERE subscr_users.user_id=? ORDER BY users.nick",
(rs, num) -> {
com.juick.User u = new com.juick.User();
- u.setUID(rs.getInt(1));
- u.setUName(rs.getString(2));
+ u.setUid(rs.getInt(1));
+ u.setName(rs.getString(2));
return u;
}, uid);
}
@@ -370,8 +370,8 @@ public class UserQueries {
"ORDER BY users.nick",
(rs, num) -> {
com.juick.User u = new com.juick.User();
- u.setUID(rs.getInt(1));
- u.setUName(rs.getString(2));
+ u.setUid(rs.getInt(1));
+ u.setName(rs.getString(2));
return u;
}, uid, uid);
}
@@ -381,8 +381,8 @@ public class UserQueries {
"ON(bl_users.bl_user_id=users.id) WHERE bl_users.user_id=? ORDER BY users.nick",
(rs, num) -> {
com.juick.User u = new com.juick.User();
- u.setUID(rs.getInt(1));
- u.setUName(rs.getString(2));
+ u.setUid(rs.getInt(1));
+ u.setName(rs.getString(2));
return u;
}, uid);
}
@@ -392,9 +392,9 @@ public class UserQueries {
if (sql.update("INSERT INTO twitter(user_id,access_token,access_token_secret,uname) " +
"VALUES (?,?,?,?)" +
" ON DUPLICATE KEY UPDATE access_token=?,access_token_secret=?,uname=?",
- user.getUID(), accessToken, accessTokenSecret, screenName, accessToken, accessTokenSecret, screenName) > 0) {
+ user.getUid(), accessToken, accessTokenSecret, screenName, accessToken, accessTokenSecret, screenName) > 0) {
return sql.update("INSERT INTO subscr_users(user_id,suser_id,jid) " +
- "VALUES (?,1741,'juick\\@twitter.juick.com')", user.getUID()) > 0;
+ "VALUES (?,1741,'juick\\@twitter.juick.com')", user.getUid()) > 0;
}
return false;
@@ -445,7 +445,7 @@ public class UserQueries {
"UPDATE jids SET active=? WHERE user_id=? AND jid=?");
int newStatus = jidStatus == ActiveStatus.Active ? 1 : 0;
preparedStatement.setInt(1, newStatus);
- preparedStatement.setInt(2, user.getUID());
+ preparedStatement.setInt(2, user.getUid());
preparedStatement.setString(3, JID);
return preparedStatement;
@@ -455,22 +455,22 @@ public class UserQueries {
}
public static List<String> getAllJIDs(JdbcTemplate sql, User user) {
- return sql.queryForList("SELECT jid FROM jids WHERE user_id=?", String.class, user.getUID());
+ return sql.queryForList("SELECT jid FROM jids WHERE user_id=?", String.class, user.getUid());
}
public static List<Auth> getAuthCodes(JdbcTemplate sql, User user) {
return sql.query("SELECT account,authcode FROM auth WHERE user_id=? AND protocol='xmpp'",
- (rs, num) -> new Auth(rs.getString(1), rs.getString(2)), user.getUID());
+ (rs, num) -> new Auth(rs.getString(1), rs.getString(2)), user.getUid());
}
public static List<String> getEmails(JdbcTemplate sql, User user) {
- return sql.queryForList("SELECT email FROM emails WHERE user_id=?", String.class, user.getUID());
+ return sql.queryForList("SELECT email FROM emails WHERE user_id=?", String.class, user.getUid());
}
public static EmailOpts getEmailOpts(JdbcTemplate sql, User user) {
try {
return sql.queryForObject("SELECT email,subscr_hour FROM emails WHERE user_id=? AND subscr_hour IS NOT NULL",
- (rs, num) -> new EmailOpts(rs.getString(1), rs.getInt(2)), user.getUID());
+ (rs, num) -> new EmailOpts(rs.getString(1), rs.getInt(2)), user.getUid());
} catch (EmptyResultDataAccessException e) {
return null;
}
@@ -478,7 +478,7 @@ public class UserQueries {
public static String getEmailHash(JdbcTemplate sql, User user) {
try {
- return sql.queryForObject("SELECT hash FROM mail WHERE user_id=?", String.class, user.getUID())
+ return sql.queryForObject("SELECT hash FROM mail WHERE user_id=?", String.class, user.getUid())
+ "@mail.juick.com";
} catch (EmptyResultDataAccessException e) {
return "";
diff --git a/server-core/src/main/java/com/juick/server/protocol/JuickProtocol.java b/server-core/src/main/java/com/juick/server/protocol/JuickProtocol.java
index e9e129a9..f1e98eb9 100644
--- a/server-core/src/main/java/com/juick/server/protocol/JuickProtocol.java
+++ b/server-core/src/main/java/com/juick/server/protocol/JuickProtocol.java
@@ -68,8 +68,8 @@ public class JuickProtocol {
public ProtocolReply postMessage(User user, String input) {
List<Tag> tags = TagQueries.fromString(sql, input, false);
String body = input.substring(TagUtils.toString(tags).length());
- int mid = MessagesQueries.createMessage(sql, user.getUID(), body, null, tags);
- SubscriptionsQueries.subscribeMessage(sql, mid, user.getUID());
+ int mid = MessagesQueries.createMessage(sql, user.getUid(), body, null, tags);
+ SubscriptionsQueries.subscribeMessage(sql, mid, user.getUid());
//app.events().publishEvent(new JuickMessageEvent(app.messages().getMessage(mid)));
return new ProtocolReply("New message posted.\n#" + mid + " " + baseUri + mid,
Optional.of(json.serializeList(Collections.singletonList(MessagesQueries.getMessage(sql, mid)))));
@@ -79,7 +79,7 @@ public class JuickProtocol {
public ProtocolReply commandLast(User user, String... arguments) {
// number of + is the page count
int page = arguments[0].length() - 1;
- List<Integer> mids = MessagesQueries.getAll(sql, user.getUID(), page);
+ List<Integer> mids = MessagesQueries.getAll(sql, user.getUid(), page);
List<Message> messages = MessagesQueries.getMessages(sql, mids);
return new ProtocolReply("Last messages: \n" + String.join("\n", messages.stream().map(PlainTextFormatter::formatPost)
.collect(Collectors.toList())), Optional.of(json.serializeList(messages)));
@@ -91,8 +91,8 @@ public class JuickProtocol {
List<User> blusers;
List<String> bltags;
- blusers = UserQueries.getUserBLUsers(sql, user_from.getUID());
- bltags = TagQueries.getUserBLTags(sql, user_from.getUID());
+ blusers = UserQueries.getUserBLUsers(sql, user_from.getUid());
+ bltags = TagQueries.getUserBLTags(sql, user_from.getUid());
String txt = "";
@@ -107,7 +107,7 @@ public class JuickProtocol {
}
if (blusers.size() > 0) {
for (User bluser : blusers) {
- txt += "@" + bluser.getUName() + "\n";
+ txt += "@" + bluser.getName() + "\n";
}
}
if (txt.isEmpty()) {
@@ -175,7 +175,7 @@ public class JuickProtocol {
@UserCommand(pattern = "\\*", help = "* - Show your tags")
public ProtocolReply commandTags(User currentUser, String... args) {
- List<Tag> tags = TagQueries.getUserTagsAll(sql, currentUser.getUID());
+ List<Tag> tags = TagQueries.getUserTagsAll(sql, currentUser.getUid());
String msg = "Your tags: (tag - messages)\n" +
tags.stream()
.map(t -> String.format("\n*%s - %d", t.getName(), t.UsageCnt)).collect(Collectors.joining());
@@ -184,7 +184,7 @@ public class JuickProtocol {
@UserCommand(pattern = "!", help = "! - Show your favorite messages")
public ProtocolReply commandFavorites(User currentUser, String... args) {
- List<Integer> mids = MessagesQueries.getUserRecommendations(sql, currentUser.getUID(), 0);
+ List<Integer> mids = MessagesQueries.getUserRecommendations(sql, currentUser.getUid(), 0);
if (mids.size() > 0) {
List<Message> messages = MessagesQueries.getMessages(sql, mids);
return new ProtocolReply("Favorite messages: \n" + String.join("\n", messages.stream().map(PlainTextFormatter::formatPost)
@@ -199,7 +199,7 @@ public class JuickProtocol {
User blogUser = UserQueries.getUserByName(sql, arguments[0]);
int page = arguments[1].length();
if (blogUser != null) {
- List<Integer> mids = MessagesQueries.getUserBlog(sql, blogUser.getUID(), 0, page);
+ List<Integer> mids = MessagesQueries.getUserBlog(sql, blogUser.getUid(), 0, page);
List<Message> messages = MessagesQueries.getMessages(sql, mids);
return new ProtocolReply(String.format("Last messages from @%s:\n%s", arguments[0],
String.join("\n", messages.stream()
@@ -214,7 +214,7 @@ public class JuickProtocol {
public ProtocolReply commandDel(User user, String... args) {
try {
int mid = Integer.parseInt(args[0]);
- if (MessagesQueries.deleteMessage(sql, user.getUID(), mid)) {
+ if (MessagesQueries.deleteMessage(sql, user.getUid(), mid)) {
return new ProtocolReply(String.format("Message %s deleted", mid), Optional.empty());
}
} catch (NumberFormatException e) {
@@ -226,7 +226,7 @@ public class JuickProtocol {
@UserCommand(pattern = "^\\s*login\\s*$", patternFlags = Pattern.CASE_INSENSITIVE,
help = "LOGIN - log in to Juick website")
public ProtocolReply commandLogin(User user, String... arguments) {
- return new ProtocolReply(baseUri + "?" + UserQueries.getHashByUID(sql, user.getUID()),
+ return new ProtocolReply(baseUri + "?" + UserQueries.getHashByUID(sql, user.getUid()),
Optional.empty());
}
@@ -234,7 +234,7 @@ public class JuickProtocol {
public ProtocolReply commandMyFeed(User user, String... arguments) {
// number of # is the page count
int page = arguments[0].length() - 1;
- List<Integer> mids = MessagesQueries.getMyFeed(sql, user.getUID(), page);
+ List<Integer> mids = MessagesQueries.getMyFeed(sql, user.getUid(), page);
List<Message> messages = MessagesQueries.getMessages(sql, mids);
// TODO: add instructions for empty feed
return new ProtocolReply("Your feed: \n" + String.join("\n",
@@ -286,11 +286,11 @@ public class JuickProtocol {
}
if (uid_to > 0) {
- if (!UserQueries.isInBLAny(sql, uid_to, user_from.getUID())) {
- if (PMQueries.createPM(sql, user_from.getUID(), uid_to, body)) {
+ if (!UserQueries.isInBLAny(sql, uid_to, user_from.getUid())) {
+ if (PMQueries.createPM(sql, user_from.getUid(), uid_to, body)) {
//jid_to = UserQueries.getJIDsbyUID(sql, uid_to);
if (jid_to != null) {
- haveInRoster = PMQueries.havePMinRoster(sql, user_from.getUID(), jid_to);
+ haveInRoster = PMQueries.havePMinRoster(sql, user_from.getUid(), jid_to);
}
ret = 200;
} else {
@@ -316,11 +316,11 @@ public class JuickProtocol {
mm.to = new JID(jid_to);
mm.type = Message.Type.chat;
if (haveInRoster) {
- mm.from = new JID(user_from.getUName(), getDomain(), "Juick");
+ mm.from = new JID(user_from.getName(), getDomain(), "Juick");
mm.body = body;
} else {
mm.from = new JID("juick", getDomain(), "Juick");
- mm.body = "Private message from @" + user_from.getUName() + ":\n" + body;
+ mm.body = "Private message from @" + user_from.getName() + ":\n" + body;
}
return Collections.singletonList(mm);
}
@@ -373,13 +373,13 @@ public class JuickProtocol {
String txt = args[5];
List<Tag> messageTags = TagQueries.fromString(sql, txt, true);
if (messageTags.size() > 0) {
- if (user.getUID() != MessagesQueries.getMessageAuthor(sql, mid).getUID()) {
+ if (user.getUid() != MessagesQueries.getMessageAuthor(sql, mid).getUid()) {
return new ProtocolReply("It is not your message", Optional.empty());
}
TagQueries.updateTags(sql, mid, messageTags);
return new ProtocolReply("Tags are updated", Optional.empty());
} else {
- int newrid = MessagesQueries.createReply(sql, mid, rid, user.getUID(), txt, null);
+ int newrid = MessagesQueries.createReply(sql, mid, rid, user.getUid(), txt, null);
return new ProtocolReply("Reply posted.\n#" + mid + "/" + newrid + " "
+ baseUri + mid + "/" + newrid,
Optional.of(json.serializeList(Collections.singletonList(MessagesQueries.getReply(sql, mid, newrid)))));
@@ -397,11 +397,11 @@ public class JuickProtocol {
return new ProtocolReply("Error", Optional.empty());
}
if (subscribe) {
- if (SubscriptionsQueries.subscribeMessage(sql, mid, user.getUID())) {
+ if (SubscriptionsQueries.subscribeMessage(sql, mid, user.getUid())) {
return new ProtocolReply("Subscribed", Optional.empty());
}
} else {
- if (SubscriptionsQueries.unSubscribeMessage(sql, mid, user.getUID())) {
+ if (SubscriptionsQueries.unSubscribeMessage(sql, mid, user.getUid())) {
return new ProtocolReply("Unsubscribed from #" + mid, Optional.empty());
}
return new ProtocolReply("You was not subscribed to #" + mid, Optional.empty());
@@ -413,7 +413,7 @@ public class JuickProtocol {
public ProtocolReply commandSubscribeUser(User user, String... args) {
boolean subscribe = args[0].equalsIgnoreCase("s");
User toUser = UserQueries.getUserByName(sql, args[1]);
- if (toUser.getUID() > 0) {
+ if (toUser.getUid() > 0) {
if (subscribe) {
if (SubscriptionsQueries.subscribeUser(sql, user, toUser)) {
return new ProtocolReply("Subscribed", Optional.empty());
@@ -422,9 +422,9 @@ public class JuickProtocol {
}
} else {
if (SubscriptionsQueries.unSubscribeUser(sql, user, toUser)) {
- return new ProtocolReply("Unsubscribed from @" + toUser.getUName(), Optional.empty());
+ return new ProtocolReply("Unsubscribed from @" + toUser.getName(), Optional.empty());
}
- return new ProtocolReply("You was not subscribed to @" + toUser.getUName(), Optional.empty());
+ return new ProtocolReply("You was not subscribed to @" + toUser.getName(), Optional.empty());
}
}
return new ProtocolReply("Error", Optional.empty());
diff --git a/server-core/src/main/java/com/juick/service/MessagesServiceImpl.java b/server-core/src/main/java/com/juick/service/MessagesServiceImpl.java
index dfbc4ade..bb030ed4 100644
--- a/server-core/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/server-core/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -43,19 +43,19 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Override
public Message mapRow(ResultSet rs, int rowNum) throws SQLException {
Message msg = new Message();
- msg.setMID(rs.getInt(1));
- msg.setRID(rs.getInt(2));
- msg.ReplyTo = rs.getInt(3);
+ msg.setMid(rs.getInt(1));
+ msg.setRid(rs.getInt(2));
+ msg.setReplyto(rs.getInt(3));
User user = new User();
- user.setUID(rs.getInt(4));
- user.setUName(rs.getString(5));
- user.Banned = rs.getBoolean(6);
+ user.setUid(rs.getInt(4));
+ user.setName(rs.getString(5));
+ user.setBanned(rs.getBoolean(6));
msg.setUser(user);
msg.TimeAgo = rs.getInt(7);
msg.setDate(rs.getTimestamp(8));
msg.ReadOnly = rs.getBoolean(9);
- msg.Privacy = rs.getInt(10);
- msg.FriendsOnly = msg.Privacy < 0;
+ msg.setPrivacy(rs.getInt(10));
+ msg.FriendsOnly = msg.getPrivacy() < 0;
msg.Replies = rs.getInt(11);
msg.AttachmentType = rs.getString(12);
if (rs.getDouble(13) != 0) {
@@ -68,7 +68,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
// parse tags string
String tagsStr = rs.getString(18);
if (tagsStr != null) {
- Arrays.stream(tagsStr.split(" ")).forEach(t -> msg.Tags.add(new Tag(t)));
+ Arrays.stream(tagsStr.split(" ")).forEach(t -> msg.getTags().add(new Tag(t)));
}
msg.RepliesBy = rs.getString(19);
msg.setText(rs.getString(20));
@@ -305,12 +305,12 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
+ "WHERE replies.message_id=? AND replies.reply_id=?",
(rs, num) -> {
Message msg = new Message();
- msg.setMID(mid);
- msg.setRID(rid);
+ msg.setMid(mid);
+ msg.setRid(rid);
msg.setUser(new User());
- msg.getUser().setUID(rs.getInt(1));
- msg.getUser().setUName(rs.getString(2));
- msg.ReplyTo = rs.getInt(3);
+ msg.getUser().setUid(rs.getInt(1));
+ msg.getUser().setName(rs.getString(2));
+ msg.setReplyto(rs.getInt(3));
msg.setDate(rs.getTimestamp(4));
msg.AttachmentType = rs.getString(5);
msg.setText(rs.getString(6));
@@ -335,8 +335,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
+ "ON messages.user_id=users.id WHERE messages.message_id=?",
new Object[]{mid}, (rs, num) -> {
User res = new com.juick.User();
- res.setUID(rs.getInt(1));
- res.setUName(rs.getString(2));
+ res.setUid(rs.getInt(1));
+ res.setName(rs.getString(2));
return res;
});
} catch (EmptyResultDataAccessException e) {
diff --git a/server-core/src/main/java/com/juick/service/PMQueriesServiceImpl.java b/server-core/src/main/java/com/juick/service/PMQueriesServiceImpl.java
index 34a07682..5c28c2ba 100644
--- a/server-core/src/main/java/com/juick/service/PMQueriesServiceImpl.java
+++ b/server-core/src/main/java/com/juick/service/PMQueriesServiceImpl.java
@@ -87,8 +87,8 @@ public class PMQueriesServiceImpl extends BaseJdbcService implements PMQueriesSe
+ "ORDER BY pm_streams.unread DESC, pm_streams.lastmessage DESC LIMIT " + cnt,
(rs, rowNum) -> {
com.juick.User u = new com.juick.User();
- u.setUID(rs.getInt(1));
- u.setUName(rs.getString(2));
+ u.setUid(rs.getInt(1));
+ u.setName(rs.getString(2));
u.setUnreadCount(rs.getInt(3));
return u;
},
@@ -106,7 +106,7 @@ public class PMQueriesServiceImpl extends BaseJdbcService implements PMQueriesSe
com.juick.Message msg = new com.juick.Message();
int uuid = rs.getInt(1);
msg.setUser(new User());
- msg.getUser().setUID(uuid);
+ msg.getUser().setUid(uuid);
msg.setText(rs.getString(2));
msg.setDate(rs.getTimestamp(3));
return msg;
@@ -133,8 +133,8 @@ public class PMQueriesServiceImpl extends BaseJdbcService implements PMQueriesSe
(rs, num) -> {
com.juick.Message msg = new com.juick.Message();
msg.setUser(new User());
- msg.getUser().setUID(rs.getInt(1));
- msg.getUser().setUName(rs.getString(2));
+ msg.getUser().setUid(rs.getInt(1));
+ msg.getUser().setName(rs.getString(2));
msg.setText(rs.getString(3));
msg.TimeAgo = rs.getInt(4);
msg.setDate(rs.getTimestamp(5));
@@ -153,8 +153,8 @@ public class PMQueriesServiceImpl extends BaseJdbcService implements PMQueriesSe
(rs, num) -> {
com.juick.Message msg = new com.juick.Message();
msg.setUser(new User());
- msg.getUser().setUID(rs.getInt(1));
- msg.getUser().setUName(rs.getString(2));
+ msg.getUser().setUid(rs.getInt(1));
+ msg.getUser().setName(rs.getString(2));
msg.setText(rs.getString(3));
msg.TimeAgo = rs.getInt(4);
msg.setDate(rs.getTimestamp(5));
diff --git a/server-core/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java b/server-core/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java
index 18c789ec..7dac4073 100644
--- a/server-core/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java
+++ b/server-core/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java
@@ -24,15 +24,15 @@ public class PrivacyQueriesServiceImpl extends BaseJdbcService implements Privac
public PrivacyResult blacklistUser(final User user, final User target) {
int result = getJdbcTemplate().update(
"DELETE FROM bl_users WHERE user_id=? AND bl_user_id=?",
- user.getUID(),
- target.getUID());
+ user.getUid(),
+ target.getUid());
if (result > 0) {
return PrivacyResult.Removed;
} else {
getJdbcTemplate().update(
"INSERT INTO bl_users(user_id,bl_user_id) VALUES (?,?)",
- user.getUID(),
- target.getUID());
+ user.getUid(),
+ target.getUid());
return PrivacyResult.Added;
}
}
@@ -41,14 +41,14 @@ public class PrivacyQueriesServiceImpl extends BaseJdbcService implements Privac
public PrivacyResult blacklistTag(final User user, final Tag tag) {
int result = getJdbcTemplate().update(
"DELETE FROM bl_tags WHERE user_id=? AND tag_id=?",
- user.getUID(),
+ user.getUid(),
tag.TID);
if (result > 0) {
return PrivacyResult.Removed;
} else {
getJdbcTemplate().update(
"INSERT INTO bl_tags(user_id,tag_id) VALUES (?,?)",
- user.getUID(),
+ user.getUid(),
tag.TID);
return PrivacyResult.Added;
}
diff --git a/server-core/src/main/java/com/juick/service/ShowQueriesServiceImpl.java b/server-core/src/main/java/com/juick/service/ShowQueriesServiceImpl.java
index a6504274..2ddfeb84 100644
--- a/server-core/src/main/java/com/juick/service/ShowQueriesServiceImpl.java
+++ b/server-core/src/main/java/com/juick/service/ShowQueriesServiceImpl.java
@@ -31,10 +31,10 @@ public class ShowQueriesServiceImpl extends BaseJdbcService implements ShowQueri
"AND subscr_users.user_id!=? AND users.lastmessage>UNIX_TIMESTAMP()-259200 " +
"GROUP BY subscr_users.user_id ORDER BY count(*) DESC LIMIT 10",
String.class,
- forUser.getUID(),
- forUser.getUID(),
- forUser.getUID(),
- forUser.getUID());
+ forUser.getUid(),
+ forUser.getUid(),
+ forUser.getUid(),
+ forUser.getUid());
}
@Override
diff --git a/server-core/src/main/java/com/juick/service/SubscriptionServiceImpl.java b/server-core/src/main/java/com/juick/service/SubscriptionServiceImpl.java
index 2bf05796..f6ecb658 100644
--- a/server-core/src/main/java/com/juick/service/SubscriptionServiceImpl.java
+++ b/server-core/src/main/java/com/juick/service/SubscriptionServiceImpl.java
@@ -61,7 +61,7 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip
List<User> userids = userService.getUserReaders(uid);
Set<Integer> set = new HashSet<>();
- set.addAll(userids.stream().map(User::getUID).collect(Collectors.toList()));
+ set.addAll(userids.stream().map(User::getUid).collect(Collectors.toList()));
List<Integer> tags = messagesService.getMessageTagsIDs(mid);
if (tags.size() > 0) {
List<Integer> tagUsers = getJdbcTemplate().queryForList(
@@ -70,7 +70,7 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip
" AND suser_id NOT IN (SELECT user_id FROM bl_users WHERE bl_user_id=?)",
Integer.class,
uid,
- author.getUID());
+ author.getUid());
set.addAll(tagUsers);
}
return userService.getUsersByID(new ArrayList<>(set));
@@ -134,7 +134,7 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip
public boolean subscribeUser(final User user, final User toUser) {
return getJdbcTemplate().update(
"INSERT IGNORE INTO subscr_users(user_id,suser_id) VALUES (?,?)",
- toUser.getUID(), user.getUID()) == 1;
+ toUser.getUid(), user.getUid()) == 1;
}
@Transactional
@@ -142,7 +142,7 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip
public boolean unSubscribeUser(final User user, final User fromUser) {
return getJdbcTemplate().update(
"DELETE FROM subscr_users WHERE suser_id=? AND user_id=?",
- user.getUID(), fromUser.getUID()) > 0;
+ user.getUid(), fromUser.getUid()) > 0;
}
@Transactional
@@ -150,7 +150,7 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip
public boolean subscribeTag(final User user, final Tag toTag) {
return getJdbcTemplate().update(
"INSERT IGNORE INTO subscr_tags(tag_id,suser_id) VALUES (?,?)",
- toTag.TID, user.getUID()) == 1;
+ toTag.TID, user.getUid()) == 1;
}
@Transactional
@@ -158,7 +158,7 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip
public boolean unSubscribeTag(final User user, final Tag toTag) {
return getJdbcTemplate().update(
"DELETE FROM subscr_tags WHERE tag_id=? AND suser_id=?",
- toTag.TID, user.getUID()) > 0;
+ toTag.TID, user.getUid()) > 0;
}
@Transactional(readOnly = true)
@@ -174,7 +174,7 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip
options.setRecommendationsEnabled(rs.getInt(3) > 0);
return options;
},
- user.getUID());
+ user.getUid());
} catch (EmptyResultDataAccessException e) {
return new NotifyOpts();
}
@@ -185,12 +185,12 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip
public boolean setNotifyOptions(final User user, final NotifyOpts options) {
return getJdbcTemplate().update(
"UPDATE useroptions SET jnotify=? WHERE user_id=?", options.isRepliesEnabled() ? 1 : 0,
- user.getUID()) > 0 &&
+ user.getUid()) > 0 &&
getJdbcTemplate().update(
"UPDATE useroptions SET subscr_notify=? WHERE user_id=?", options.isSubscriptionsEnabled() ? 1 : 0,
- user.getUID()) > 0 &&
+ user.getUid()) > 0 &&
getJdbcTemplate().update(
"UPDATE useroptions SET recommendations=? WHERE user_id=?", options.isRecommendationsEnabled() ? 1 : 0,
- user.getUID()) > 0;
+ user.getUid()) > 0;
}
}
diff --git a/server-core/src/main/java/com/juick/service/UserServiceImpl.java b/server-core/src/main/java/com/juick/service/UserServiceImpl.java
index b681e3c8..63785cff 100644
--- a/server-core/src/main/java/com/juick/service/UserServiceImpl.java
+++ b/server-core/src/main/java/com/juick/service/UserServiceImpl.java
@@ -32,9 +32,9 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
@Override
public User mapRow(ResultSet rs, int rowNum) throws SQLException {
User user = new User();
- user.setUID(rs.getInt(1));
- user.setUName(rs.getString(2));
- user.Banned = rs.getBoolean(3);
+ user.setUid(rs.getInt(1));
+ user.setName(rs.getString(2));
+ user.setBanned(rs.getBoolean(3));
return user;
}
}
@@ -172,8 +172,8 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
+ "WHERE jids.jid IN (\"" + StringUtils.arrayToDelimitedString(jids.toArray(), "\",\"") + "\")",
(rs, rowNum) -> {
com.juick.User user = new com.juick.User();
- user.setUID(rs.getInt(1));
- user.setUName(rs.getString(2));
+ user.setUid(rs.getInt(1));
+ user.setName(rs.getString(2));
user.setJID(rs.getString(3));
return user;
});
@@ -260,7 +260,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
if (realPassword.equals(password)) {
User user = getUserByName(username);
if (user != null) {
- return user.getUID();
+ return user.getUid();
} else {
return -1;
}
@@ -275,7 +275,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
@Transactional
@Override
public boolean updatePassword(final User user, final String newPassword) {
- return user.getUID() > 0 && getJdbcTemplate().update("UPDATE users SET passw=? WHERE id=?", newPassword, user.getUID()) > 0;
+ return user.getUid() > 0 && getJdbcTemplate().update("UPDATE users SET passw=? WHERE id=?", newPassword, user.getUid()) > 0;
}
@Transactional
@@ -284,7 +284,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
String newHash = UserUtils.generateHash(16);
if (getJdbcTemplate().update(
"INSERT INTO mail(user_id,hash) VALUES (?,?) ON DUPLICATE KEY UPDATE hash=?",
- user.getUID(),
+ user.getUid(),
newHash,
newHash) > 0) {
return newHash;
@@ -320,7 +320,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
info.setUrl(rs.getString(3));
info.setDescription(rs.getString(4));
return info;
- }), user.getUID());
+ }), user.getUid());
} catch (EmptyResultDataAccessException e) {
return new UserInfo();
}
@@ -332,7 +332,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
return getJdbcTemplate().update(
"INSERT INTO usersinfo(user_id,fullname,country,url,descr) VALUES (?,?,?,?,?) " +
"ON DUPLICATE KEY UPDATE fullname=?,country=?,url=?,descr=?",
- user.getUID(),
+ user.getUid(),
info.getFullName(),
info.getCountry(),
info.getUrl(),
@@ -435,8 +435,8 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
"ON subscr_users.user_id=users.id ORDER BY cnt LIMIT ?",
(rs, num) -> {
com.juick.User u = new com.juick.User();
- u.setUID(rs.getInt(1));
- u.setUName(rs.getString(2));
+ u.setUid(rs.getInt(1));
+ u.setName(rs.getString(2));
return u;
},
uid,
@@ -452,8 +452,8 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
"WHERE subscr_users.user_id=? ORDER BY users.nick",
(rs, num) -> {
com.juick.User u = new com.juick.User();
- u.setUID(rs.getInt(1));
- u.setUName(rs.getString(2));
+ u.setUid(rs.getInt(1));
+ u.setName(rs.getString(2));
return u;
},
uid);
@@ -469,8 +469,8 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
"ORDER BY users.nick",
(rs, num) -> {
com.juick.User u = new com.juick.User();
- u.setUID(rs.getInt(1));
- u.setUName(rs.getString(2));
+ u.setUid(rs.getInt(1));
+ u.setName(rs.getString(2));
return u;
},
uid,
@@ -484,8 +484,8 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
"ON(bl_users.bl_user_id=users.id) WHERE bl_users.user_id=? ORDER BY users.nick",
(rs, num) -> {
com.juick.User u = new com.juick.User();
- u.setUID(rs.getInt(1));
- u.setUName(rs.getString(2));
+ u.setUid(rs.getInt(1));
+ u.setName(rs.getString(2));
return u;
}, uid);
}
@@ -497,9 +497,9 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
if (getJdbcTemplate().update("INSERT INTO twitter(user_id,access_token,access_token_secret,uname) " +
"VALUES (?,?,?,?)" +
" ON DUPLICATE KEY UPDATE access_token=?,access_token_secret=?,uname=?",
- user.getUID(), accessToken, accessTokenSecret, screenName, accessToken, accessTokenSecret, screenName) > 0) {
+ user.getUid(), accessToken, accessTokenSecret, screenName, accessToken, accessTokenSecret, screenName) > 0) {
return getJdbcTemplate().update("INSERT INTO subscr_users(user_id,suser_id,jid) " +
- "VALUES (?,1741,'juick\\@twitter.juick.com')", user.getUID()) > 0;
+ "VALUES (?,1741,'juick\\@twitter.juick.com')", user.getUid()) > 0;
}
return false;
@@ -555,7 +555,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
"UPDATE jids SET active=? WHERE user_id=? AND jid=?");
int newStatus = jidStatus == UserService.ActiveStatus.Active ? 1 : 0;
preparedStatement.setInt(1, newStatus);
- preparedStatement.setInt(2, user.getUID());
+ preparedStatement.setInt(2, user.getUid());
preparedStatement.setString(3, JID);
return preparedStatement;
@@ -568,7 +568,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
@Override
public List<String> getAllJIDs(final User user) {
return getJdbcTemplate().queryForList(
- "SELECT jid FROM jids WHERE user_id=?", String.class, user.getUID());
+ "SELECT jid FROM jids WHERE user_id=?", String.class, user.getUid());
}
@Transactional(readOnly = true)
@@ -577,13 +577,13 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
return getJdbcTemplate().query(
"SELECT account,authcode FROM auth WHERE user_id=? AND protocol='xmpp'",
(rs, num) -> new Auth(rs.getString(1), rs.getString(2)),
- user.getUID());
+ user.getUid());
}
@Transactional(readOnly = true)
@Override
public List<String> getEmails(final User user) {
- return getJdbcTemplate().queryForList("SELECT email FROM emails WHERE user_id=?", String.class, user.getUID());
+ return getJdbcTemplate().queryForList("SELECT email FROM emails WHERE user_id=?", String.class, user.getUid());
}
@Transactional(readOnly = true)
@@ -592,7 +592,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
try {
return getJdbcTemplate().queryForObject(
"SELECT email,subscr_hour FROM emails WHERE user_id=? AND subscr_hour IS NOT NULL",
- (rs, num) -> new EmailOpts(rs.getString(1), rs.getInt(2)), user.getUID());
+ (rs, num) -> new EmailOpts(rs.getString(1), rs.getInt(2)), user.getUid());
} catch (EmptyResultDataAccessException e) {
return null;
}
@@ -605,7 +605,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
return getJdbcTemplate().queryForObject(
"SELECT hash FROM mail WHERE user_id=?",
String.class,
- user.getUID())
+ user.getUid())
+ "@mail.juick.com";
} catch (EmptyResultDataAccessException e) {
return "";
diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java
index 02180888..b80b9eb9 100644
--- a/src/test/java/com/juick/tests/ApiTests.java
+++ b/src/test/java/com/juick/tests/ApiTests.java
@@ -59,7 +59,7 @@ public class ApiTests {
public void messageTests() {
int user_id = UserQueries.createUser(jdbc, "mmmme", "secret");
User user = UserQueries.getUserByUID(jdbc, user_id).orElse(new User());
- assertEquals("it should be me", "mmmme", user.getUName());
+ assertEquals("it should be me", "mmmme", user.getName());
int mid = MessagesQueries.createMessage(jdbc, user_id, "yo", null, new ArrayList<>());
Message msg = MessagesQueries.getMessage(jdbc, mid);
assertEquals("yo", msg.getText());
@@ -67,27 +67,27 @@ public class ApiTests {
calendar.setTime(msg.getDate());
assertEquals(2016, calendar.get(Calendar.YEAR));
User me = msg.getUser();
- assertEquals("mmmme", me.getUName());
- assertEquals("mmmme", MessagesQueries.getMessageAuthor(jdbc, mid).getUName());
+ assertEquals("mmmme", me.getName());
+ assertEquals("mmmme", MessagesQueries.getMessageAuthor(jdbc, mid).getName());
int tagID = TagQueries.createTag(jdbc, "weather");
Tag tag = TagQueries.getTag(jdbc, tagID);
List<Tag> tagList = new ArrayList<>();
tagList.add(tag);
int mid2 = MessagesQueries.createMessage(jdbc, user_id, "yo2", null, tagList);
Message msg2 = MessagesQueries.getMessage(jdbc, mid2);
- assertEquals(1, msg2.Tags.size());
+ assertEquals(1, msg2.getTags().size());
assertEquals("we already have ugnich", -1, UserQueries.createUser(jdbc, "ugnich", "x"));
int ugnich_id = UserQueries.createUser(jdbc, "hugnich", "x");
User ugnich = UserQueries.getUserByUID(jdbc, ugnich_id).orElse(new User());
- int rid = MessagesQueries.createReply(jdbc, msg2.getMID(), 0, ugnich.getUID(), "bla-bla", null);
+ int rid = MessagesQueries.createReply(jdbc, msg2.getMid(), 0, ugnich.getUid(), "bla-bla", null);
assertEquals(1, rid);
Message msg3 = MessagesQueries.getMessage(jdbc, mid2);
assertEquals(1, msg3.Replies);
- assertEquals("weather", msg3.Tags.get(0).getName());
- assertEquals(ugnich.getUID(), UserQueries.checkPassword(jdbc, ugnich.getUName(), "x"));
- assertEquals(-1, UserQueries.checkPassword(jdbc, ugnich.getUName(), "xy"));
- SubscriptionsQueries.subscribeMessage(jdbc, msg.getMID(), ugnich.getUID());
- assertEquals(1, SubscriptionsQueries.getUsersSubscribedToComments(jdbc, msg.getMID(), user.getUID()).size());
+ assertEquals("weather", msg3.getTags().get(0).getName());
+ assertEquals(ugnich.getUid(), UserQueries.checkPassword(jdbc, ugnich.getName(), "x"));
+ assertEquals(-1, UserQueries.checkPassword(jdbc, ugnich.getName(), "xy"));
+ SubscriptionsQueries.subscribeMessage(jdbc, msg.getMid(), ugnich.getUid());
+ assertEquals(1, SubscriptionsQueries.getUsersSubscribedToComments(jdbc, msg.getMid(), user.getUid()).size());
MessagesQueries.deleteMessage(jdbc, user_id, mid);
MessagesQueries.deleteMessage(jdbc, user_id, mid2);
String htmlTagName = ">_<";
@@ -110,7 +110,7 @@ public class ApiTests {
String expectedMessage = "New message posted";
assertEquals("should be message", true,
protocol.getReply(user, "*yo yoyo").getDescription().startsWith(expectedMessage));
- int mid = MessagesQueries.getUserBlog(jdbc, user.getUID(), -1, 0).stream().reduce((first, second) -> second).get();
+ int mid = MessagesQueries.getUserBlog(jdbc, user.getUid(), -1, 0).stream().reduce((first, second) -> second).get();
assertEquals("text should match", "yoyo",
MessagesQueries.getMessage(jdbc, mid).getText());
assertEquals("tag should match", "yo",
@@ -124,7 +124,7 @@ public class ApiTests {
assertEquals("number of subscribed users should match", 1,
SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, uid).size());
assertEquals("should be subscribed", "Subscribed",
- protocol.getReply(readerUser, "S @" + user.getUName()).getDescription());
+ protocol.getReply(readerUser, "S @" + user.getName()).getDescription());
List<User> friends = UserQueries.getUserFriends(jdbc, readerUid);
assertEquals("number of friend users should match", 2,
friends.size());
@@ -138,9 +138,9 @@ public class ApiTests {
protocol.getReply(user, "#" + mid + " yoyo").getDescription());
assertEquals("should be second reply", expectedSecondReply,
protocol.getReply(user, "#" + mid + "/1 yoyo").getDescription());
- Message reply = MessagesQueries.getReplies(jdbc, mid).stream().filter(m -> m.getRID() == 2).findFirst()
+ Message reply = MessagesQueries.getReplies(jdbc, mid).stream().filter(m -> m.getRid() == 2).findFirst()
.orElse(new Message());
- assertEquals("should be reply to first comment", 1, reply.ReplyTo);
+ assertEquals("should be reply to first comment", 1, reply.getReplyto());
String jsonReply = protocol.getReply(user, "#" + mid).getJson().orElse("");
JSONArray jsonMessages = new JSONArray(jsonReply);
Message receivedMsg = json.deserialize(jsonMessages.getJSONObject(0));
@@ -176,8 +176,8 @@ public class ApiTests {
String readerUserFeed = readerFeed.getJson().orElse("");
JSONArray readerUserFeedMessages = new JSONArray(readerUserFeed);
assertEquals("messages count should match", 1, readerUserFeedMessages.length());
- assertEquals("should be unsubscribed", "Unsubscribed from @" + user.getUName(),
- protocol.getReply(readerUser, "U @" + user.getUName()).getDescription());
+ assertEquals("should be unsubscribed", "Unsubscribed from @" + user.getName(),
+ protocol.getReply(readerUser, "U @" + user.getName()).getDescription());
assertEquals("number of readers should match", 0,
UserQueries.getUserReaders(jdbc, uid).size());
assertEquals("number of friends should match", 1,
@@ -190,7 +190,7 @@ public class ApiTests {
protocol.getReply(readerUser, "D #" + mid).getDescription());
assertEquals("should be deleted", String.format("Message %s deleted", mid),
protocol.getReply(user, "D #" + mid).getDescription());
- assertEquals("should not have messages", 0, MessagesQueries.getAll(jdbc, user.getUID(), 0).size());
+ assertEquals("should not have messages", 0, MessagesQueries.getAll(jdbc, user.getUid(), 0).size());
String allFeed = protocol.getReply(readerUser, "#").getJson().orElse("");
JSONArray allFeedMessages = new JSONArray(allFeed);
assertEquals("messages count should match", 0, allFeedMessages.length());
diff --git a/src/test/java/com/juick/tests/MessageTests.java b/src/test/java/com/juick/tests/MessageTests.java
index 3e391a67..45575ded 100644
--- a/src/test/java/com/juick/tests/MessageTests.java
+++ b/src/test/java/com/juick/tests/MessageTests.java
@@ -26,9 +26,9 @@ public class MessageTests {
IOException, SAXException {
Message msg = new Message();
msg.parseTags("test test" + (char) 0xA0 + "2 test3");
- assertEquals("First tag must be", "test", msg.Tags.get(0).getName());
- assertEquals("Third tag must be", "test3", msg.Tags.get(2).getName());
- assertEquals("Count of tags must be", 3, msg.Tags.size());
+ assertEquals("First tag must be", "test", msg.getTags().get(0).getName());
+ assertEquals("Third tag must be", "test3", msg.getTags().get(2).getName());
+ assertEquals("Count of tags must be", 3, msg.getTags().size());
Date currentDate = new Date();
msg.setDate(currentDate);
MessageSerializer serializer = new MessageSerializer();
diff --git a/src/test/java/com/juick/tests/JsonTests.java b/src/test/java/com/juick/tests/SerializationTests.java
index 8378d7f1..dd2812c7 100644
--- a/src/test/java/com/juick/tests/JsonTests.java
+++ b/src/test/java/com/juick/tests/SerializationTests.java
@@ -7,10 +7,20 @@ import com.juick.Tag;
import com.juick.User;
import com.juick.json.MessageSerializer;
import com.juick.json.UserSerializer;
+import com.juick.xmpp.extensions.JuickMessage;
import org.json.JSONObject;
import org.junit.Test;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import javax.xml.bind.*;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -18,7 +28,7 @@ import java.util.TimeZone;
import static org.junit.Assert.assertEquals;
-public class JsonTests {
+public class SerializationTests {
@Test
public void DateTest() {
Message msg = new Message();
@@ -34,10 +44,10 @@ public class JsonTests {
}
}
@Test
- public void serializersTest() throws IOException {
+ public void serializersTest() throws IOException, JAXBException, ParserConfigurationException, SAXException {
User user = new User();
- user.setUName("ugnich");
- user.setUID(1);
+ user.setName("ugnich");
+ user.setUid(1);
user.setFullName("Anton Ugnich");
UserSerializer userSerializer = new UserSerializer();
JSONObject handmadeJson = userSerializer.serialize(user);
@@ -51,12 +61,12 @@ public class JsonTests {
JSONObject jacksonJson = new JSONObject(jacksonString);
assertEquals("jackson should serialize as ugnich", handmadeJson.length(), jacksonJson.length());
Message msg = new Message();
- msg.setMID(1);
+ msg.setMid(1);
msg.setUser(user);
msg.setText("yo");
msg.setDate(new Date());
- msg.Tags.add(new Tag("test"));
- msg.Tags.add(new Tag("json"));
+ msg.getTags().add(new Tag("test"));
+ msg.getTags().add(new Tag("json"));
MessageSerializer messageSerializer = new MessageSerializer();
JSONObject handmadeJsonMessage = messageSerializer.serialize(msg);
Message jacksonMessage = mapper.readValue(handmadeJsonMessage.toString(), Message.class);
@@ -64,5 +74,23 @@ public class JsonTests {
String jacksonStringMessage = mapper.writeValueAsString(jacksonMessage);
JSONObject jacksonJsonMessage = new JSONObject(jacksonStringMessage);
assertEquals("jackson should serialize as ugnich", handmadeJsonMessage.length(), jacksonJsonMessage.length());
+
+ JuickMessage jmsg = new JuickMessage(msg);
+ String handmadeXml = jmsg.toString();
+
+ JAXBContext messageContext = JAXBContext.newInstance(Message.class);
+ Unmarshaller unmarshaller = messageContext.createUnmarshaller();
+ Message jaxbMessage = (Message) unmarshaller.unmarshal(new StringReader(handmadeXml));
+ assertEquals("jaxb should unmarshal ugnich xml", msg, jaxbMessage);
+ StringWriter sw = new StringWriter();
+ Marshaller messageMarshaller = messageContext.createMarshaller();
+ messageMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
+ messageMarshaller.marshal(msg, sw);
+ String xmlString = sw.toString();
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
+ Document doc = dBuilder.parse(new InputSource(new StringReader(xmlString)));
+ assertEquals("jaxb should marshal as ugnich", 4, doc.getDocumentElement().getChildNodes().getLength());
+ assertEquals("jaxb should marshal as ugnich", 7, doc.getDocumentElement().getAttributes().getLength());
}
} \ No newline at end of file