Improvements to support for OMEMO in MUC #siskinim-254
This commit is contained in:
parent
0d0281638a
commit
611890393b
|
@ -250,6 +250,14 @@ class ChannelJoinViewController: UITableViewController {
|
|||
}
|
||||
}
|
||||
}
|
||||
if let whoisField: ListSingleField = config.getField(named: "muc#roomconfig_whois") {
|
||||
if invitationOnly && whoisField.options.contains(where: { $0.value == "anyone" }) {
|
||||
whoisField.value = "anyone";
|
||||
}
|
||||
if !invitationOnly && whoisField.options.contains(where: { $0.value == "moderators" }) {
|
||||
whoisField.value = "moderators";
|
||||
}
|
||||
}
|
||||
if let persistantField: BooleanField = config.getField(named: "muc#roomconfig_persistentroom") {
|
||||
persistantField.value = true;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,11 @@ class MucChatSettingsViewController: UITableViewController, UIImagePickerControl
|
|||
roomSubjectField.text = room.subject ?? "";
|
||||
pushNotificationsSwitch.isEnabled = false;
|
||||
pushNotificationsSwitch.isOn = false;
|
||||
encryptionField.text = room.options.encryption == .none ? "None" : "OMEMO";
|
||||
if let encryption = room.options.encryption {
|
||||
encryptionField.text = encryption == .none ? "None" : "OMEMO";
|
||||
} else if room.isOMEMOCapable {
|
||||
encryptionField.text = (ChatEncryption(rawValue: Settings.messageEncryption.getString() ?? "") ?? ChatEncryption.none) == .none ? "None" : "OMEMO";
|
||||
}
|
||||
refresh();
|
||||
refreshPermissions();
|
||||
}
|
||||
|
|
|
@ -321,14 +321,21 @@ class MucChatViewController: BaseChatViewControllerWithDataSourceAndContextMenuA
|
|||
}
|
||||
|
||||
guard room.state == .joined else {
|
||||
let alert: UIAlertController? = UIAlertController.init(title: "Warning", message: "You are not connected to room.\nPlease wait reconnection to room", preferredStyle: .alert);
|
||||
alert?.addAction(UIAlertAction(title: "OK", style: .default, handler: nil));
|
||||
self.present(alert!, animated: true, completion: nil);
|
||||
let alert = UIAlertController.init(title: "Warning", message: "You are not connected to room.\nPlease wait reconnection to room", preferredStyle: .alert);
|
||||
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil));
|
||||
self.present(alert, animated: true, completion: nil);
|
||||
return;
|
||||
}
|
||||
|
||||
let encryption: ChatEncryption = room.options.encryption ?? (ChatEncryption(rawValue: Settings.messageEncryption.string() ?? "") ?? .none);
|
||||
guard encryption == .none || ((room.supportedFeatures?.contains("muc_nonanonymous") ?? false) && (room.supportedFeatures?.contains("muc_membersonly") ?? false)) else {
|
||||
let canEncrypt = (room.supportedFeatures?.contains("muc_nonanonymous") ?? false) && (room.supportedFeatures?.contains("muc_membersonly") ?? false);
|
||||
|
||||
let encryption: ChatEncryption = room.options.encryption ?? (canEncrypt ? (ChatEncryption(rawValue: Settings.messageEncryption.string() ?? "") ?? .none) : .none);
|
||||
guard encryption == .none || canEncrypt else {
|
||||
if encryption == .omemo && !canEncrypt {
|
||||
let alert = UIAlertController(title: "Warning", message: "This room is not capable of sending encrypted messages. Please change encryption settings to be able to send messages", preferredStyle: .alert);
|
||||
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil));
|
||||
self.present(alert, animated: true, completion: nil);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -179,6 +179,7 @@ class MucEventHandler: XmppServiceEventHandler {
|
|||
let newName = identities.first(where: { (identity) -> Bool in
|
||||
return identity.category == "conference";
|
||||
})?.name?.trimmingCharacters(in: .whitespacesAndNewlines);
|
||||
room.supportedFeatures = features;
|
||||
|
||||
DBChatStore.instance.updateChatName(for: room.account, with: room.roomJid, name: (newName?.isEmpty ?? true) ? nil : newName);
|
||||
}, onError: nil);
|
||||
|
|
Loading…
Reference in a new issue