From 41c4ea59c8d1929a1f8b8f8536ffa696e64e1336 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 10 Oct 2017 09:36:08 +0300 Subject: xmpp: mark jids inactive when resource-constraint is received --- .../src/main/java/com/juick/components/JuickBot.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/juick-xmpp/src/main/java/com/juick/components/JuickBot.java b/juick-xmpp/src/main/java/com/juick/components/JuickBot.java index cefacb56..f79db78e 100644 --- a/juick-xmpp/src/main/java/com/juick/components/JuickBot.java +++ b/juick-xmpp/src/main/java/com/juick/components/JuickBot.java @@ -204,10 +204,20 @@ public class JuickBot implements StanzaListener, AutoCloseable { } public boolean incomingMessage(Message msg) { - if (StringUtils.isBlank(msg.getBody()) || (msg.getType() != null && msg.getType().equals(Message.Type.ERROR))) { + if (StringUtils.isBlank(msg.getBody())) { + return false; + } + if (msg.getType() != null && msg.getType().equals(Message.Type.ERROR)) { + StanzaError error = msg.getExtension(StanzaError.class); + if (error.getCondition().equals(Condition.RESOURCE_CONSTRAINT)) { + // offline query is full, deactivating this jid + if (userService.setActiveStatusForJID(msg.getFrom().toEscapedString(), UserService.ActiveStatus.Inactive)) { + logger.info("{} is inactive now", msg.getFrom()); + return true; + } + } return false; } - String username = msg.getTo().getLocal(); User user_from; -- cgit v1.2.3