mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 23:18:27 +02:00
refactor set serveracl and fix json key
This commit is contained in:
@@ -1708,10 +1708,8 @@ BOOL reloadToggleCell = false;
|
||||
NSString *serverACLRule = updatedItemsDict[kRoomSettingsFederationKey];
|
||||
if (serverACLRule)
|
||||
{
|
||||
NSMutableDictionary *content = [[NSMutableDictionary alloc] initWithDictionary:@{
|
||||
@"allow": @[serverACLRule],
|
||||
@"allowIPLiterals" : @false
|
||||
}];
|
||||
|
||||
NSDictionary *content = [mxRoom createServerACLContentWithServerACL:serverACLRule];
|
||||
|
||||
pendingOperation = [mxRoom sendStateEventOfType:kMXEventTypeStringRoomServerACL content:content stateKey:nil success:^(NSString *eventId) {
|
||||
if (weakSelf)
|
||||
|
||||
@@ -117,4 +117,32 @@ import MatrixSDK
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create map for content json with boolean
|
||||
func createServerACL(isFederated: Bool) -> [String:Any] {
|
||||
var serverACL: String = ""
|
||||
if isFederated {
|
||||
serverACL = "*"
|
||||
} else {
|
||||
if let myUserIDComponents = self.mxSession.myUserId?.components(separatedBy: ":")
|
||||
{
|
||||
if myUserIDComponents.count == 2 {
|
||||
serverACL = myUserIDComponents[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
return createServerACLContent(serverACL: serverACL)
|
||||
}
|
||||
|
||||
// Create map for content json with serverACL string
|
||||
func createServerACLContent(serverACL: String) -> [String:Any] {
|
||||
var content: [String:Any] = [String:Any]()
|
||||
var serverACLList: [String] = [String]()
|
||||
serverACLList.append(serverACL)
|
||||
content.updateValue(serverACLList, forKey: "allow")
|
||||
content.updateValue(false, forKey: "allow_ip_literals")
|
||||
|
||||
return content
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -161,21 +161,7 @@ struct RoomFederationDecisionView: View {
|
||||
|
||||
|
||||
func setServerACL(isFederated: Bool) {
|
||||
var serverACL: [String] = [String]()
|
||||
if isFederated {
|
||||
serverACL.append("*")
|
||||
} else {
|
||||
if let myUserIDComponents = room.mxSession.myUserId?.components(separatedBy: ":")
|
||||
{
|
||||
if myUserIDComponents.count == 2 {
|
||||
serverACL.append(myUserIDComponents[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var content: [String:Any] = [String:Any]()
|
||||
content.updateValue(serverACL, forKey: "allow")
|
||||
content.updateValue(false, forKey: "allowIPLiterals")
|
||||
let content: [String:Any] = room.createServerACL(isFederated: isFederated)
|
||||
isUpdatingServerACLs = true
|
||||
pendingRequest = room.sendStateEvent(MXEventType.roomServerACL, content: content, stateKey: "") { response in
|
||||
isUpdatingServerACLs = false
|
||||
|
||||
Reference in New Issue
Block a user