From fe4c5fabf7a9da61b52ce6a269d1df0493826e01 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Tue, 18 Jun 2019 18:11:08 +0200 Subject: self ping (xep-0410) after receiving invite to muc --- .../messenger/services/XmppConnectionService.java | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/main/java/de/pixart/messenger/services/XmppConnectionService.java') 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); } -- cgit v1.2.3