diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-06-18 18:11:08 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-06-18 18:11:08 +0200 |
commit | fe4c5fabf7a9da61b52ce6a269d1df0493826e01 (patch) | |
tree | 3d9459fac06b7ec8b9907bb0f347d3c60bd05a32 /src/main/java/de/pixart/messenger/services | |
parent | 777ab177c1416c5635f7821acd85ab3298cf1484 (diff) |
self ping (xep-0410) after receiving invite to muc
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 24 |
1 files changed, 22 insertions, 2 deletions
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); } |