diff options
author | fiaxh <git@lightrise.org> | 2019-05-21 21:42:39 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2019-05-26 20:20:09 +0200 |
commit | 03f25e1f87dd4608c7cf4d0f97d1cb2e0141094d (patch) | |
tree | edbbef9cad6e0548ea27bb09c988b4717c49cb37 /libdino/src/service/chat_interaction.vala | |
parent | 32687d731f50969545e0122e13c395cfa5f859a1 (diff) | |
download | dino-03f25e1f87dd4608c7cf4d0f97d1cb2e0141094d.tar.gz dino-03f25e1f87dd4608c7cf4d0f97d1cb2e0141094d.zip |
Remove Message.stanza field
Diffstat (limited to 'libdino/src/service/chat_interaction.vala')
-rw-r--r-- | libdino/src/service/chat_interaction.vala | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/libdino/src/service/chat_interaction.vala b/libdino/src/service/chat_interaction.vala index 77176d93..9fc471fb 100644 --- a/libdino/src/service/chat_interaction.vala +++ b/libdino/src/service/chat_interaction.vala @@ -95,10 +95,9 @@ public class ChatInteraction : StreamInteractionModule, Object { private void check_send_read() { if (selected_conversation == null || selected_conversation.type_ == Conversation.Type.GROUPCHAT) return; Entities.Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_last_message(selected_conversation); - if (message != null && message.direction == Entities.Message.DIRECTION_RECEIVED && - message.stanza != null && !message.equals(selected_conversation.read_up_to)) { + if (message != null && message.direction == Entities.Message.DIRECTION_RECEIVED && !message.equals(selected_conversation.read_up_to)) { selected_conversation.read_up_to = message; - send_chat_marker(selected_conversation, message, Xep.ChatMarkers.MARKER_DISPLAYED); + send_chat_marker(message, null, selected_conversation, Xep.ChatMarkers.MARKER_DISPLAYED); } } @@ -137,47 +136,52 @@ public class ChatInteraction : StreamInteractionModule, Object { } public override async bool run(Entities.Message message, Xmpp.MessageStanza stanza, Conversation conversation) { - if (Xep.MessageArchiveManagement.MessageFlag.get_flag(message.stanza) != null) return false; + if (Xep.MessageArchiveManagement.MessageFlag.get_flag(stanza) != null) return false; ChatInteraction outer = stream_interactor.get_module(ChatInteraction.IDENTITY); - outer.send_delivery_receipt(conversation, message); + outer.send_delivery_receipt(message, stanza, conversation); if (outer.is_active_focus(conversation)) { outer.check_send_read(); conversation.read_up_to = message; - outer.send_chat_marker(conversation, message, Xep.ChatMarkers.MARKER_DISPLAYED); + outer.send_chat_marker(message, stanza, conversation, Xep.ChatMarkers.MARKER_DISPLAYED); } else { - outer.send_chat_marker(conversation, message, Xep.ChatMarkers.MARKER_RECEIVED); + outer.send_chat_marker(message, stanza, conversation, Xep.ChatMarkers.MARKER_RECEIVED); } return false; } } - private void send_chat_marker(Conversation conversation, Entities.Message message, string marker) { - XmppStream stream = stream_interactor.get_stream(conversation.account); - if (stream != null && - (marker == Xep.ChatMarkers.MARKER_RECEIVED || conversation.get_send_marker_setting() == Conversation.Setting.ON) && - Xep.ChatMarkers.Module.requests_marking(message.stanza)) { - stream.get_module(Xep.ChatMarkers.Module.IDENTITY).send_marker(stream, message.stanza.from, message.stanza_id, message.get_type_string(), marker); + private void send_chat_marker(Entities.Message message, Xmpp.MessageStanza? stanza, Conversation conversation, string marker) { + XmppStream? stream = stream_interactor.get_stream(conversation.account); + if (stream == null) return; + + switch (marker) { + case Xep.ChatMarkers.MARKER_RECEIVED: + if (stanza != null && Xep.ChatMarkers.Module.requests_marking(stanza)) { + stream.get_module(Xep.ChatMarkers.Module.IDENTITY).send_marker(stream, message.from, message.stanza_id, message.get_type_string(), Xep.ChatMarkers.MARKER_RECEIVED); + } + break; + case Xep.ChatMarkers.MARKER_DISPLAYED: + if (conversation.get_send_marker_setting(stream_interactor) == Conversation.Setting.ON) { + stream.get_module(Xep.ChatMarkers.Module.IDENTITY).send_marker(stream, message.from, message.stanza_id, message.get_type_string(), Xep.ChatMarkers.MARKER_DISPLAYED); + } + break; } } - private void send_delivery_receipt(Conversation conversation, Entities.Message message) { - XmppStream stream = stream_interactor.get_stream(conversation.account); - if (stream != null && Xep.MessageDeliveryReceipts.Module.requests_receipt(message.stanza)) { + private void send_delivery_receipt(Entities.Message message, Xmpp.MessageStanza stanza, Conversation conversation) { + XmppStream? stream = stream_interactor.get_stream(conversation.account); + if (stream != null && conversation.type_ != Conversation.Type.GROUPCHAT && Xep.MessageDeliveryReceipts.Module.requests_receipt(stanza)) { 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) { - XmppStream stream = stream_interactor.get_stream(conversation.account); - if (stream != null && conversation.get_send_typing_setting() == Conversation.Setting.ON) { - if (conversation.type_ != Conversation.Type.GROUPCHAT) { - stream.get_module(Xep.ChatStateNotifications.Module.IDENTITY).send_state(stream, conversation.counterpart, Xmpp.MessageStanza.TYPE_CHAT, state); - } - if (stream_interactor.get_module(MucManager.IDENTITY).is_private_room(conversation.account, conversation.counterpart)) { - stream.get_module(Xep.ChatStateNotifications.Module.IDENTITY).send_state(stream, conversation.counterpart, Xmpp.MessageStanza.TYPE_GROUPCHAT, state); - } + XmppStream? stream = stream_interactor.get_stream(conversation.account); + if (stream != null && conversation.get_send_typing_setting(stream_interactor) == Conversation.Setting.ON) { + string message_type = conversation.type_ == Conversation.Type.GROUPCHAT ? Xmpp.MessageStanza.TYPE_GROUPCHAT : Xmpp.MessageStanza.TYPE_GROUPCHAT; + stream.get_module(Xep.ChatStateNotifications.Module.IDENTITY).send_state(stream, conversation.counterpart, message_type, state); } } } |