From b18f49cda3cd2c9e7f5a1eda43b9e5fbbdb0a97a Mon Sep 17 00:00:00 2001 From: Konstantin Kuznetsov Date: Mon, 25 Mar 2024 12:40:00 +0300 Subject: [PATCH] Skip duplicate invites for active conversations --- libdino/src/service/muc_manager.vala | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala index c849035a..210090ca 100644 --- a/libdino/src/service/muc_manager.vala +++ b/libdino/src/service/muc_manager.vala @@ -535,12 +535,25 @@ public class MucManager : StreamInteractionModule, Object { } private void on_invite_received(Account account, Jid room_jid, Jid from_jid, string? password, string? reason) { + info("Invite received for room %s", room_jid.bare_jid.to_string()); + Gee.List conversations = stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations(account); + foreach (Conversation conversation in conversations) { + if (conversation.counterpart.bare_jid.to_string() == room_jid.bare_jid.to_string()) { + // HACK: try to skip duplicate invites for active conversations + warning("Skipping duplicate invite for conversation %s", room_jid.bare_jid.to_string()); + return; + } + } + if (!invites.has_key(account)) { invites[account] = new LinkedList(Jid.equals_func); } - if (invites[account].contains(room_jid)) return; - invites[account].add(room_jid); + if (invites[account].contains(room_jid)) { + return; + } + + invites[account].add(room_jid); invite_received(account, room_jid, from_jid, password, reason); Timeout.add_seconds(5, () => {