aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/message_processor.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-04-03 22:49:59 +0200
committerfiaxh <git@lightrise.org>2020-04-03 22:49:59 +0200
commit871ff33ac79f3d17b0260b8bfcd27780038edd6d (patch)
treef8079e29db5d0f9294fbfbfb47b93b0403249cc9 /libdino/src/service/message_processor.vala
parent1c8e15c408f57d93461e6adb33c4c4415ac49267 (diff)
downloaddino-871ff33ac79f3d17b0260b8bfcd27780038edd6d.tar.gz
dino-871ff33ac79f3d17b0260b8bfcd27780038edd6d.zip
Add support for last message correction
Diffstat (limited to 'libdino/src/service/message_processor.vala')
-rw-r--r--libdino/src/service/message_processor.vala21
1 files changed, 21 insertions, 0 deletions
diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala
index fd719eda..0120fcd4 100644
--- a/libdino/src/service/message_processor.vala
+++ b/libdino/src/service/message_processor.vala
@@ -40,6 +40,7 @@ public class MessageProcessor : StreamInteractionModule, Object {
received_pipeline.connect(new DeduplicateMessageListener(this, db));
received_pipeline.connect(new FilterMessageListener());
received_pipeline.connect(new StoreMessageListener(stream_interactor));
+ received_pipeline.connect(new StoreContentItemListener(stream_interactor));
received_pipeline.connect(new MamMessageListener(stream_interactor));
stream_interactor.account_added.connect(on_account_added);
@@ -62,6 +63,7 @@ public class MessageProcessor : StreamInteractionModule, Object {
public Entities.Message send_message(Entities.Message message, Conversation conversation) {
stream_interactor.get_module(MessageStorage.IDENTITY).add_message(message, conversation);
+ stream_interactor.get_module(ContentItemStore.IDENTITY).insert_message(message, conversation);
send_xmpp_message(message, conversation);
message_sent(message, conversation);
return message;
@@ -526,6 +528,25 @@ public class MessageProcessor : StreamInteractionModule, Object {
}
}
+ private class StoreContentItemListener : MessageListener {
+
+ public string[] after_actions_const = new string[]{ "DEDUPLICATE", "DECRYPT", "FILTER_EMPTY", "STORE", "CORRECTION" };
+ public override string action_group { get { return "STORE_CONTENT_ITEM"; } }
+ public override string[] after_actions { get { return after_actions_const; } }
+
+ private StreamInteractor stream_interactor;
+
+ public StoreContentItemListener(StreamInteractor stream_interactor) {
+ this.stream_interactor = stream_interactor;
+ }
+
+ public override async bool run(Entities.Message message, Xmpp.MessageStanza stanza, Conversation conversation) {
+ if (message.body == null) return true;
+ stream_interactor.get_module(ContentItemStore.IDENTITY).insert_message(message, conversation);
+ return false;
+ }
+ }
+
private class MamMessageListener : MessageListener {
public string[] after_actions_const = new string[]{ "DEDUPLICATE" };