aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-06-17 14:30:46 +0200
committerfiaxh <git@lightrise.org>2020-06-23 15:54:12 +0200
commit886a519d8543cba45792a08210093c851f20a2a0 (patch)
tree639180b362b79518e0ea0523c39ae7fe36877cd6
parent6d41071da1f01678b9ab449ed7f00391067da43a (diff)
downloaddino-886a519d8543cba45792a08210093c851f20a2a0.tar.gz
dino-886a519d8543cba45792a08210093c851f20a2a0.zip
Don't offer encryption in MUC PMs
-rw-r--r--main/src/ui/chat_input/encryption_button.vala17
-rw-r--r--plugins/omemo/src/logic/manager.vala4
-rw-r--r--plugins/omemo/src/ui/bad_messages_populator.vala3
-rw-r--r--plugins/omemo/src/ui/encryption_list_entry.vala5
4 files changed, 27 insertions, 2 deletions
diff --git a/main/src/ui/chat_input/encryption_button.vala b/main/src/ui/chat_input/encryption_button.vala
index 859b7baa..11466931 100644
--- a/main/src/ui/chat_input/encryption_button.vala
+++ b/main/src/ui/chat_input/encryption_button.vala
@@ -86,8 +86,21 @@ public class EncryptionButton : MenuButton {
}
private void update_visibility() {
- visible = !stream_interactor.get_module(MucManager.IDENTITY).is_public_room(conversation.account, conversation.counterpart) ||
- conversation.encryption != Encryption.NONE;
+ if (conversation.encryption != Encryption.NONE) {
+ visible = true;
+ return;
+ }
+ switch (conversation.type_) {
+ case Conversation.Type.CHAT:
+ visible = true;
+ break;
+ case Conversation.Type.GROUPCHAT_PM:
+ visible = false;
+ break;
+ case Conversation.Type.GROUPCHAT:
+ visible = stream_interactor.get_module(MucManager.IDENTITY).is_private_room(conversation.account, conversation.counterpart);
+ break;
+ }
}
public new void set_conversation(Conversation conversation) {
diff --git a/plugins/omemo/src/logic/manager.vala b/plugins/omemo/src/logic/manager.vala
index e561bd90..64b117c7 100644
--- a/plugins/omemo/src/logic/manager.vala
+++ b/plugins/omemo/src/logic/manager.vala
@@ -95,6 +95,10 @@ public class Manager : StreamInteractionModule, Object {
private void on_pre_message_send(Entities.Message message, Xmpp.MessageStanza message_stanza, Conversation conversation) {
if (message.encryption == Encryption.OMEMO) {
+ if (message.type_ == Message.Type.GROUPCHAT_PM) {
+ message.marked = Message.Marked.WONTSEND;
+ return;
+ }
XmppStream? stream = stream_interactor.get_stream(conversation.account);
if (stream == null) {
message.marked = Entities.Message.Marked.UNSENT;
diff --git a/plugins/omemo/src/ui/bad_messages_populator.vala b/plugins/omemo/src/ui/bad_messages_populator.vala
index b8f38434..5a881c25 100644
--- a/plugins/omemo/src/ui/bad_messages_populator.vala
+++ b/plugins/omemo/src/ui/bad_messages_populator.vala
@@ -37,6 +37,9 @@ public class BadMessagesPopulator : Plugins.ConversationItemPopulator, Plugins.C
}
private void init_state() {
+
+ if (current_conversation.type_ == Conversation.Type.GROUPCHAT_PM) return;
+
var qry = db.identity_meta.select()
.join_with(db.identity, db.identity.id, db.identity_meta.identity_id)
.with(db.identity.account_id, "=", current_conversation.account.id)
diff --git a/plugins/omemo/src/ui/encryption_list_entry.vala b/plugins/omemo/src/ui/encryption_list_entry.vala
index aaec517f..a0e6bb0f 100644
--- a/plugins/omemo/src/ui/encryption_list_entry.vala
+++ b/plugins/omemo/src/ui/encryption_list_entry.vala
@@ -1,3 +1,4 @@
+using Dino.Entities;
using Gtk;
using Qlite;
using Xmpp;
@@ -42,6 +43,10 @@ public class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
}
public async void encryption_activated_async(Entities.Conversation conversation, Plugins.SetInputFieldStatus input_status_callback) {
+ if (conversation.type_ == Conversation.Type.GROUPCHAT_PM) {
+ input_status_callback(new Plugins.InputFieldStatus("Can't use encryption in a groupchat private message.", Plugins.InputFieldStatus.MessageType.ERROR, Plugins.InputFieldStatus.InputState.NO_SEND));
+ return;
+ }
MucManager muc_manager = plugin.app.stream_interactor.get_module(MucManager.IDENTITY);
Manager omemo_manager = plugin.app.stream_interactor.get_module(Manager.IDENTITY);