aboutsummaryrefslogtreecommitdiff
path: root/juick-server-xmpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server-xmpp/src')
-rw-r--r--juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java26
1 files changed, 12 insertions, 14 deletions
diff --git a/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java
index 884b1563..bf3f54e1 100644
--- a/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java
+++ b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java
@@ -74,6 +74,7 @@ import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@@ -261,13 +262,12 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
return stanzaWriter.toString();
}
- private void sendJuickMessage(com.juick.Message jmsg) {
+ private void sendJuickMessage(com.juick.Message jmsg, List<User> users) {
List<String> jids = new ArrayList<>();
if (jmsg.FriendsOnly) {
jids = subscriptionService.getJIDSubscribedToUser(jmsg.getUser().getUid(), jmsg.FriendsOnly);
} else {
- List<User> users = subscriptionService.getSubscribedUsers(jmsg.getUser().getUid(), jmsg.getMid());
for (User user : users) {
jids.addAll(userService.getJIDsbyUID(user.getUid()));
}
@@ -304,13 +304,10 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
}
}
- public void sendJuickComment(com.juick.Message jmsg) {
- List<User> users;
+ public void sendJuickComment(com.juick.Message jmsg, List<User> users) {
String replyQuote;
String replyTo;
- com.juick.Message op = messagesService.getMessage(jmsg.getMid());
- users = subscriptionService.getUsersSubscribedToComments(op, jmsg);
com.juick.Message replyMessage = jmsg.getReplyto() > 0 ? messagesService.getReply(jmsg.getMid(), jmsg.getReplyto())
: messagesService.getMessage(jmsg.getMid());
replyTo = replyMessage.getUser().getName();
@@ -340,6 +337,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
@Override
public void processMessageEvent(MessageEvent event) {
com.juick.Message msg = event.getMessage();
+ List<User> subscribers = event.getUsers();
if (MessageUtils.isPM(msg)) {
userService.getJIDsbyUID(msg.getTo().getUid())
.forEach(userJid -> {
@@ -357,10 +355,10 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
router.send(ClientMessage.from(mm));
});
} else if (MessageUtils.isReply(msg)) {
- sendJuickComment(msg);
+ sendJuickComment(msg, subscribers);
}
else {
- sendJuickMessage(msg);
+ sendJuickMessage(msg, subscribers);
}
}
@@ -380,11 +378,9 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
@Override
public void processLikeEvent(LikeEvent likeEvent) {
- List<User> users;
+ List<User> users = likeEvent.getSubscribers();
com.juick.Message jmsg = likeEvent.getMessage();
User liker = likeEvent.getUser();
- users = subscriptionService.getUsersSubscribedToUserRecommendations(liker.getUid(),
- jmsg.getMid(), jmsg.getUser().getUid());
String txt = "Recommended by @" + liker.getName() + ":\n";
txt += "@" + jmsg.getUser().getName() + ":" + MessageUtils.getTagsString(jmsg) + "\n";
@@ -551,15 +547,17 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
com.juick.Message jmsg = msg.getExtension(com.juick.Message.class);
if (jmsg != null) {
if (to.getLocal().equals("pm")) {
- applicationEventPublisher.publishEvent(new MessageEvent(this, jmsg));
+ applicationEventPublisher.publishEvent(new MessageEvent(this, jmsg, Collections.singletonList(jmsg.getTo())));
} else {
if (MessageUtils.isReply(jmsg)) {
// to get quote and attachment
+ com.juick.Message original = messagesService.getMessage(jmsg.getMid());
com.juick.Message reply = messagesService.getReply(jmsg.getMid(), jmsg.getRid());
- applicationEventPublisher.publishEvent(new MessageEvent(this, reply));
+ applicationEventPublisher.publishEvent(new MessageEvent(this, reply,
+ subscriptionService.getUsersSubscribedToComments(original, reply)));
} else if (!MessageUtils.isPM(jmsg)) {
applicationEventPublisher.publishEvent(new MessageEvent(this,
- messagesService.getMessage(jmsg.getMid())));
+ messagesService.getMessage(jmsg.getMid()), subscriptionService.getSubscribedUsers(jmsg.getUser().getUid(), jmsg.getMid())));
}
}
} else {