diff options
author | fiaxh <git@lightrise.org> | 2024-07-29 13:16:54 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2024-07-29 13:16:54 +0200 |
commit | b0ff90a14a5d127e17f2371f87e7bb659de3a68f (patch) | |
tree | a4b44a2837f94bef433adc318eb9a738425a494f /libdino/src/service/message_processor.vala | |
parent | ceb921a0148f7fdc2a9df3e6b85143bf8c26c341 (diff) | |
download | dino-b0ff90a14a5d127e17f2371f87e7bb659de3a68f.tar.gz dino-b0ff90a14a5d127e17f2371f87e7bb659de3a68f.zip |
Add initial message markup (XEP-0394) support
Diffstat (limited to 'libdino/src/service/message_processor.vala')
-rw-r--r-- | libdino/src/service/message_processor.vala | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala index 620c93eb..d8ea3e2d 100644 --- a/libdino/src/service/message_processor.vala +++ b/libdino/src/service/message_processor.vala @@ -38,6 +38,7 @@ public class MessageProcessor : StreamInteractionModule, Object { received_pipeline.connect(new FilterMessageListener()); received_pipeline.connect(new StoreMessageListener(this, stream_interactor)); received_pipeline.connect(new StoreContentItemListener(stream_interactor)); + received_pipeline.connect(new MarkupListener(stream_interactor)); stream_interactor.account_added.connect(on_account_added); @@ -45,18 +46,6 @@ public class MessageProcessor : StreamInteractionModule, Object { stream_interactor.stream_resumed.connect(send_unsent_chat_messages); } - public Entities.Message send_text(string text, Conversation conversation) { - Entities.Message message = create_out_message(text, conversation); - return send_message(message, conversation); - } - - public Entities.Message send_message(Entities.Message message, Conversation conversation) { - stream_interactor.get_module(ContentItemStore.IDENTITY).insert_message(message, conversation); - send_xmpp_message(message, conversation); - message_sent(message, conversation); - return message; - } - private void convert_sending_to_unsent_msgs(Account account) { db.message.update() .with(db.message.account_id, "=", account.id) @@ -344,6 +333,25 @@ public class MessageProcessor : StreamInteractionModule, Object { } } + private class MarkupListener : MessageListener { + + public string[] after_actions_const = new string[]{ "STORE" }; + public override string action_group { get { return "Markup"; } } + public override string[] after_actions { get { return after_actions_const; } } + + private StreamInteractor stream_interactor; + + public MarkupListener(StreamInteractor stream_interactor) { + this.stream_interactor = stream_interactor; + } + + public override async bool run(Entities.Message message, Xmpp.MessageStanza stanza, Conversation conversation) { + Gee.List<MessageMarkup.Span> markups = MessageMarkup.get_spans(stanza); + message.persist_markups(markups, message.id); + return false; + } + } + private class StoreContentItemListener : MessageListener { public string[] after_actions_const = new string[]{ "DEDUPLICATE", "DECRYPT", "FILTER_EMPTY", "STORE", "CORRECTION", "MESSAGE_REINTERPRETING" }; @@ -421,6 +429,8 @@ public class MessageProcessor : StreamInteractionModule, Object { } } + MessageMarkup.add_spans(new_message, message.get_markups()); + build_message_stanza(message, new_message, conversation); pre_message_send(message, new_message, conversation); if (message.marked == Entities.Message.Marked.UNSENT || message.marked == Entities.Message.Marked.WONTSEND) return; |