From 2a5bd4a24556b0d1fa78361e747913726cfa8ce2 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 25 Jun 2017 15:35:16 +0300 Subject: xmpp: broadcast presence only to active jids --- juick-server/src/main/java/com/juick/service/UserService.java | 2 +- juick-server/src/main/java/com/juick/service/UserServiceImpl.java | 4 ++-- juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/juick-server/src/main/java/com/juick/service/UserService.java b/juick-server/src/main/java/com/juick/service/UserService.java index 98786f7d..a6db9f82 100644 --- a/juick-server/src/main/java/com/juick/service/UserService.java +++ b/juick-server/src/main/java/com/juick/service/UserService.java @@ -122,5 +122,5 @@ public interface UserService { boolean unauthJID(int uid, String jid); - List getAllJIDs(); + List getActiveJIDs(); } diff --git a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java index 1b7cee42..6a3bb40c 100644 --- a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java +++ b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java @@ -698,7 +698,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { @Transactional(readOnly = true) @Override - public List getAllJIDs() { - return getJdbcTemplate().queryForList("SELECT jid FROM jids WHERE loginhash IS NULL", String.class); + public List getActiveJIDs() { + return getJdbcTemplate().queryForList("SELECT jid FROM jids WHERE active=1 AND loginhash IS NULL", String.class); } } diff --git a/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java b/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java index 5b6dd353..52dbdb2b 100644 --- a/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java +++ b/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java @@ -480,7 +480,7 @@ public class JuickBot implements StanzaListener, AutoCloseable { if (type != null) { presence.setType(type); } - xmpp.userService.getAllJIDs().forEach(j -> { + xmpp.userService.getActiveJIDs().forEach(j -> { try { presence.setTo(Jid.of(j)); xmpp.sendOut(ClientPresence.from(presence)); -- cgit v1.2.3