updated XMPPService.swift fix warnings
This commit is contained in:
1 parent
5c51bacc40
commit
cd342a3f98
1 file changed
+24
-33
@@ -1838,51 +1838,42 @@ final class XMPPService {
|
|||||||
makeMembersOnly: Bool
|
makeMembersOnly: Bool
|
||||||
) async throws -> Bool {
|
) async throws -> Bool {
|
||||||
let roomJID = JID(room.jid)
|
let roomJID = JID(room.jid)
|
||||||
let configuration: JabberDataElement = try await withCheckedThrowingContinuation {
|
let roomConfig: RoomConfig = try await withCheckedThrowingContinuation { continuation in
|
||||||
continuation in
|
muc.roomConfiguration(roomJid: roomJID) { result in
|
||||||
muc.getRoomConfiguration(roomJid: roomJID) { result in
|
continuation.resume(with: result)
|
||||||
switch result {
|
|
||||||
case .success(let value): continuation.resume(returning: value)
|
|
||||||
case .failure(let error): continuation.resume(throwing: error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var supportsNonAnonymousRooms = false
|
var supportsNonAnonymousRooms = false
|
||||||
if let field: ListSingleField = configuration.getField(named: "muc#roomconfig_whois") {
|
|
||||||
field.value = "anyone"
|
if roomConfig.hasField(for: "muc#roomconfig_whois") {
|
||||||
|
roomConfig.whois = .anyone
|
||||||
supportsNonAnonymousRooms = true
|
supportsNonAnonymousRooms = true
|
||||||
} else if let field: TextSingleField = configuration.getField(named: "muc#roomconfig_whois")
|
|
||||||
{
|
|
||||||
field.value = "anyone"
|
|
||||||
supportsNonAnonymousRooms = true
|
|
||||||
}
|
|
||||||
if let field: ListMultiField = configuration.getField(named: "muc#roomconfig_getmemberlist")
|
|
||||||
{
|
|
||||||
field.value = Array(Set(field.value + ["moderator", "participant"])).sorted()
|
|
||||||
}
|
|
||||||
if makeMembersOnly,
|
|
||||||
let field: BooleanField = configuration.getField(named: "muc#roomconfig_membersonly")
|
|
||||||
{
|
|
||||||
field.value = true
|
|
||||||
}
|
|
||||||
if makeMembersOnly,
|
|
||||||
let field: BooleanField = configuration.getField(named: "muc#roomconfig_persistentroom")
|
|
||||||
{
|
|
||||||
field.value = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in
|
if roomConfig.hasField(for: "muc#roomconfig_getmemberlist") {
|
||||||
muc.setRoomConfiguration(roomJid: roomJID, configuration: configuration) { result in
|
let current = roomConfig.getMemberList ?? []
|
||||||
switch result {
|
roomConfig.getMemberList = Array(Set(current + ["moderator", "participant"])).sorted()
|
||||||
case .success(let value): continuation.resume(returning: value)
|
}
|
||||||
case .failure(let error): continuation.resume(throwing: error)
|
|
||||||
}
|
if makeMembersOnly, roomConfig.hasField(for: "muc#roomconfig_membersonly") {
|
||||||
|
roomConfig.membersOnly = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if makeMembersOnly, roomConfig.hasField(for: "muc#roomconfig_persistentroom") {
|
||||||
|
roomConfig.persistentRoom = true
|
||||||
|
}
|
||||||
|
|
||||||
|
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
|
||||||
|
muc.setRoomConfiguration(roomJid: roomJID, configuration: roomConfig) { result in
|
||||||
|
continuation.resume(with: result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if supportsNonAnonymousRooms {
|
if supportsNonAnonymousRooms {
|
||||||
omemoConfiguredRoomJIDs.insert(room.jid.stringValue.lowercased())
|
omemoConfiguredRoomJIDs.insert(room.jid.stringValue.lowercased())
|
||||||
}
|
}
|
||||||
|
|
||||||
return supportsNonAnonymousRooms
|
return supportsNonAnonymousRooms
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user