aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/juick/XMPPManager.java30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/main/java/com/juick/XMPPManager.java b/src/main/java/com/juick/XMPPManager.java
index cba6ef3e..38da2d51 100644
--- a/src/main/java/com/juick/XMPPManager.java
+++ b/src/main/java/com/juick/XMPPManager.java
@@ -424,6 +424,7 @@ public class XMPPManager implements NotificationListener {
}
private void incomingPresence(Presence p) {
+ User visitor = userService.getUserByJID(p.getFrom().asBareJid().toEscapedString());
final boolean toJuick = isValidTarget(p.getTo(), false);
if (p.getType() == null) {
Presence reply = new Presence();
@@ -433,27 +434,28 @@ public class XMPPManager implements NotificationListener {
xmpp.send(ClientPresence.from(reply));
} else if (p.getType().equals(Presence.Type.PROBE)) {
if (toJuick) {
- User visitor = userService.getUserByJID(p.getFrom().asBareJid().toEscapedString());
if (visitor != null) {
userService.updateLastSeen(visitor);
+ Presence reply = new Presence();
+ reply.setFrom(p.getTo().withResource(jid.getResource()));
+ reply.setTo(p.getFrom());
+ reply.setPriority((byte) 10);
+ if (!userService.getActiveJIDs().contains(p.getFrom().asBareJid().toEscapedString())) {
+ reply.setStatus("Send ON to enable notifications");
+ }
+ xmpp.send(ClientPresence.from(reply));
+ } else {
+ Presence reply = new Presence();
+ reply.setFrom(p.getTo());
+ reply.setTo(p.getFrom());
+ reply.setType(Presence.Type.UNSUBSCRIBED);
+ xmpp.send(ClientPresence.from(reply));
}
- }
- if (toJuick) {
- Presence reply = new Presence();
- reply.setFrom(p.getTo().withResource(jid.getResource()));
- reply.setTo(p.getFrom());
- reply.setPriority((byte) 10);
- if (!userService.getActiveJIDs().contains(p.getFrom().asBareJid().toEscapedString())) {
- reply.setStatus("Send ON to enable notifications");
- }
- xmpp.send(ClientPresence.from(reply));
} else {
Presence reply = new Presence();
reply.setFrom(p.getTo());
reply.setTo(p.getFrom());
- reply.setType(Presence.Type.ERROR);
- reply.setId(p.getId());
- reply.setError(new StanzaError(StanzaError.Type.CANCEL, Condition.ITEM_NOT_FOUND));
+ reply.setType(Presence.Type.UNSUBSCRIBED);
xmpp.send(ClientPresence.from(reply));
}
} else if (p.getType().equals(Presence.Type.SUBSCRIBE)) {