From 57c72d2818dec6c713834cfbb8c4c566a1602907 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Fri, 19 Jan 2018 22:37:02 +0100 Subject: Pipeline for incoming messages in libdino --- .../src/module/xep/0085_chat_state_notifications.vala | 9 +++++---- .../src/module/xep/0184_message_delivery_receipts.vala | 9 +++++---- xmpp-vala/src/module/xep/0203_delayed_delivery.vala | 3 ++- xmpp-vala/src/module/xep/0280_message_carbons.vala | 16 ++++++++-------- .../src/module/xep/0313_message_archive_management.vala | 5 +++-- xmpp-vala/src/module/xep/0333_chat_markers.vala | 9 +++++---- 6 files changed, 28 insertions(+), 23 deletions(-) (limited to 'xmpp-vala/src/module/xep') diff --git a/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala b/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala index cc18c52f..9d23c716 100644 --- a/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala +++ b/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala @@ -9,7 +9,7 @@ public const string STATE_GONE = "gone"; public const string STATE_COMPOSING = "composing"; public const string STATE_PAUSED = "paused"; -private const string[] STATES = {STATE_ACTIVE, STATE_INACTIVE, STATE_GONE, STATE_COMPOSING, STATE_PAUSED}; +private const string[] STATES = { STATE_ACTIVE, STATE_INACTIVE, STATE_GONE, STATE_COMPOSING, STATE_PAUSED }; public class Module : XmppStreamModule { public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, "0085_chat_state_notifications"); @@ -63,10 +63,11 @@ public class SendPipelineListener : StanzaListener { public override string action_group { get { return "ADD_NODES"; } } public override string[] after_actions { get { return after_actions_const; } } - public override async void run(XmppStream stream, MessageStanza message) { - if (message.body == null) return; - if (message.type_ != MessageStanza.TYPE_CHAT) return; + public override async bool run(XmppStream stream, MessageStanza message) { + if (message.body == null) return false; + if (message.type_ != MessageStanza.TYPE_CHAT) return false; message.stanza.put_node(new StanzaNode.build(STATE_ACTIVE, NS_URI).add_self_xmlns()); + return false; } } diff --git a/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala b/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala index 5e3cb320..b51178c7 100644 --- a/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala +++ b/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala @@ -48,12 +48,13 @@ public class SendPipelineListener : StanzaListener { public override string action_group { get { return "ADD_NODES"; } } public override string[] after_actions { get { return after_actions_const; } } - public override async void run(XmppStream stream, MessageStanza message) { + public override async bool run(XmppStream stream, MessageStanza message) { StanzaNode? received_node = message.stanza.get_subnode("received", NS_URI); - if (received_node != null) return; - if (message.body == null) return; - if (message.type_ == MessageStanza.TYPE_GROUPCHAT) return; + if (received_node != null) return false; + if (message.body == null) return false; + if (message.type_ == MessageStanza.TYPE_GROUPCHAT) return false; message.stanza.put_node(new StanzaNode.build("request", NS_URI).add_self_xmlns()); + return false; } } diff --git a/xmpp-vala/src/module/xep/0203_delayed_delivery.vala b/xmpp-vala/src/module/xep/0203_delayed_delivery.vala index 8581ed93..39666fa8 100644 --- a/xmpp-vala/src/module/xep/0203_delayed_delivery.vala +++ b/xmpp-vala/src/module/xep/0203_delayed_delivery.vala @@ -51,9 +51,10 @@ public class ReceivedPipelineListener : StanzaListener { public override string action_group { get { return "ADD_NODE"; } } public override string[] after_actions { get { return after_actions_const; } } - public override async void run(XmppStream stream, MessageStanza message) { + public override async bool run(XmppStream stream, MessageStanza message) { DateTime? datetime = Module.get_time_for_message(message); if (datetime != null) message.add_flag(new MessageFlag(datetime)); + return false; } } diff --git a/xmpp-vala/src/module/xep/0280_message_carbons.vala b/xmpp-vala/src/module/xep/0280_message_carbons.vala index 9e85a607..fca35606 100644 --- a/xmpp-vala/src/module/xep/0280_message_carbons.vala +++ b/xmpp-vala/src/module/xep/0280_message_carbons.vala @@ -44,7 +44,7 @@ public class ReceivedPipelineListener : StanzaListener { public override string action_group { get { return "EXTRACT_MESSAGE_2"; } } public override string[] after_actions { get { return after_actions_const; } } - public override async void run(XmppStream stream, MessageStanza message) { + public override async bool run(XmppStream stream, MessageStanza message) { StanzaNode? received_node = message.stanza.get_subnode("received", NS_URI); StanzaNode? sent_node = received_node == null ? message.stanza.get_subnode("sent", NS_URI) : null; StanzaNode? carbons_node = received_node != null ? received_node : sent_node; @@ -55,18 +55,18 @@ public class ReceivedPipelineListener : StanzaListener { string? from_attribute = message_node.get_attribute("from", Xmpp.NS_URI); // Any forwarded copies received by a Carbons-enabled client MUST be from that user's bare JID; any copies that do not meet this requirement MUST be ignored. if (from_attribute != null && from_attribute == stream.get_flag(Bind.Flag.IDENTITY).my_jid.bare_jid.to_string()) { - if (received_node != null) { - message.add_flag(new MessageFlag(MessageFlag.TYPE_RECEIVED)); - } else if (sent_node != null) { - message.add_flag(new MessageFlag(MessageFlag.TYPE_SENT)); - } - message.stanza = message_node; - message.rerun_parsing = true; + return true; + } + if (received_node != null) { + message.add_flag(new MessageFlag(MessageFlag.TYPE_RECEIVED)); + } else if (sent_node != null) { + message.add_flag(new MessageFlag(MessageFlag.TYPE_SENT)); } message.stanza = message_node; message.rerun_parsing = true; } } + return false; } } diff --git a/xmpp-vala/src/module/xep/0313_message_archive_management.vala b/xmpp-vala/src/module/xep/0313_message_archive_management.vala index 1c1b51e3..343a5fbd 100644 --- a/xmpp-vala/src/module/xep/0313_message_archive_management.vala +++ b/xmpp-vala/src/module/xep/0313_message_archive_management.vala @@ -91,9 +91,9 @@ public class ReceivedPipelineListener : StanzaListener { public override string action_group { get { return "EXTRACT_MESSAGE_1"; } } public override string[] after_actions { get { return after_actions_const; } } - public override async void run(XmppStream stream, MessageStanza message) { + public override async bool run(XmppStream stream, MessageStanza message) { // if (message.from != stream.remote_name) return; - if (stream.get_flag(Flag.IDENTITY) == null) return; + if (stream.get_flag(Flag.IDENTITY) == null) return false; StanzaNode? message_node = message.stanza.get_deep_subnode(NS_VER(stream) + ":result", "urn:xmpp:forward:0:forwarded", Xmpp.NS_URI + ":message"); if (message_node != null) { @@ -104,6 +104,7 @@ public class ReceivedPipelineListener : StanzaListener { message.stanza = message_node; message.rerun_parsing = true; } + return false; } } diff --git a/xmpp-vala/src/module/xep/0333_chat_markers.vala b/xmpp-vala/src/module/xep/0333_chat_markers.vala index 2cba957a..d5f46c43 100644 --- a/xmpp-vala/src/module/xep/0333_chat_markers.vala +++ b/xmpp-vala/src/module/xep/0333_chat_markers.vala @@ -61,12 +61,13 @@ public class SendPipelineListener : StanzaListener { public override string action_group { get { return "ADD_NODES"; } } public override string[] after_actions { get { return after_actions_const; } } - public override async void run(XmppStream stream, MessageStanza message) { + public override async bool run(XmppStream stream, MessageStanza message) { StanzaNode? received_node = message.stanza.get_subnode("received", NS_URI); - if (received_node != null) return; - if (message.body == null) return; - if (message.type_ != MessageStanza.TYPE_CHAT) return; + if (received_node != null) return false; + if (message.body == null) return false; + if (message.type_ != MessageStanza.TYPE_CHAT) return false; message.stanza.put_node(new StanzaNode.build("markable", NS_URI).add_self_xmlns()); + return false; } } -- cgit v1.2.3-70-g09d2