diff options
author | fiaxh <git@mx.ax.lt> | 2017-08-18 00:46:40 +0200 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-08-19 00:31:44 +0200 |
commit | dff8e08669996936cb58884c71b5ecd6ad7b1f76 (patch) | |
tree | 1bed7be48a042ca788f466a149ab0f434a53c34f /libdino/src/service/message_processor.vala | |
parent | 299f52df3af8bc7dafcd9a5a6e12d31042734357 (diff) | |
download | dino-dff8e08669996936cb58884c71b5ecd6ad7b1f76.tar.gz dino-dff8e08669996936cb58884c71b5ecd6ad7b1f76.zip |
MAM fixes
- don't send first request for timestamp -60
- only open conversation for messages within last 24h
- always show latest message in conversation tabs
Diffstat (limited to 'libdino/src/service/message_processor.vala')
-rw-r--r-- | libdino/src/service/message_processor.vala | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala index 14d4ef28..d1490aa0 100644 --- a/libdino/src/service/message_processor.vala +++ b/libdino/src/service/message_processor.vala @@ -45,7 +45,8 @@ public class MessageProcessor : StreamInteractionModule, Object { on_message_received(account, message); }); stream_interactor.module_manager.get_module(account, Xmpp.Xep.MessageArchiveManagement.Module.IDENTITY).feature_available.connect( (stream) => { - stream.get_module(Xep.MessageArchiveManagement.Module.IDENTITY).query_archive(stream, null, account.mam_earliest_synced.add_minutes(-1), null); + DateTime start_time = account.mam_earliest_synced.to_unix() > 60 ? account.mam_earliest_synced.add_minutes(-1) : account.mam_earliest_synced; + stream.get_module(Xep.MessageArchiveManagement.Module.IDENTITY).query_archive(stream, null, start_time, null); }); } @@ -102,15 +103,21 @@ public class MessageProcessor : StreamInteractionModule, Object { if ((is_uuid && !db.contains_message_by_stanza_id(new_message.stanza_id, conversation.account)) || (!is_uuid && !db.contains_message(new_message, conversation.account))) { stream_interactor.get_module(MessageStorage.IDENTITY).add_message(new_message, conversation); - if (new_message.direction == Entities.Message.DIRECTION_SENT) { - message_sent(new_message, conversation); - } else { - message_received(new_message, conversation); + + bool is_mam_message = Xep.MessageArchiveManagement.MessageFlag.get_flag(stanza) != null; + bool is_recent = new_message.local_time.compare(new DateTime.now_utc().add_hours(-24)) > 0; + if (!is_mam_message || is_recent) { + print(new_message.local_time.to_string() + "\n"); + if (new_message.direction == Entities.Message.DIRECTION_SENT) { + message_sent(new_message, conversation); + } else { + message_received(new_message, conversation); + } } Core.XmppStream? stream = stream_interactor.get_stream(conversation.account); Xep.MessageArchiveManagement.Flag? mam_flag = stream != null ? stream.get_flag(Xep.MessageArchiveManagement.Flag.IDENTITY) : null; - if (Xep.MessageArchiveManagement.MessageFlag.get_flag(stanza) != null || (mam_flag != null && mam_flag.cought_up == true)) { + if (is_mam_message || (mam_flag != null && mam_flag.cought_up == true)) { conversation.account.mam_earliest_synced = new_message.local_time; } } |