Don't offer encryption in MUC PMs

This commit is contained in:
fiaxh 2020-06-17 14:30:46 +02:00
parent 6d41071da1
commit 886a519d85
4 changed files with 27 additions and 2 deletions

View file

@ -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) {

View file

@ -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;

View file

@ -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)

View file

@ -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);