Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new account property scopes #1190

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion NextcloudTalk/NCDatabaseManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

NSString *const kTalkDatabaseFolder = @"Library/Application Support/Talk";
NSString *const kTalkDatabaseFileName = @"talk.realm";
uint64_t const kTalkDatabaseSchemaVersion = 47;
uint64_t const kTalkDatabaseSchemaVersion = 48;

NSString * const kCapabilitySystemMessages = @"system-messages";
NSString * const kCapabilityNotificationLevels = @"notification-levels";
Expand Down Expand Up @@ -374,6 +374,8 @@ - (void)setServerCapabilities:(NSDictionary *)serverCapabilities forAccountId:(N
capabilities.readStatusPrivacy = [[[[talkCaps objectForKey:@"config"] objectForKey:@"chat"] objectForKey:@"read-privacy"] boolValue];
capabilities.accountPropertyScopesVersion2 = [[provisioningAPICaps objectForKey:@"AccountPropertyScopesVersion"] integerValue] == 2;
capabilities.accountPropertyScopesFederationEnabled = [[provisioningAPICaps objectForKey:@"AccountPropertyScopesFederationEnabled"] boolValue];
capabilities.accountPropertyScopesFederatedEnabled = [[provisioningAPICaps objectForKey:@"AccountPropertyScopesFederatedEnabled"] boolValue];
capabilities.accountPropertyScopesPublishedEnabled = [[provisioningAPICaps objectForKey:@"AccountPropertyScopesPublishedEnabled"] boolValue];
capabilities.talkVersion = [talkCaps objectForKey:@"version"];
capabilities.guestsAppEnabled = [[guestsCaps objectForKey:@"enabled"] boolValue];
capabilities.referenceApiSupported = [[coreCaps objectForKey:@"reference-api"] boolValue];
Expand Down
2 changes: 2 additions & 0 deletions NextcloudTalk/ServerCapabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ NS_ASSUME_NONNULL_BEGIN
@property BOOL readStatusPrivacy;
@property BOOL accountPropertyScopesVersion2;
@property BOOL accountPropertyScopesFederationEnabled;
@property BOOL accountPropertyScopesFederatedEnabled;
@property BOOL accountPropertyScopesPublishedEnabled;
@property BOOL callEnabled;
@property NSString *talkVersion;
@property NSString *externalSignalingServerVersion;
Expand Down
7 changes: 7 additions & 0 deletions NextcloudTalk/UserProfileTableViewController+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,17 @@ extension UserProfileTableViewController {
options.append(localOption)

let serverCapabilities = NCDatabaseManager.sharedInstance().serverCapabilities(forAccountId: account.accountId)
// Legacy capability
if serverCapabilities.accountPropertyScopesFederationEnabled {
options.append(federatedOption)
options.append(publishedOption)
}
if serverCapabilities.accountPropertyScopesFederatedEnabled {
options.append(federatedOption)
}
if serverCapabilities.accountPropertyScopesPublishedEnabled {
options.append(publishedOption)
}

let optionSelectorVC = DetailedOptionsSelectorTableViewController(options: options, forSenderIdentifier: field, andStyle: .insetGrouped)
if let optionSelectorVC = optionSelectorVC {
Expand Down
3 changes: 2 additions & 1 deletion NextcloudTalk/UserProfileTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ extension UserProfileTableViewController {
var headerView = HeaderWithButton()
headerView.button.addTarget(self, action: #selector(showScopeSelectionDialog(_:)), for: .touchUpInside)
let serverCapabilities = NCDatabaseManager.sharedInstance().serverCapabilities(forAccountId: account.accountId)
let shouldEnableNameAndEmailScopeButton = serverCapabilities.accountPropertyScopesFederationEnabled
let shouldEnableNameAndEmailScopeButton = serverCapabilities.accountPropertyScopesFederationEnabled ||
serverCapabilities.accountPropertyScopesFederatedEnabled || serverCapabilities.accountPropertyScopesPublishedEnabled

switch profileSection {
case ProfileSection.kProfileSectionName.rawValue:
Expand Down