aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-06-18 18:11:08 +0200
committerChristian Schneppe <christian@pix-art.de>2019-06-18 18:11:08 +0200
commitfe4c5fabf7a9da61b52ce6a269d1df0493826e01 (patch)
tree3d9459fac06b7ec8b9907bb0f347d3c60bd05a32
parent777ab177c1416c5635f7821acd85ab3298cf1484 (diff)
self ping (xep-0410) after receiving invite to muc
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java7
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java24
-rw-r--r--src/main/java/de/pixart/messenger/utils/Namespace.java1
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/XmppConnection.java2
4 files changed, 29 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index 2c81380dc..8c0f89323 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -549,7 +549,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
final boolean checkedForDuplicates = serverMsgId != null && remoteMsgId != null && !conversation.possibleDuplicate(serverMsgId, remoteMsgId);
if (origin != null) {
- message = parseAxolotlChat(axolotlEncrypted, origin, conversation, status, checkedForDuplicates,query != null);
+ message = parseAxolotlChat(axolotlEncrypted, origin, conversation, status, checkedForDuplicates, query != null);
} else {
Message trial = null;
for (Jid fallback : fallbacksBySourceId) {
@@ -999,7 +999,10 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
public boolean execute(Account account) {
if (jid != null) {
Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, jid, true, false);
- if (!conversation.getMucOptions().online()) {
+ if (conversation.getMucOptions().online()) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received invite to " + jid + " but muc is considered to be online");
+ mXmppConnectionService.mucSelfPingAndRejoin(conversation);
+ } else {
conversation.getMucOptions().setPassword(password);
mXmppConnectionService.databaseBackend.updateConversation(conversation);
mXmppConnectionService.joinMuc(conversation, inviter != null && inviter.mutualPresenceSubscription());
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index e03250cb3..ec46a91f1 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -2217,7 +2217,7 @@ public class XmppConnectionService extends Service {
archiveConversation(conversation, true);
}
- private void archiveConversation(Conversation conversation, final boolean maySyncronizeWithBookmarks) {
+ private void archiveConversation(Conversation conversation, final boolean maySynchronizeWithBookmarks) {
getNotificationService().clear(conversation);
conversation.setStatus(Conversation.STATUS_ARCHIVED);
conversation.setNextMessage(null);
@@ -2226,7 +2226,7 @@ public class XmppConnectionService extends Service {
if (conversation.getMode() == Conversation.MODE_MULTI) {
if (conversation.getAccount().getStatus() == Account.State.ONLINE) {
Bookmark bookmark = conversation.getBookmark();
- if (maySyncronizeWithBookmarks && bookmark != null && bookmark.autojoin() && synchronizeWithBookmarks()) {
+ if (maySynchronizeWithBookmarks && bookmark != null && synchronizeWithBookmarks()) {
bookmark.setAutojoin(false);
pushBookmarks(bookmark.getAccount());
}
@@ -2675,6 +2675,26 @@ public class XmppConnectionService extends Service {
}
}
+ public void mucSelfPingAndRejoin(final Conversation conversation) {
+ final Jid self = conversation.getMucOptions().getSelf().getFullJid();
+ final IqPacket ping = new IqPacket(IqPacket.TYPE.GET);
+ ping.setTo(self);
+ ping.addChild("ping", Namespace.PING);
+ sendIqPacket(conversation.getAccount(), ping, (account, response) -> {
+ if (response.getType() == IqPacket.TYPE.ERROR) {
+ Element error = response.findChild("error");
+ if (error == null || error.hasChild("service-unavailable") || error.hasChild("feature-not-implemented") || error.hasChild("item-not-found")) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ping to " + self + " came back as ignorable error");
+ } else {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ping to " + self + " failed. attempting rejoin");
+ joinMuc(conversation);
+ }
+ } else if (response.getType() == IqPacket.TYPE.RESULT) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ping to " + self + " came back fine");
+ }
+ });
+ }
+
public void joinMuc(Conversation conversation) {
joinMuc(conversation, null, false);
}
diff --git a/src/main/java/de/pixart/messenger/utils/Namespace.java b/src/main/java/de/pixart/messenger/utils/Namespace.java
index d832dea47..a28adb20c 100644
--- a/src/main/java/de/pixart/messenger/utils/Namespace.java
+++ b/src/main/java/de/pixart/messenger/utils/Namespace.java
@@ -27,4 +27,5 @@ public final class Namespace {
public static final String AVATAR_CONVERSION = "urn:xmpp:pep-vcard-conversion:0";
public static final String JINGLE_TRANSPORTS_S5B = "urn:xmpp:jingle:transports:s5b:1";
public static final String JINGLE_TRANSPORTS_IBB = "urn:xmpp:jingle:transports:ibb:1";
+ public static final String PING = "urn:xmpp:ping";
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
index 7eece5b38..4cab09d99 100644
--- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
@@ -1503,7 +1503,7 @@ public class XmppConnection implements Runnable {
if (!r()) {
final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
iq.setFrom(account.getJid());
- iq.addChild("ping", "urn:xmpp:ping");
+ iq.addChild("ping", Namespace.PING);
this.sendIqPacket(iq, null);
}
this.lastPingSent = SystemClock.elapsedRealtime();