aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-01-10 09:07:15 +0300
committerGravatar Vitaly Takmazov2023-01-10 09:07:15 +0300
commit85e9288348e93bf033ad8b7a648fcc94189b9a96 (patch)
tree572827e1c1ddbfde41da4c118ceeaf555a3a8c00 /src/main/java/com/juick
parentf6b78c029a1e9e4f09b600131e99bbc13c65f30a (diff)
XMPP: send `unsubscribe` presence to unknown JIDs
Diffstat (limited to 'src/main/java/com/juick')
-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)) {