Don't send delivery recipts or chat states for own messages

fixes #631
This commit is contained in:
fiaxh 2019-10-20 00:14:52 +02:00
parent 394862dbd3
commit c032ab00ec
3 changed files with 15 additions and 6 deletions

View file

@ -177,6 +177,9 @@ public class ChatInteraction : StreamInteractionModule, Object {
ChatInteraction outer = stream_interactor.get_module(ChatInteraction.IDENTITY); ChatInteraction outer = stream_interactor.get_module(ChatInteraction.IDENTITY);
outer.send_delivery_receipt(message, stanza, conversation); outer.send_delivery_receipt(message, stanza, conversation);
// Send chat marker
if (message.direction == Entities.Message.DIRECTION_SENT) return false;
if (outer.is_active_focus(conversation)) { if (outer.is_active_focus(conversation)) {
outer.check_send_read(); outer.check_send_read();
conversation.read_up_to = message; conversation.read_up_to = message;
@ -208,15 +211,21 @@ public class ChatInteraction : StreamInteractionModule, Object {
} }
private void send_delivery_receipt(Entities.Message message, Xmpp.MessageStanza stanza, Conversation conversation) { private void send_delivery_receipt(Entities.Message message, Xmpp.MessageStanza stanza, Conversation conversation) {
if (message.direction == Entities.Message.DIRECTION_SENT) return;
if (!Xep.MessageDeliveryReceipts.Module.requests_receipt(stanza)) return;
if (conversation.type_ == Conversation.Type.GROUPCHAT) return;
XmppStream? stream = stream_interactor.get_stream(conversation.account); XmppStream? stream = stream_interactor.get_stream(conversation.account);
if (stream != null && conversation.type_ != Conversation.Type.GROUPCHAT && Xep.MessageDeliveryReceipts.Module.requests_receipt(stanza)) { if (stream != null) {
stream.get_module(Xep.MessageDeliveryReceipts.Module.IDENTITY).send_received(stream, message.from, message.stanza_id); stream.get_module(Xep.MessageDeliveryReceipts.Module.IDENTITY).send_received(stream, message.from, message.stanza_id);
} }
} }
private void send_chat_state_notification(Conversation conversation, string state) { private void send_chat_state_notification(Conversation conversation, string state) {
if (conversation.get_send_typing_setting(stream_interactor) != Conversation.Setting.ON) return;
XmppStream? stream = stream_interactor.get_stream(conversation.account); XmppStream? stream = stream_interactor.get_stream(conversation.account);
if (stream != null && conversation.get_send_typing_setting(stream_interactor) == Conversation.Setting.ON) { if (stream != null) {
string message_type = conversation.type_ == Conversation.Type.GROUPCHAT ? Xmpp.MessageStanza.TYPE_GROUPCHAT : Xmpp.MessageStanza.TYPE_CHAT; string message_type = conversation.type_ == Conversation.Type.GROUPCHAT ? Xmpp.MessageStanza.TYPE_GROUPCHAT : Xmpp.MessageStanza.TYPE_CHAT;
stream.get_module(Xep.ChatStateNotifications.Module.IDENTITY).send_state(stream, conversation.counterpart, message_type, state); stream.get_module(Xep.ChatStateNotifications.Module.IDENTITY).send_state(stream, conversation.counterpart, message_type, state);
} }

View file

@ -211,7 +211,7 @@ public class StreamModule : XmppStreamModule {
} }
} }
identity_key = bundle.identity_key; identity_key = bundle.identity_key;
signed_pre_key_id = bundle.signed_pre_key_id;; signed_pre_key_id = bundle.signed_pre_key_id;
signed_pre_key = bundle.signed_pre_key; signed_pre_key = bundle.signed_pre_key;
} }

View file

@ -134,12 +134,12 @@ public class DataForm {
public class HiddenField : Field { public class HiddenField : Field {
public HiddenField() { public HiddenField() {
base(); base();
type_ = Type.HIDDEN;; type_ = Type.HIDDEN;
node.put_attribute("type", "hidden"); node.put_attribute("type", "hidden");
} }
public HiddenField.from_node(StanzaNode node) { public HiddenField.from_node(StanzaNode node) {
base.from_node(node); base.from_node(node);
type_ = Type.HIDDEN;; type_ = Type.HIDDEN;
} }
} }
@ -160,7 +160,7 @@ public class DataForm {
} }
public ListSingleField(StanzaNode node) { public ListSingleField(StanzaNode node) {
base.from_node(node); base.from_node(node);
type_ = Type.LIST_SINGLE;; type_ = Type.LIST_SINGLE;
} }
} }