From 218ea245d5fa0367d5d7b494cd7e6cd44be16f9b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 30 Jan 2018 16:56:51 +0300 Subject: ws: send pm to service user --- .../src/main/java/com/juick/ws/XMPPConnection.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'juick-ws/src/main/java/com/juick/ws') 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); + } + }); } } -- cgit v1.2.3