diff options
author | fiaxh <git@mx.ax.lt> | 2018-01-19 22:37:02 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2018-01-28 13:37:53 +0100 |
commit | 57c72d2818dec6c713834cfbb8c4c566a1602907 (patch) | |
tree | 0f7102171049cce6f6732b658d005b3c57140271 /xmpp-vala/src/module/xep | |
parent | ca331e85efe2a74a6b9b5a5ff0fbcd10a36758ce (diff) | |
download | dino-57c72d2818dec6c713834cfbb8c4c566a1602907.tar.gz dino-57c72d2818dec6c713834cfbb8c4c566a1602907.zip |
Pipeline for incoming messages in libdino
Diffstat (limited to 'xmpp-vala/src/module/xep')
6 files changed, 28 insertions, 23 deletions
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<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0085_chat_state_notifications"); @@ -63,10 +63,11 @@ public class SendPipelineListener : StanzaListener<MessageStanza> { 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<MessageStanza> { 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<MessageStanza> { 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<MessageStanza> { 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<MessageStanza> { 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<MessageStanza> { 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<MessageStanza> { 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<MessageStanza> { 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; } } |