Update XMPPService.swift
This commit is contained in:
1 parent
69195efd36
commit
395100f0f5
1 file changed
+23
-25
@@ -1838,7 +1838,7 @@ final class XMPPService {
|
||||
makeMembersOnly: Bool
|
||||
) async throws -> Bool {
|
||||
let roomJID = JID(room.jid)
|
||||
let configuration: DataForm = try await withCheckedThrowingContinuation {
|
||||
let configuration: RoomConfig = try await withCheckedThrowingContinuation {
|
||||
continuation in
|
||||
muc.getRoomConfiguration(roomJid: roomJID) { result in
|
||||
switch result {
|
||||
@@ -1849,33 +1849,30 @@ final class XMPPService {
|
||||
}
|
||||
|
||||
var supportsNonAnonymousRooms = false
|
||||
if let field: DataForm.ListSingleField = configuration.getField(
|
||||
named: "muc#roomconfig_whois")
|
||||
{
|
||||
field.value = "anyone"
|
||||
supportsNonAnonymousRooms = true
|
||||
} else if let field: DataForm.TextSingleField = configuration.getField(
|
||||
named: "muc#roomconfig_whois")
|
||||
{
|
||||
field.value = "anyone"
|
||||
|
||||
// Update the whois field to non-anonymous
|
||||
if let whoisField = configuration.getField(named: "muc#roomconfig_whois") {
|
||||
whoisField.value = "anyone"
|
||||
supportsNonAnonymousRooms = true
|
||||
}
|
||||
if let field: DataForm.ListMultiField = configuration.getField(
|
||||
named: "muc#roomconfig_getmemberlist")
|
||||
{
|
||||
field.value = Array(Set(field.value + ["moderator", "participant"])).sorted()
|
||||
|
||||
// Update member list visibility
|
||||
if let memberListField = configuration.getField(named: "muc#roomconfig_getmemberlist") {
|
||||
if let currentValue = memberListField.value as? [String] {
|
||||
memberListField.value = Array(Set(currentValue + ["moderator", "participant"]))
|
||||
.sorted()
|
||||
}
|
||||
}
|
||||
if makeMembersOnly,
|
||||
let field: DataForm.BooleanField = configuration.getField(
|
||||
named: "muc#roomconfig_membersonly")
|
||||
{
|
||||
field.value = true
|
||||
}
|
||||
if makeMembersOnly,
|
||||
let field: DataForm.BooleanField = configuration.getField(
|
||||
named: "muc#roomconfig_persistentroom")
|
||||
{
|
||||
field.value = true
|
||||
|
||||
// Set members only if requested
|
||||
if makeMembersOnly {
|
||||
if let membersOnlyField = configuration.getField(named: "muc#roomconfig_membersonly") {
|
||||
membersOnlyField.value = true
|
||||
}
|
||||
if let persistentField = configuration.getField(named: "muc#roomconfig_persistentroom")
|
||||
{
|
||||
persistentField.value = true
|
||||
}
|
||||
}
|
||||
|
||||
try await withCheckedThrowingContinuation {
|
||||
@@ -1887,6 +1884,7 @@ final class XMPPService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if supportsNonAnonymousRooms {
|
||||
omemoConfiguredRoomJIDs.insert(room.jid.stringValue.lowercased())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user