aboutsummaryrefslogtreecommitdiff
path: root/juick-www
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-01-30 16:48:08 +0300
committerGravatar Vitaly Takmazov2018-01-30 16:48:08 +0300
commit8eb857ec38b86e03a2509df1ad263cdb1e9bb7b7 (patch)
tree823a090ffeb77ca469afcfa9437b69c9a7166f34 /juick-www
parentbbd3faa0ff2f65aa852e0995d8fa3a46d17b485f (diff)
serialize PM in api and www
Diffstat (limited to 'juick-www')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/NewMessage.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
index 5a73d983..c9a1d572 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
@@ -18,6 +18,8 @@ package com.juick.www.controllers;
import com.juick.Status;
import com.juick.Tag;
+import com.juick.User;
+import com.juick.server.helpers.AnonymousUser;
import com.juick.server.util.*;
import com.juick.service.*;
import com.juick.www.WebApp;
@@ -342,34 +344,35 @@ public class NewMessage {
if (uname.startsWith("@")) {
uname = uname.substring(1);
}
- int uid = 0;
+ User userTo = AnonymousUser.INSTANCE;
if (WebUtils.isUserName(uname)) {
- uid = userService.getUIDbyName(uname);
+ userTo = userService.getUserByName(uname);
}
- if (uid == 0 || body.length() > 10240) {
+ if (userTo.getUid() == 0 || body.length() > 10240) {
throw new HttpBadRequestException();
}
- if (userService.isInBLAny(uid, visitor.getUid())) {
+ if (userService.isInBLAny(userTo.getUid(), visitor.getUid())) {
throw new HttpForbiddenException();
}
- if (pmQueriesService.createPM(visitor.getUid(), uid, body)) {
+ if (pmQueriesService.createPM(visitor.getUid(), userTo.getUid(), body)) {
if (webApp.getXmpp() != null) {
Message msg = new Message();
msg.setFrom(Jid.of("juick@juick.com"));
- msg.setTo(Jid.of(String.format("%d@push.juick.com", uid)));
+ msg.setTo(Jid.of(String.format("%d@push.juick.com", userTo.getUid())));
com.juick.Message jmsg = new com.juick.Message();
jmsg.setUser(visitor);
jmsg.setText(body);
+ jmsg.setTo(userTo);
msg.addExtension(jmsg);
webApp.getXmpp().send(msg);
- msg.setTo(Jid.of(String.format("%d@ws.juick.com", uid)));
+ msg.setTo(Jid.of(String.format("%d@ws.juick.com", userTo.getUid())));
webApp.getXmpp().send(msg);
- List<String> jids = userService.getJIDsbyUID(uid);
+ List<String> jids = userService.getJIDsbyUID(userTo.getUid());
for (String jid : jids) {
Message mm = new Message();
mm.setTo(Jid.of(jid));