aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com')
-rw-r--r--juick-server/src/main/java/com/juick/server/EmailManager.java7
-rw-r--r--juick-server/src/main/java/com/juick/server/MessengerManager.java9
-rw-r--r--juick-server/src/main/java/com/juick/server/ServerManager.java3
-rw-r--r--juick-server/src/main/java/com/juick/server/TelegramBotManager.java7
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPConnection.java7
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Notifications.java3
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Service.java74
7 files changed, 20 insertions, 90 deletions
diff --git a/juick-server/src/main/java/com/juick/server/EmailManager.java b/juick-server/src/main/java/com/juick/server/EmailManager.java
index 8dd7e06e..83db3ac3 100644
--- a/juick-server/src/main/java/com/juick/server/EmailManager.java
+++ b/juick-server/src/main/java/com/juick/server/EmailManager.java
@@ -52,9 +52,10 @@ public class EmailManager implements ApplicationListener<MessageEvent> {
} else if (msg.getRid() > 0) {
Message originalMessage = messagesService.getMessage(msg.getMid());
String subject = String.format("New reply to %s", originalMessage.getUser().getName());
- subscriptionService.getUsersSubscribedToComments(msg.getMid(), msg.getUser().getUid())
- .forEach(user -> emailService.getEmails(user.getUid(), true)
- .forEach(email -> emailNotify(email, subject, msg)));
+ subscriptionService.getUsersSubscribedToComments(originalMessage, msg)
+ .stream().filter(user -> !userService.isInBLAny(user.getUid(), msg.getUser().getUid()))
+ .flatMap(user -> emailService.getEmails(user.getUid(), true).stream())
+ .forEach(email -> emailNotify(email, subject, msg));
}
}
diff --git a/juick-server/src/main/java/com/juick/server/MessengerManager.java b/juick-server/src/main/java/com/juick/server/MessengerManager.java
index 14a43d6a..1fe04aca 100644
--- a/juick-server/src/main/java/com/juick/server/MessengerManager.java
+++ b/juick-server/src/main/java/com/juick/server/MessengerManager.java
@@ -112,12 +112,11 @@ public class MessengerManager implements ApplicationListener<MessageEvent> {
.forEach(user -> messengerService.getSenderId(user)
.ifPresent(t -> messengerNotify(t, subject, formatUrl(msg))));
} else if (msg.getRid() > 0) {
- // get quote
- com.juick.Message jmsg = messagesService.getReply(msg.getMid(), msg.getRid());
- String subject = formatPost(jmsg);
- subscriptionService.getUsersSubscribedToComments(msg.getMid(), msg.getUser().getUid())
+ Message op = messagesService.getMessage(msg.getMid());
+ String subject = formatPost(msg);
+ subscriptionService.getUsersSubscribedToComments(op, msg)
.forEach(user -> messengerService.getSenderId(user)
- .ifPresent(t -> messengerNotify(t, subject, formatUrl(jmsg))));
+ .ifPresent(t -> messengerNotify(t, subject, formatUrl(msg))));
}
}
diff --git a/juick-server/src/main/java/com/juick/server/ServerManager.java b/juick-server/src/main/java/com/juick/server/ServerManager.java
index 30740a76..ca22aa35 100644
--- a/juick-server/src/main/java/com/juick/server/ServerManager.java
+++ b/juick-server/src/main/java/com/juick/server/ServerManager.java
@@ -226,8 +226,9 @@ public class ServerManager implements AutoCloseable {
private void onJuickMessageReply(final com.juick.Message jmsg) throws JsonProcessingException {
String json = jsonMapper.writeValueAsString(jmsg);
+ com.juick.Message op = messagesService.getMessage(jmsg.getMid());
List<Integer> threadUsers =
- subscriptionService.getUsersSubscribedToComments(jmsg.getMid(), jmsg.getUser().getUid())
+ subscriptionService.getUsersSubscribedToComments(op, jmsg)
.stream().map(User::getUid).collect(Collectors.toList());
synchronized (wsHandler.getClients()) {
wsHandler.getClients().stream().filter(c ->
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 697f6dd1..2793f906 100644
--- a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
+++ b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
@@ -230,11 +230,10 @@ public class TelegramBotManager implements ApplicationListener<MessageEvent> {
// anonymous
chats.stream().filter(u -> telegramService.getUser(u) == 0).forEach(c -> telegramNotify(c, msg, MessageUtils.attachmentUrl(jmsg)));
} else if (jmsg.getRid() > 0) {
- // get quote
- com.juick.Message msg = messagesService.getReply(jmsg.getMid(), jmsg.getRid());
- String fmsg = String.format("[%s](%s) %s", MSG_LINK, msgUrl, formatPost(msg, true));
+ com.juick.Message op = messagesService.getMessage(jmsg.getMid());
+ String fmsg = String.format("[%s](%s) %s", MSG_LINK, msgUrl, formatPost(jmsg, true));
telegramService.getTelegramIdentifiers(
- subscriptionService.getUsersSubscribedToComments(jmsg.getMid(), jmsg.getUser().getUid())
+ subscriptionService.getUsersSubscribedToComments(op, jmsg)
).forEach(c -> telegramNotify(c, fmsg, MessageUtils.attachmentUrl(jmsg)));
}
}
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 4bfcd833..69d39c18 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
@@ -160,7 +160,9 @@ public class XMPPConnection implements AutoCloseable {
sendJuickRecommendation(jmsg);
} else {
if (jmsg.getRid() > 0) {
- sendJuickComment(jmsg);
+ // to get quote and attachment
+ com.juick.Message reply = messagesService.getReply(jmsg.getMid(), jmsg.getRid());
+ sendJuickComment(reply);
} else if (jmsg.getMid() > 0) {
sendJuickMessage(jmsg);
}
@@ -332,7 +334,8 @@ public class XMPPConnection implements AutoCloseable {
String replyQuote;
String replyTo;
- users = subscriptionService.getUsersSubscribedToComments(jmsg.getMid(), jmsg.getUser().getUid());
+ 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();
diff --git a/juick-server/src/main/java/com/juick/server/api/Notifications.java b/juick-server/src/main/java/com/juick/server/api/Notifications.java
index 16601b7f..94b66746 100644
--- a/juick-server/src/main/java/com/juick/server/api/Notifications.java
+++ b/juick-server/src/main/java/com/juick/server/api/Notifications.java
@@ -84,8 +84,9 @@ public class Notifications {
if (msg != null) {
List<User> users;
if (rid > 0) {
+ Message op = messagesService.getMessage(mid);
Message reply = messagesService.getReply(mid, rid);
- users = subscriptionService.getUsersSubscribedToComments(mid, reply.getUser().getUid());
+ users = subscriptionService.getUsersSubscribedToComments(op, reply);
} else {
users = subscriptionService.getSubscribedUsers(msg.getUser().getUid(), mid);
}
diff --git a/juick-server/src/main/java/com/juick/server/api/Service.java b/juick-server/src/main/java/com/juick/server/api/Service.java
deleted file mode 100644
index 12ffee9c..00000000
--- a/juick-server/src/main/java/com/juick/server/api/Service.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2008-2017, Juick
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.juick.server.api;
-
-import com.juick.Message;
-import com.juick.User;
-import com.juick.server.util.HttpBadRequestException;
-import com.juick.server.util.HttpForbiddenException;
-import com.juick.server.util.UserUtils;
-import com.juick.service.CrosspostService;
-import com.juick.service.MessagesService;
-import com.juick.service.SubscriptionService;
-import com.juick.service.UserService;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-import springfox.documentation.annotations.ApiIgnore;
-
-import javax.inject.Inject;
-import java.io.IOException;
-import java.util.List;
-
-/**
- * TODO: configure spring-security to allow only admin role
- */
-@ApiIgnore
-@RestController
-public class Service {
- @Inject
- private SubscriptionService subscriptionService;
- @Inject
- private MessagesService messagesService;
- @Inject
- private CrosspostService crosspostService;
- @Inject
- private UserService userService;
-
- @RequestMapping(value = "/subscriptions", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- public List<User> doGet(
- @RequestParam(defaultValue = "0") int mid,
- @RequestParam(defaultValue = "0") int uid) throws IOException {
- User visitor = UserUtils.getCurrentUser();
- if ((visitor.getUid() == 0) && !(visitor.getName().equals("juick"))) {
- throw new HttpForbiddenException();
- }
- if (uid > 0) {
- return subscriptionService.getSubscribedUsers(uid, mid);
- } else {
- // thread
- Message msg = messagesService.getMessage(mid);
- if (msg != null) {
- return subscriptionService.getUsersSubscribedToComments(mid, msg.getUser().getUid());
- }
- }
- throw new HttpBadRequestException();
- }
-}