aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/muc_manager.vala
diff options
context:
space:
mode:
Diffstat (limited to 'libdino/src/service/muc_manager.vala')
-rw-r--r--libdino/src/service/muc_manager.vala23
1 files changed, 22 insertions, 1 deletions
diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala
index 5cfe5528..17787387 100644
--- a/libdino/src/service/muc_manager.vala
+++ b/libdino/src/service/muc_manager.vala
@@ -68,6 +68,15 @@ public class MucManager : StreamInteractionModule, Object {
if (last_message != null) history_since = last_message.time;
}
+ bool receive_history = true;
+ EntityInfo entity_info = stream_interactor.get_module(EntityInfo.IDENTITY);
+ bool can_do_mam = yield entity_info.has_feature(account, jid, Xmpp.MessageArchiveManagement.NS_URI_2);
+ print(@"$(jid) $can_do_mam\n");
+ if (can_do_mam) {
+ receive_history = false;
+ history_since = null;
+ }
+
if (!mucs_joining.has_key(account)) {
mucs_joining[account] = new HashSet<Jid>(Jid.hash_bare_func, Jid.equals_bare_func);
}
@@ -78,7 +87,7 @@ public class MucManager : StreamInteractionModule, Object {
}
mucs_todo[account].add(jid.with_resource(nick_));
- Muc.JoinResult? res = yield stream.get_module(Xep.Muc.Module.IDENTITY).enter(stream, jid.bare_jid, nick_, password, history_since, null);
+ Muc.JoinResult? res = yield stream.get_module(Xep.Muc.Module.IDENTITY).enter(stream, jid.bare_jid, nick_, password, history_since, receive_history, null);
mucs_joining[account].remove(jid);
@@ -91,6 +100,18 @@ public class MucManager : StreamInteractionModule, Object {
Conversation joined_conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.GROUPCHAT);
joined_conversation.nickname = nick;
stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(joined_conversation);
+
+ if (can_do_mam) {
+ if (conversation == null) {
+ // We never joined the conversation before, just fetch the latest MAM page
+ yield stream_interactor.get_module(MessageProcessor.IDENTITY).history_sync
+ .fetch_latest_page(account, jid.bare_jid, null, new DateTime.from_unix_utc(0));
+ } else {
+ // Fetch everything up to the last time the user actively joined
+ stream_interactor.get_module(MessageProcessor.IDENTITY).history_sync
+ .fetch_everything.begin(account, jid.bare_jid, conversation.active_last_changed);
+ }
+ }
} else if (res.muc_error != null) {
// Join failed
enter_errors[jid] = res.muc_error;