aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2021-01-12 23:10:45 +0100
committerfiaxh <git@lightrise.org>2021-01-12 23:10:45 +0100
commit59236ec01a55a6316befad5101ec95314fac42fa (patch)
tree2981fb2209707f42b84ffb4e4baf908c7f6fdc00 /libdino/src/service
parentfc18e781a5c8d6fda52ecc5f4b4da96944f969a5 (diff)
downloaddino-59236ec01a55a6316befad5101ec95314fac42fa.tar.gz
dino-59236ec01a55a6316befad5101ec95314fac42fa.zip
Add support for Direct MUC Invitations (XEP-0249)
Diffstat (limited to 'libdino/src/service')
-rw-r--r--libdino/src/service/module_manager.vala1
-rw-r--r--libdino/src/service/muc_manager.vala22
2 files changed, 22 insertions, 1 deletions
diff --git a/libdino/src/service/module_manager.vala b/libdino/src/service/module_manager.vala
index ebcff6ab..c3f524df 100644
--- a/libdino/src/service/module_manager.vala
+++ b/libdino/src/service/module_manager.vala
@@ -78,6 +78,7 @@ public class ModuleManager {
module_map[account].add(new Xep.JingleFileTransfer.Module());
module_map[account].add(new Xep.Jet.Module());
module_map[account].add(new Xep.LastMessageCorrection.Module());
+ module_map[account].add(new Xep.DirectMucInvitations.Module());
initialize_account_modules(account, module_map[account]);
}
}
diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala
index b5d85236..5a224a18 100644
--- a/libdino/src/service/muc_manager.vala
+++ b/libdino/src/service/muc_manager.vala
@@ -26,6 +26,7 @@ public class MucManager : StreamInteractionModule, Object {
private HashMap<Jid, Xep.Muc.MucEnterError> enter_errors = new HashMap<Jid, Xep.Muc.MucEnterError>(Jid.hash_func, Jid.equals_func);
private ReceivedMessageListener received_message_listener;
private HashMap<Account, BookmarksProvider> bookmarks_provider = new HashMap<Account, BookmarksProvider>(Account.hash_func, Account.equals_func);
+ private HashMap<Account, Gee.List<Jid>> invites = new HashMap<Account, Gee.List<Jid>>(Account.hash_func, Account.equals_func);
public static void start(StreamInteractor stream_interactor) {
MucManager m = new MucManager(stream_interactor);
@@ -364,7 +365,10 @@ public class MucManager : StreamInteractionModule, Object {
subject_set(account, jid, subject);
});
stream_interactor.module_manager.get_module(account, Xep.Muc.Module.IDENTITY).invite_received.connect( (stream, room_jid, from_jid, password, reason) => {
- invite_received(account, room_jid, from_jid, password, reason);
+ on_invite_received(account, room_jid, from_jid, password, reason);
+ });
+ stream_interactor.module_manager.get_module(account, Xep.DirectMucInvitations.Module.IDENTITY).invite_received.connect( (stream, room_jid, from_jid, password, reason) => {
+ on_invite_received(account, room_jid, from_jid, password, reason);
});
stream_interactor.module_manager.get_module(account, Xep.Muc.Module.IDENTITY).voice_request_received.connect( (stream, room_jid, from_jid, nick) => {
voice_request_received(account, room_jid, from_jid, nick);
@@ -409,6 +413,22 @@ public class MucManager : StreamInteractionModule, Object {
}
}
+ private void on_invite_received(Account account, Jid room_jid, Jid from_jid, string? password, string? reason) {
+ if (!invites.has_key(account)) {
+ invites[account] = new LinkedList<Jid>(Jid.equals_func);
+ }
+ 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, () => {
+ // We don't want to show the same invite (direct+mediated) twice, but a distinct invite is fine
+ invites[account].remove(room_jid);
+ return false;
+ });
+ }
+
private void join_all_active(Account account) {
Gee.List<Conversation> conversations = stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations(account);
foreach (Conversation conversation in conversations) {