aboutsummaryrefslogtreecommitdiff
path: root/juick-ws/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-01-30 16:56:51 +0300
committerGravatar Vitaly Takmazov2018-01-30 16:56:51 +0300
commit218ea245d5fa0367d5d7b494cd7e6cd44be16f9b (patch)
treef12ffd97c9d42a7b19fe3acdcbb2f90c19f92697 /juick-ws/src/main/java/com/juick
parent8eb857ec38b86e03a2509df1ad263cdb1e9bb7b7 (diff)
ws: send pm to service user
Diffstat (limited to 'juick-ws/src/main/java/com/juick')
-rw-r--r--juick-ws/src/main/java/com/juick/ws/XMPPConnection.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
index d30f8f03..be7f3899 100644
--- a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
+++ b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
@@ -65,6 +65,8 @@ public class XMPPConnection implements AutoCloseable {
private int xmppPort;
@Value("${ws_jid:ws.juick.local}")
private String wsJid;
+ @Value("${service_user:juick}")
+ private String serviceUser;
private XmppSession xmpp;
@@ -140,14 +142,16 @@ public class XMPPConnection implements AutoCloseable {
private void onJuickPM(final int uid_to, final com.juick.Message jmsg) throws JsonProcessingException {
String json = jsonMapper.writeValueAsString(jmsg);
synchronized (wsHandler.getClients()) {
- wsHandler.getClients().stream().filter(c -> !c.legacy && c.visitor.getUid() == uid_to).forEach(c -> {
- try {
- logger.info("sending pm to {}", c.visitor.getUid());
- c.session.sendMessage(new TextMessage(json));
- } catch (IOException e) {
- logger.warn("ws error", e);
- }
- });
+ wsHandler.getClients().stream().filter(c ->
+ (!c.legacy && c.visitor.getUid() == uid_to) || c.visitor.getName().equals(serviceUser))
+ .forEach(c -> {
+ try {
+ logger.info("sending pm to {}", c.visitor.getUid());
+ c.session.sendMessage(new TextMessage(json));
+ } catch (IOException e) {
+ logger.warn("ws error", e);
+ }
+ });
}
}