aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/PM.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/PM.java')
-rw-r--r--juick-www/src/main/java/com/juick/www/PM.java31
1 files changed, 15 insertions, 16 deletions
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 2e35ec1c..95e2623a 100644
--- a/juick-www/src/main/java/com/juick/www/PM.java
+++ b/juick-www/src/main/java/com/juick/www/PM.java
@@ -21,15 +21,14 @@ import com.juick.server.PMQueries;
import com.juick.server.TagQueries;
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 com.mitchellbosecke.pebble.error.PebbleException;
import com.mitchellbosecke.pebble.template.PebbleTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -87,7 +86,7 @@ public class PM {
}
}
- public void doPostPM(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, Stream xmpp, com.juick.User visitor) throws ServletException, IOException {
+ public void doPostPM(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, XmppSession xmpp, com.juick.User visitor) throws ServletException, IOException {
String uname = request.getParameter("uname");
if (uname.startsWith("@")) {
uname = uname.substring(1);
@@ -111,28 +110,28 @@ public class PM {
if (PMQueries.createPM(sql, visitor.getUid(), uid, body)) {
if (xmpp != null) {
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(visitor);
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);
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, visitor.getUid(), 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);
}