aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/XMPPConnection.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-08-15 15:17:15 +0300
committerGravatar Vitaly Takmazov2018-08-15 15:17:15 +0300
commit55f245ddcdd7ce18d55cd9a4b6cd0081ac31735b (patch)
treed1674a2f49ec0da066671ec86a16e8a8b8dee80c /juick-server/src/main/java/com/juick/server/XMPPConnection.java
parent5518faa7d7c28ae2a996fe057e7747d3b307c749 (diff)
Author should receive notifications about likes
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/XMPPConnection.java')
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPConnection.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/juick-server/src/main/java/com/juick/server/XMPPConnection.java b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
index 41102322..856b1367 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
@@ -18,6 +18,7 @@
package com.juick.server;
import com.juick.User;
+import com.juick.formatters.PlainTextFormatter;
import com.juick.server.component.*;
import com.juick.server.helpers.CommandResult;
import com.juick.server.helpers.UserInfo;
@@ -405,6 +406,19 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
com.juick.Message jmsg = likeEvent.getMessage();
User liker = likeEvent.getUser();
+ if (!userService.isInBLAny(jmsg.getUser().getUid(), liker.getUid())) {
+ userService.getJIDsbyUID(jmsg.getUser().getUid()).forEach(authorJid -> {
+ Message xmppMessage = new Message();
+ xmppMessage.setFrom(jid);
+ xmppMessage.setTo(Jid.of(authorJid));
+ xmppMessage.setType(Message.Type.CHAT);
+ xmppMessage.addExtension(jmsg);
+ xmppMessage.setBody(String.format("%s recommended your post #%d. %s",
+ liker.getName(), jmsg.getMid(), PlainTextFormatter.formatUrl(jmsg)));
+ router.send(ClientMessage.from(xmppMessage));
+ });
+ }
+
String txt = "Recommended by @" + liker.getName() + ":\n";
txt += "@" + jmsg.getUser().getName() + ":" + MessageUtils.getTagsString(jmsg) + "\n";
String attachmentUrl = MessageUtils.attachmentUrl(jmsg);