aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdino/src/service/message_processor.vala4
-rw-r--r--xmpp-vala/src/module/xep/0085_chat_state_notifications.vala21
2 files changed, 7 insertions, 18 deletions
diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala
index 12bbeeac..45f06a69 100644
--- a/libdino/src/service/message_processor.vala
+++ b/libdino/src/service/message_processor.vala
@@ -451,6 +451,10 @@ public class MessageProcessor : StreamInteractionModule, Object {
}
}
+ if (conversation.get_send_typing_setting(stream_interactor) == Conversation.Setting.ON) {
+ ChatStateNotifications.add_state_to_message(new_message, ChatStateNotifications.STATE_ACTIVE);
+ }
+
stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, new_message, (_, res) => {
try {
stream.get_module(MessageModule.IDENTITY).send_message.end(res);
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 fa0360c0..7634e605 100644
--- a/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala
+++ b/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala
@@ -16,14 +16,12 @@ public class Module : XmppStreamModule {
public signal void chat_state_received(XmppStream stream, Jid jid, string state, MessageStanza stanza);
- private SendPipelineListener send_pipeline_listener = new SendPipelineListener();
-
/**
* "A message stanza that does not contain standard messaging content [...] SHOULD be a state other than <active/>" (0085, 5.6)
*/
public void send_state(XmppStream stream, Jid jid, string message_type, string state) {
MessageStanza message = new MessageStanza() { to=jid, type_=message_type };
- message.stanza.put_node(new StanzaNode.build(state, NS_URI).add_self_xmlns());
+ add_state_to_message(message, state);
MessageProcessingHints.set_message_hint(message, MessageProcessingHints.HINT_NO_STORE);
@@ -32,14 +30,12 @@ public class Module : XmppStreamModule {
public override void attach(XmppStream stream) {
stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
- stream.get_module(MessageModule.IDENTITY).send_pipeline.connect(send_pipeline_listener);
stream.get_module(MessageModule.IDENTITY).received_message.connect(on_received_message);
}
public override void detach(XmppStream stream) {
stream.get_module(ServiceDiscovery.Module.IDENTITY).remove_feature(stream, NS_URI);
stream.get_module(MessageModule.IDENTITY).received_message.disconnect(on_received_message);
- stream.get_module(MessageModule.IDENTITY).send_pipeline.disconnect(send_pipeline_listener);
}
public override string get_ns() { return NS_URI; }
@@ -57,19 +53,8 @@ public class Module : XmppStreamModule {
}
}
-public class SendPipelineListener : StanzaListener<MessageStanza> {
-
- private string[] after_actions_const = {"MODIFY_BODY"};
-
- public override string action_group { get { return "ADD_NODES"; } }
- public override string[] after_actions { get { return after_actions_const; } }
-
- 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;
- }
+public static void add_state_to_message(MessageStanza message, string state) {
+ message.stanza.put_node(new StanzaNode.build(state, NS_URI).add_self_xmlns());
}
}