Feature/2897 restricted user

This commit is contained in:
Frank Rotermund
2022-03-22 14:37:58 +00:00
committed by Arnfried Griesert
parent 472dbded4e
commit 4b1ca0ff7f
16 changed files with 183 additions and 16 deletions
@@ -51,6 +51,16 @@ struct DeveloperSettingsView: View {
.alert(isPresented: $showAlert) {
Alert(title: Text(NSLocalizedString("bwi_settings_developer", tableName: "Vector", comment: "")), message: Text(NSLocalizedString("bwi_settings_developer_show_matomo_privacy_notes_resetted", tableName: "Vector", comment: "")), dismissButton: .default(Text("Ok")))
}
Button(action: { _ = restrictUser(mxSession: session) }) {
Text(NSLocalizedString("bwi_settings_developer_restrict_user", tableName: "Bwi", comment: ""))
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
}
Button(action: { _ = unrestrictUser(mxSession: session) }) {
Text(NSLocalizedString("bwi_settings_developer_unrestrict_user", tableName: "Bwi", comment: ""))
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
}
}
.navigationTitle(NSLocalizedString("bwi_settings_developer", tableName: "Vector", comment: ""))
.navigationBarTitleDisplayMode(.inline)
@@ -82,3 +92,20 @@ fileprivate func resetMatomoInfoScreen() -> Bool {
UserDefaults.standard.set(false, forKey: "bwi_matomo_info_screen_shown")
return true
}
fileprivate func restrictUser(mxSession: MXSession?) -> Bool {
guard let mxSession = mxSession else {
return false
}
AccountRestrictionService(mxSession: mxSession).updateRestriction(roomAccess: true, addressListAccess: true)
return true
}
fileprivate func unrestrictUser(mxSession: MXSession?) -> Bool {
guard let mxSession = mxSession else {
return false
}
AccountRestrictionService(mxSession: mxSession).updateRestriction(roomAccess: false, addressListAccess: false)
return true
}