aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service
diff options
context:
space:
mode:
Diffstat (limited to 'libdino/src/service')
-rw-r--r--libdino/src/service/message_correction.vala28
-rw-r--r--libdino/src/service/message_processor.vala34
2 files changed, 33 insertions, 29 deletions
diff --git a/libdino/src/service/message_correction.vala b/libdino/src/service/message_correction.vala
index 6d4137d4..e6401a05 100644
--- a/libdino/src/service/message_correction.vala
+++ b/libdino/src/service/message_correction.vala
@@ -39,27 +39,21 @@ public class MessageCorrection : StreamInteractionModule, MessageListener {
});
}
- public void send_correction(Conversation conversation, Message old_message, string correction_text) {
- string stanza_id = old_message.edit_to ?? old_message.stanza_id;
+ public void set_correction(Conversation conversation, Message message, Message old_message) {
+ string reference_stanza_id = old_message.edit_to ?? old_message.stanza_id;
- Message out_message = stream_interactor.get_module(MessageProcessor.IDENTITY).create_out_message(correction_text, conversation);
- out_message.edit_to = stanza_id;
- out_message.set_quoted_item(old_message.quoted_item_id);
- outstanding_correction_nodes[out_message.stanza_id] = stanza_id;
- stream_interactor.get_module(MessageProcessor.IDENTITY).send_xmpp_message(out_message, conversation);
+ outstanding_correction_nodes[message.stanza_id] = reference_stanza_id;
db.message_correction.insert()
- .value(db.message_correction.message_id, out_message.id)
- .value(db.message_correction.to_stanza_id, stanza_id)
- .perform();
+ .value(db.message_correction.message_id, message.id)
+ .value(db.message_correction.to_stanza_id, reference_stanza_id)
+ .perform();
db.content_item.update()
- .with(db.content_item.foreign_id, "=", old_message.id)
- .with(db.content_item.content_type, "=", 1)
- .set(db.content_item.foreign_id, out_message.id)
- .perform();
-
- on_received_correction(conversation, out_message.id);
+ .with(db.content_item.foreign_id, "=", old_message.id)
+ .with(db.content_item.content_type, "=", 1)
+ .set(db.content_item.foreign_id, message.id)
+ .perform();
}
public bool is_own_correction_allowed(Conversation conversation, Message message) {
@@ -145,7 +139,7 @@ public class MessageCorrection : StreamInteractionModule, MessageListener {
return false;
}
- private void on_received_correction(Conversation conversation, int message_id) {
+ public void on_received_correction(Conversation conversation, int message_id) {
ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item_by_foreign(conversation, 1, message_id);
if (content_item != null) {
received_correction(content_item);
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;