From ddd08bfe5fb16125306a5d59f43535af80d96383 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 25 Aug 2022 17:12:39 +0200 Subject: [PATCH] issue self ping + rejoin on muc status code 333 --- .../conversations/entities/MucOptions.java | 1 + .../conversations/generator/IqGenerator.java | 4 ++-- .../conversations/parser/PresenceParser.java | 20 +++++++++++++++---- .../ui/ConversationFragment.java | 3 +++ src/main/res/values/strings.xml | 1 + 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index 34f437e1c..060b1b6f6 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -725,6 +725,7 @@ public class MucOptions { SHUTDOWN, DESTROYED, INVALID_NICK, + TECHNICAL_PROBLEMS, UNKNOWN, NON_ANONYMOUS } diff --git a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java index 2776aa4f0..6b87cb36d 100644 --- a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java @@ -136,8 +136,8 @@ public class IqGenerator extends AbstractGenerator { return publish(Namespace.NICK, item); } - public IqPacket deleteNode(String node) { - IqPacket packet = new IqPacket(IqPacket.TYPE.SET); + public IqPacket deleteNode(final String node) { + final IqPacket packet = new IqPacket(IqPacket.TYPE.SET); final Element pubsub = packet.addChild("pubsub", Namespace.PUBSUB_OWNER); pubsub.addChild("delete").setAttribute("node", node); return packet; diff --git a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java index 341e8d9a0..8ad582b17 100644 --- a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java @@ -56,7 +56,8 @@ public class PresenceParser extends AbstractParser implements } private void processConferencePresence(PresencePacket packet, Conversation conversation) { - MucOptions mucOptions = conversation.getMucOptions(); + final Account account = conversation.getAccount(); + final MucOptions mucOptions = conversation.getMucOptions(); final Jid jid = conversation.getAccount().getJid(); final Jid from = packet.getFrom(); if (!from.isBareJid()) { @@ -93,7 +94,7 @@ public class PresenceParser extends AbstractParser implements axolotlService.fetchDeviceIds(user.getRealJid()); } if (codes.contains(MucOptions.STATUS_CODE_ROOM_CREATED) && mucOptions.autoPushConfiguration()) { - Log.d(Config.LOGTAG,mucOptions.getAccount().getJid().asBareJid() + Log.d(Config.LOGTAG,account.getJid().asBareJid() +": room '" +mucOptions.getConversation().getJid().asBareJid() +"' created. pushing default configuration"); @@ -138,13 +139,24 @@ public class PresenceParser extends AbstractParser implements final Jid alternate = destroy == null ? null : InvalidJid.getNullForInvalid(destroy.getAttributeAsJid("jid")); mucOptions.setError(MucOptions.Error.DESTROYED); if (alternate != null) { - Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": muc destroyed. alternate location " + alternate); + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": muc destroyed. alternate location " + alternate); } } else if (codes.contains(MucOptions.STATUS_CODE_SHUTDOWN) && fullJidMatches) { mucOptions.setError(MucOptions.Error.SHUTDOWN); } else if (codes.contains(MucOptions.STATUS_CODE_SELF_PRESENCE)) { if (codes.contains(MucOptions.STATUS_CODE_TECHNICAL_REASONS)) { - mucOptions.setError(MucOptions.Error.UNKNOWN); + final boolean wasOnline = mucOptions.online(); + mucOptions.setError(MucOptions.Error.TECHNICAL_PROBLEMS); + Log.d( + Config.LOGTAG, + account.getJid().asBareJid() + + ": received status code 333 in room " + + mucOptions.getConversation().getJid().asBareJid() + + " online=" + + wasOnline); + if (wasOnline) { + mXmppConnectionService.mucSelfPingAndRejoin(conversation); + } } else if (codes.contains(MucOptions.STATUS_CODE_KICKED)) { mucOptions.setError(MucOptions.Error.KICKED); } else if (codes.contains(MucOptions.STATUS_CODE_BANNED)) { diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 0471c014f..3b923adce 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -2721,6 +2721,9 @@ public class ConversationFragment extends XmppFragment case KICKED: showSnackbar(R.string.conference_kicked, R.string.join, joinMuc); break; + case TECHNICAL_PROBLEMS: + showSnackbar(R.string.conference_technical_problems, R.string.try_again, joinMuc); + break; case UNKNOWN: showSnackbar(R.string.conference_unknown_error, R.string.try_again, joinMuc); break; diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index d4e2c0d57..299c57b33 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -301,6 +301,7 @@ You have been kicked from this group chat The group chat was shut down You are no longer in this group chat + You left this group chat due to technical reasons using account %s hosted on %s Checking %s on HTTP host