From 73250e09af4bfeb2f4ca0d2a2223140d81e78808 Mon Sep 17 00:00:00 2001 From: Arne Date: Sun, 26 Dec 2021 22:45:59 +0100 Subject: [PATCH] fix sending room invitation multiple times --- .../siacs/conversations/parser/MessageParser.java | 13 +++++++++++-- .../services/XmppConnectionService.java | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 7a0aa300c..e3e0122e9 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -1,5 +1,8 @@ package eu.siacs.conversations.parser; +import static eu.siacs.conversations.entities.Message.DELETED_MESSAGE_BODY; +import static eu.siacs.conversations.entities.Message.DELETED_MESSAGE_BODY_OLD; + import android.util.Log; import android.util.Pair; @@ -565,7 +568,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece } else if (invite.direct && (mucUserElement != null || invite.inviter == null || mXmppConnectionService.isMuc(account, invite.inviter))) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring direct invite to " + invite.jid + " because it was received in MUC"); } else { - invite.execute(account); + invite.execute(account, packet.getBody()); return; } } @@ -1229,6 +1232,10 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece } public boolean execute(Account account) { + return execute(account, null); + } + + public boolean execute(Account account, LocalizedContent body) { if (jid != null) { Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, jid, true, false); if (conversation.getMucOptions().online()) { @@ -1240,7 +1247,9 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece final Contact contact = inviter != null ? account.getRoster().getContactFromContactList(inviter) : null; mXmppConnectionService.joinMuc(conversation, contact != null && contact.mutualPresenceSubscription()); mXmppConnectionService.updateConversationUi(); - mXmppConnectionService.showInvitationNotification(conversation, contact); + if (body != null) { + mXmppConnectionService.showInvitationNotification(conversation, contact, body); + } } return true; } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 15cdea0bc..5f67407d1 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -5363,8 +5363,8 @@ public class XmppConnectionService extends Service { } } - public void showInvitationNotification(final Conversation conversation, final Contact contact) { - final String messageId = "MUC_INVITATION_" + System.currentTimeMillis(); + public void showInvitationNotification(final Conversation conversation, final Contact contact, final LocalizedContent id) { + final String messageId = "MUC_INVITATION_" + id; final Message message = new Message( conversation, Message.STATUS_RECEIVED,