aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/main/java/com/juick/api/PM.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-11-15 15:56:06 +0300
committerGravatar Vitaly Takmazov2016-11-15 15:56:06 +0300
commit2cfabeab2e64a1b8b6db32a0135a2fce06bc87ab (patch)
tree65790951a6b43e436f8bfc742cc3a81cbeeb7b2c /juick-api/src/main/java/com/juick/api/PM.java
parent1c65b6d29c0fc69d861ffa0e624f73981b62cca6 (diff)
all components using babbler now, only juick-xmpp uses ugnich xmpp
Diffstat (limited to 'juick-api/src/main/java/com/juick/api/PM.java')
-rw-r--r--juick-api/src/main/java/com/juick/api/PM.java33
1 files changed, 16 insertions, 17 deletions
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 d8f17366..86d9c534 100644
--- a/juick-api/src/main/java/com/juick/api/PM.java
+++ b/juick-api/src/main/java/com/juick/api/PM.java
@@ -4,11 +4,10 @@ import com.juick.json.MessageSerializer;
import com.juick.server.PMQueries;
import com.juick.server.UserQueries;
import com.juick.util.UserUtils;
-import com.juick.xmpp.JID;
-import com.juick.xmpp.Message;
-import com.juick.xmpp.Stream;
-import com.juick.xmpp.extensions.JuickMessage;
import org.springframework.jdbc.core.JdbcTemplate;
+import rocks.xmpp.addr.Jid;
+import rocks.xmpp.core.session.XmppSession;
+import rocks.xmpp.core.stanza.model.Message;
import java.io.IOException;
import java.util.List;
@@ -53,8 +52,8 @@ public class PM {
}
}
- public void doPostPM(HttpServletRequest request,
- HttpServletResponse response, Stream xmpp, int vuid)
+ public void doPostPM(HttpServletRequest request,
+ HttpServletResponse response, XmppSession xmpp, int vuid)
throws ServletException, IOException {
String uname = request.getParameter("uname");
int uid = 0;
@@ -75,15 +74,15 @@ public class PM {
if (PMQueries.createPM(sql, vuid, uid, body)) {
Message msg = new Message();
- msg.from = new JID("juick", "juick.com", null);
- msg.to = new JID(Integer.toString(uid), "push.juick.com", null);
- JuickMessage jmsg = new JuickMessage();
+ msg.setFrom(Jid.of("juick@juick.com"));
+ msg.setTo(Jid.of(String.format("%d@push.juick.com", uid)));
+ com.juick.Message jmsg = new com.juick.Message();
jmsg.setUser(UserQueries.getUserByUID(sql, vuid).get());
jmsg.setText(body);
- msg.childs.add(jmsg);
+ msg.addExtension(jmsg);
xmpp.send(msg);
- msg.to.Host = "ws.juick.com";
+ msg.setTo(Jid.of(String.format("%d@ws.juick.com", uid)));
xmpp.send(msg);
Main.replyJSON(request, response, messageSerializer.serialize(jmsg).toString());
@@ -91,14 +90,14 @@ public class PM {
List<String> jids = UserQueries.getJIDsbyUID(sql, uid);
for (String jid: jids) {
Message mm = new Message();
- mm.to = new JID(jid);
- mm.type = Message.Type.chat;
+ mm.setTo(Jid.of(jid));
+ mm.setType(Message.Type.CHAT);
if (PMQueries.havePMinRoster(sql, vuid, jid)) {
- mm.from = new JID(jmsg.getUser().getName(), "juick.com", "Juick");
- mm.body = body;
+ mm.setFrom(Jid.of(jmsg.getUser().getName(), "juick.com", "Juick"));
+ mm.setBody(body);
} else {
- mm.from = new JID("juick", "juick.com", "Juick");
- mm.body = "Private message from @" + jmsg.getUser().getName() + ":\n" + body;
+ mm.setFrom(Jid.of("juick", "juick.com", "Juick"));
+ mm.setBody("Private message from @" + jmsg.getUser().getName() + ":\n" + body);
}
xmpp.send(mm);
}