diff options
author | fiaxh <git@lightrise.org> | 2019-05-12 00:09:50 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2019-05-16 11:12:14 -0600 |
commit | d3c6e5c62cb405cb6db646ee1ee03ca1e51d5e00 (patch) | |
tree | f304fb028397c668d87651e4e9350c3d009c280c /libdino/src | |
parent | 951be638f6596e9156dd087c310837cfeda242b3 (diff) | |
download | dino-d3c6e5c62cb405cb6db646ee1ee03ca1e51d5e00.tar.gz dino-d3c6e5c62cb405cb6db646ee1ee03ca1e51d5e00.zip |
Enable sending chat state notifications in private rooms
Diffstat (limited to 'libdino/src')
-rw-r--r-- | libdino/src/service/chat_interaction.vala | 10 | ||||
-rw-r--r-- | libdino/src/service/counterpart_interaction_manager.vala | 8 | ||||
-rw-r--r-- | libdino/src/service/muc_manager.vala | 4 |
3 files changed, 19 insertions, 3 deletions
diff --git a/libdino/src/service/chat_interaction.vala b/libdino/src/service/chat_interaction.vala index e273cc32..77176d93 100644 --- a/libdino/src/service/chat_interaction.vala +++ b/libdino/src/service/chat_interaction.vala @@ -171,9 +171,13 @@ public class ChatInteraction : StreamInteractionModule, Object { 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 && - conversation.type_ != Conversation.Type.GROUPCHAT) { - stream.get_module(Xep.ChatStateNotifications.Module.IDENTITY).send_state(stream, conversation.counterpart, state); + 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); + } } } } diff --git a/libdino/src/service/counterpart_interaction_manager.vala b/libdino/src/service/counterpart_interaction_manager.vala index 68589003..7da65650 100644 --- a/libdino/src/service/counterpart_interaction_manager.vala +++ b/libdino/src/service/counterpart_interaction_manager.vala @@ -52,6 +52,14 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object { Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation_for_message(message); if (conversation == null) return; + // Don't show our own typing notification in MUCs + if (conversation.type_ == Conversation.Type.GROUPCHAT) { + Jid? own_muc_jid = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(jid.bare_jid, account); + if (own_muc_jid != null && own_muc_jid.equals(jid)) { + return; + } + } + if (!chat_states.has_key(conversation)) { chat_states[conversation] = new HashMap<Jid, string>(Jid.hash_func, Jid.equals_func); } diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala index 534f9d75..c376a5d9 100644 --- a/libdino/src/service/muc_manager.vala +++ b/libdino/src/service/muc_manager.vala @@ -111,6 +111,10 @@ public class MucManager : StreamInteractionModule, Object { return flag.has_room_feature(jid, Xep.Muc.Feature.NON_ANONYMOUS) && flag.has_room_feature(jid, Xep.Muc.Feature.MEMBERS_ONLY); } + public bool is_public_room(Account account, Jid jid) { + return is_groupchat(jid, account) && !is_private_room(account, jid); + } + public Gee.List<Jid>? get_occupants(Jid jid, Account account) { if (is_groupchat(jid, account)) { Gee.List<Jid> ret = new ArrayList<Jid>(Jid.equals_func); |