aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src')
-rw-r--r--juick-server/src/main/java/com/juick/server/TelegramBotManager.java8
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPConnection.java14
2 files changed, 19 insertions, 3 deletions
diff --git a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
index 50fe40e1..b4865dfb 100644
--- a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
+++ b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
@@ -366,9 +366,11 @@ public class TelegramBotManager implements NotificationListener {
com.juick.Message message = likeEvent.getMessage();
List<User> subscribers = likeEvent.getSubscribers();
logger.info("Like received in tg listener");
- telegramService.getTelegramIdentifiers(Collections.singletonList(message.getUser()))
- .forEach(c -> telegramNotify(c, String.format("%s recommends your [post](%s)",
- MessageUtils.getMarkdownUser(liker), formatUrl(message)), new com.juick.Message()));
+ if (!userService.isInBLAny(message.getUser().getUid(), liker.getUid())) {
+ telegramService.getTelegramIdentifiers(Collections.singletonList(message.getUser()))
+ .forEach(c -> telegramNotify(c, String.format("%s recommends your [post](%s)",
+ MessageUtils.getMarkdownUser(liker), formatUrl(message)), new com.juick.Message()));
+ }
telegramService.getTelegramIdentifiers(subscribers)
.forEach(c -> telegramNotify(c, String.format("%s recommends you someone's [post](%s)",
MessageUtils.getMarkdownUser(liker), formatUrl(message)), new com.juick.Message()));
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);