From 418cecad118329492d640a75af6173bf86973ba8 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 28 Apr 2020 06:50:04 +0200 Subject: [PATCH] remove XEP-0357 support for group chats --- .../services/PushManagementService.java | 8 --- .../conversations/entities/MucOptions.java | 4 -- .../siacs/conversations/parser/IqParser.java | 23 ------- .../services/XmppConnectionService.java | 60 ------------------- .../services/PushManagementService.java | 60 ------------------- 5 files changed, 155 deletions(-) diff --git a/src/free/java/eu/siacs/conversations/services/PushManagementService.java b/src/free/java/eu/siacs/conversations/services/PushManagementService.java index 9fac3655e..f436da434 100644 --- a/src/free/java/eu/siacs/conversations/services/PushManagementService.java +++ b/src/free/java/eu/siacs/conversations/services/PushManagementService.java @@ -15,18 +15,10 @@ public class PushManagementService { //stub implementation. only affects playstore flavor } - void registerPushTokenOnServer(Conversation conversation) { - //stub implementation. only affects playstore flavor - } - void unregisterChannel(Account account, String hash) { //stub implementation. only affects playstore flavor } - void disablePushOnServer(Conversation conversation) { - //stub implementation. only affects playstore flavor - } - public boolean available(Account account) { return false; } diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index 74a3c538d..f45d93330 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -114,10 +114,6 @@ public class MucOptions { return MessageArchiveService.Version.has(getFeatures()); } - public boolean push() { - return getFeatures().contains(Namespace.PUSH); - } - public boolean updateConfiguration(ServiceDiscoveryResult serviceDiscoveryResult) { this.serviceDiscoveryResult = serviceDiscoveryResult; String name; diff --git a/src/main/java/eu/siacs/conversations/parser/IqParser.java b/src/main/java/eu/siacs/conversations/parser/IqParser.java index e5ef662bb..f825e464d 100644 --- a/src/main/java/eu/siacs/conversations/parser/IqParser.java +++ b/src/main/java/eu/siacs/conversations/parser/IqParser.java @@ -387,29 +387,6 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived { response = mXmppConnectionService.getIqGenerator().entityTimeResponse(packet); } mXmppConnectionService.sendIqPacket(account, response, null); - } else if (packet.hasChild("pubsub", Namespace.PUBSUB) && packet.getType() == IqPacket.TYPE.SET) { - final Jid server = packet.getFrom(); - final Element pubsub = packet.findChild("pubsub", Namespace.PUBSUB); - final Element publish = pubsub == null ? null : pubsub.findChild("publish"); - final String node = publish == null ? null : publish.getAttribute("node"); - final Element item = publish == null ? null : publish.findChild("item"); - final Element notification = item == null ? null : item.findChild("notification", Namespace.PUSH); - if (notification != null && node != null && server != null) { - final Conversation conversation = mXmppConnectionService.findConversationByUuid(node); - if (conversation != null && conversation.getAccount() == account && conversation.getJid().getDomain().equals(server.getDomain())) { - Log.d(Config.LOGTAG,account.getJid().asBareJid()+": received muc push event for "+conversation.getJid().asBareJid()); - mXmppConnectionService.sendIqPacket(account, packet.generateResponse(IqPacket.TYPE.RESULT), null); - mXmppConnectionService.mucSelfPingAndRejoin(conversation); - } else { - Log.d(Config.LOGTAG,account.getJid().asBareJid()+": received push event for unknown conference from "+server); - final IqPacket response = packet.generateResponse(IqPacket.TYPE.ERROR); - final Element error = response.addChild("error"); - error.setAttribute("type", "cancel"); - error.addChild("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas"); - mXmppConnectionService.sendIqPacket(account, response, null); - } - } - } else { if (packet.getType() == IqPacket.TYPE.GET || packet.getType() == IqPacket.TYPE.SET) { final IqPacket response = packet.generateResponse(IqPacket.TYPE.ERROR); diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 0efa27618..b9204d9d5 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -610,7 +610,6 @@ public class XmppConnectionService extends Service { toggleForegroundService(true); } String pushedAccountHash = null; - String pushedChannelHash = null; boolean interactive = false; if (action != null) { final String uuid = intent.getStringExtra("uuid"); @@ -735,7 +734,6 @@ public class XmppConnectionService extends Service { break; case ACTION_FCM_MESSAGE_RECEIVED: pushedAccountHash = intent.getStringExtra("account"); - pushedChannelHash = intent.getStringExtra("channel"); Log.d(Config.LOGTAG, "push message arrived in service. account=" + pushedAccountHash); break; case Intent.ACTION_SEND: @@ -758,9 +756,6 @@ public class XmppConnectionService extends Service { "ui".equals(action), pushWasMeantForThisAccount, pingCandidates); - if (pushWasMeantForThisAccount && pushedChannelHash != null) { - checkMucStillJoined(account, pushedAccountHash, androidId); - } } if (pingNow) { for (Account account : pingCandidates) { @@ -853,20 +848,6 @@ public class XmppConnectionService extends Service { return pingNow; } - private void checkMucStillJoined(final Account account, final String hash, final String androidId) { - for (final Conversation conversation : this.conversations) { - if (conversation.getAccount() == account && conversation.getMode() == Conversational.MODE_MULTI) { - Jid jid = conversation.getJid().asBareJid(); - final String currentHash = CryptoHelper.getFingerprint(jid, androidId); - if (currentHash.equals(hash)) { - Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received cloud push notification for MUC " + jid); - return; - } - } - } - mPushManagementService.unregisterChannel(account, hash); - } - public void reinitializeMuclumbusService() { mChannelDiscoveryService.initializeMuclumbusService(); } @@ -2156,10 +2137,6 @@ public class XmppConnectionService extends Service { } } } - if (conversation.getMucOptions().push()) { - disableDirectMucPush(conversation); - mPushManagementService.disablePushOnServer(conversation); - } leaveMuc(conversation); } else { if (conversation.getContact().getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) { @@ -2758,9 +2735,6 @@ public class XmppConnectionService extends Service { } } } - if (mucOptions.push()) { - enableMucPush(conversation); - } synchronized (account.inProgressConferenceJoins) { account.inProgressConferenceJoins.remove(conversation); sendUnsentMessages(conversation); @@ -2805,40 +2779,6 @@ public class XmppConnectionService extends Service { updateConversationUi(); } } - - private void enableDirectMucPush(final Conversation conversation) { - final Account account = conversation.getAccount(); - final Jid room = conversation.getJid().asBareJid(); - final IqPacket enable = mIqGenerator.enablePush(conversation.getAccount().getJid(), conversation.getUuid(), null); - enable.setTo(room); - sendIqPacket(account, enable, (a, response) -> { - if (response.getType() == IqPacket.TYPE.RESULT) { - Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": enabled direct push for muc " + room); - } else if (response.getType() == IqPacket.TYPE.ERROR) { - Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": unable to enable direct push for muc " + room + " " + response.getError()); - } - }); - } - - private void enableMucPush(final Conversation conversation) { - enableDirectMucPush(conversation); - mPushManagementService.registerPushTokenOnServer(conversation); - } - - private void disableDirectMucPush(final Conversation conversation) { - final Account account = conversation.getAccount(); - final Jid room = conversation.getJid().asBareJid(); - final IqPacket disable = mIqGenerator.disablePush(conversation.getAccount().getJid(), conversation.getUuid()); - disable.setTo(room); - sendIqPacket(account, disable, (a, response) -> { - if (response.getType() == IqPacket.TYPE.RESULT) { - Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": disabled direct push for muc " + room); - } else if (response.getType() == IqPacket.TYPE.ERROR) { - Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": unable to disable direct push for muc " + room + " " + response.getError()); - } - }); - } - private void fetchConferenceMembers(final Conversation conversation) { final Account account = conversation.getAccount(); final AxolotlService axolotlService = account.getAxolotlService(); diff --git a/src/playstore/java/eu/siacs/conversations/services/PushManagementService.java b/src/playstore/java/eu/siacs/conversations/services/PushManagementService.java index e99de1b14..8469225b0 100644 --- a/src/playstore/java/eu/siacs/conversations/services/PushManagementService.java +++ b/src/playstore/java/eu/siacs/conversations/services/PushManagementService.java @@ -75,34 +75,6 @@ public class PushManagementService { } }); } - - void registerPushTokenOnServer(final Conversation conversation) { - Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": room "+conversation.getJid().asBareJid()+" has push support"); - retrieveFcmInstanceToken(token -> { - final Jid muc = conversation.getJid().asBareJid(); - final String androidId = PhoneHelper.getAndroidId(mXmppConnectionService); - final IqPacket packet = mXmppConnectionService.getIqGenerator().pushTokenToAppServer(getAppServer(), token, androidId, muc); - packet.setTo(muc); - mXmppConnectionService.sendIqPacket(conversation.getAccount(), packet, (a, response) -> { - final Data data = findResponseData(response); - if (response.getType() == IqPacket.TYPE.RESULT && data != null) { - try { - final String node = data.getValue("node"); - final String secret = data.getValue("secret"); - final Jid jid = Jid.of(data.getValue("jid")); - if (node != null && secret != null) { - enablePushOnServer(conversation, jid, node, secret); - } - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } - } else { - Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": invalid response from app server"); - } - }); - }); - } - private void enablePushOnServer(final Account account, final Jid appServer, final String node, final String secret) { final IqPacket enable = mXmppConnectionService.getIqGenerator().enablePush(appServer, node, secret); mXmppConnectionService.sendIqPacket(account, enable, (a, p) -> { @@ -114,38 +86,6 @@ public class PushManagementService { }); } - private void enablePushOnServer(final Conversation conversation, final Jid appServer, final String node, final String secret) { - final Jid muc = conversation.getJid().asBareJid(); - final IqPacket enable = mXmppConnectionService.getIqGenerator().enablePush(appServer, node, secret); - enable.setTo(muc); - mXmppConnectionService.sendIqPacket(conversation.getAccount(), enable, (a, p) -> { - if (p.getType() == IqPacket.TYPE.RESULT) { - Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": successfully enabled push on " + muc); - if (conversation.setAttribute(Conversation.ATTRIBUTE_ALWAYS_NOTIFY, node)) { - mXmppConnectionService.updateConversation(conversation); - } - } else if (p.getType() == IqPacket.TYPE.ERROR) { - Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": enabling push on " + muc + " failed"); - } - }); - } - - public void disablePushOnServer(final Conversation conversation) { - final Jid muc = conversation.getJid().asBareJid(); - final String node = conversation.getAttribute(Conversation.ATTRIBUTE_PUSH_NODE); - if (node != null) { - final IqPacket disable = mXmppConnectionService.getIqGenerator().disablePush(getAppServer(), node); - disable.setTo(muc); - mXmppConnectionService.sendIqPacket(conversation.getAccount(), disable, (account, response) -> { - if (response.getType() == IqPacket.TYPE.ERROR) { - Log.d(Config.LOGTAG,account.getJid().asBareJid()+": unable to disable push for room "+muc); - } - }); - } else { - Log.d(Config.LOGTAG,conversation.getAccount().getJid().asBareJid()+": room "+muc+" has no stored node. unable to disable push"); - } - } - private void retrieveFcmInstanceToken(final OnGcmInstanceTokenRetrieved instanceTokenRetrieved) { final FirebaseInstanceId firebaseInstanceId; try {