diff --git a/Btchap/Config/BuildSettings.swift b/Btchap/Config/BuildSettings.swift index 485c89ebcf..eb0223e148 100644 --- a/Btchap/Config/BuildSettings.swift +++ b/Btchap/Config/BuildSettings.swift @@ -229,6 +229,18 @@ final class BuildSettings: NSObject { static let allowBackgroundAudioMessagePlayback: Bool = true + // Tchap: Feature activation by Instance + static let tchapFeatureAnyFeature = "*" // To allow any feature for some instances + static let tchapFeatureAnyHomeServer = "*" // To allow a feature for any instance + // tchapFeatureAnyFeature : [ ] to allow any feature for an instance + // "" : [ tchapFeatureAnyHomeServer ] to allow a feature to any instance + static let tchapFeatureNotificationByEmail = "tchapFeatureNotificationByEmail" + static let tchapFeatureVoiceOverIP = "tchapFeatureVoiceOverIP" + static let tchapFeatureVideoOverIP = "tchapFeatureVideoOverIP" // Tchap: in pre-prod, allow any feature to any instance. + static var tchapFeatureByHomeServer: [String: [String]] = [ + tchapFeatureAnyFeature: [ tchapFeatureAnyHomeServer ] + ] + // MARK: - Side Menu static let enableSideMenu: Bool = true && !newAppLayoutEnabled static let sideMenuShowInviteFriends: Bool = true diff --git a/DevTchap/Config/BuildSettings.swift b/DevTchap/Config/BuildSettings.swift index a311ac487d..7e040064b5 100644 --- a/DevTchap/Config/BuildSettings.swift +++ b/DevTchap/Config/BuildSettings.swift @@ -230,6 +230,18 @@ final class BuildSettings: NSObject { static let allowBackgroundAudioMessagePlayback: Bool = true + // Tchap: Feature activation by Instance + static let tchapFeatureAnyFeature = "*" // To allow any feature for some instances + static let tchapFeatureAnyHomeServer = "*" // To allow a feature for any instance + // tchapFeatureAnyFeature : [ ] to allow any feature for an instance + // "" : [ tchapFeatureAnyHomeServer ] to allow a feature to any instance + static let tchapFeatureNotificationByEmail = "tchapFeatureNotificationByEmail" + static let tchapFeatureVoiceOverIP = "tchapFeatureVoiceOverIP" + static let tchapFeatureVideoOverIP = "tchapFeatureVideoOverIP" // Tchap: in Dev, allow any feature to any instance. + static var tchapFeatureByHomeServer: [String: [String]] = [ + tchapFeatureAnyFeature: [ tchapFeatureAnyHomeServer ] + ] + // MARK: - Side Menu static let enableSideMenu: Bool = true && !newAppLayoutEnabled static let sideMenuShowInviteFriends: Bool = true diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 114d996438..e76ab67acb 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -492,8 +492,8 @@ - (void)updateSections [sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_SHOW_DECODED_CONTENT]; } - // Tchap: allow enabling email notifications only for DINUM homeserver - if ([account.identityServerURL isEqualToString:[BuildSettings.serverUrlPrefix stringByAppendingString:@"agent.dinum.tchap.gouv.fr"]]) { + // Tchap: allow enabling email notifications only for allowed instances + if ([account isFeatureActivated:BuildSettings.tchapFeatureNotificationByEmail]) { [sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_ENABLE_BY_EMAIL_INDEX]; } [sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_PIN_MISSED_NOTIFICATIONS_INDEX]; diff --git a/RiotNSE/BuildSettings.swift b/RiotNSE/BuildSettings.swift index dfeaa5da35..319f939bce 100644 --- a/RiotNSE/BuildSettings.swift +++ b/RiotNSE/BuildSettings.swift @@ -259,6 +259,20 @@ final class BuildSettings: NSObject { static let allowBackgroundAudioMessagePlayback: Bool = true + // Tchap: Feature activation by Instance + static let tchapFeatureAnyFeature = "*" // To allow any feature for some instances + static let tchapFeatureAnyHomeServer = "*" // To allow a feature for any instance + // tchapFeatureAnyFeature : [ ] to allow any feature for an instance + // "" : [ tchapFeatureAnyHomeServer ] to allow a feature to any instance + static let tchapFeatureNotificationByEmail = "tchapFeatureNotificationByEmail" + static let tchapFeatureVoiceOverIP = "tchapFeatureVoiceOverIP" + static let tchapFeatureVideoOverIP = "tchapFeatureVideoOverIP" + static var tchapFeatureByHomeServer: [String: [String]] = [ + tchapFeatureNotificationByEmail: [ + "agent.dinum.tchap.gouv.fr" + ] + ] + // MARK: - Side Menu static let enableSideMenu: Bool = true && !newAppLayoutEnabled static let sideMenuShowInviteFriends: Bool = true diff --git a/RiotShareExtension/BuildSettings.swift b/RiotShareExtension/BuildSettings.swift index dfeaa5da35..319f939bce 100644 --- a/RiotShareExtension/BuildSettings.swift +++ b/RiotShareExtension/BuildSettings.swift @@ -259,6 +259,20 @@ final class BuildSettings: NSObject { static let allowBackgroundAudioMessagePlayback: Bool = true + // Tchap: Feature activation by Instance + static let tchapFeatureAnyFeature = "*" // To allow any feature for some instances + static let tchapFeatureAnyHomeServer = "*" // To allow a feature for any instance + // tchapFeatureAnyFeature : [ ] to allow any feature for an instance + // "" : [ tchapFeatureAnyHomeServer ] to allow a feature to any instance + static let tchapFeatureNotificationByEmail = "tchapFeatureNotificationByEmail" + static let tchapFeatureVoiceOverIP = "tchapFeatureVoiceOverIP" + static let tchapFeatureVideoOverIP = "tchapFeatureVideoOverIP" + static var tchapFeatureByHomeServer: [String: [String]] = [ + tchapFeatureNotificationByEmail: [ + "agent.dinum.tchap.gouv.fr" + ] + ] + // MARK: - Side Menu static let enableSideMenu: Bool = true && !newAppLayoutEnabled static let sideMenuShowInviteFriends: Bool = true diff --git a/Tchap/Config/BuildSettings.swift b/Tchap/Config/BuildSettings.swift index dfeaa5da35..319f939bce 100644 --- a/Tchap/Config/BuildSettings.swift +++ b/Tchap/Config/BuildSettings.swift @@ -259,6 +259,20 @@ final class BuildSettings: NSObject { static let allowBackgroundAudioMessagePlayback: Bool = true + // Tchap: Feature activation by Instance + static let tchapFeatureAnyFeature = "*" // To allow any feature for some instances + static let tchapFeatureAnyHomeServer = "*" // To allow a feature for any instance + // tchapFeatureAnyFeature : [ ] to allow any feature for an instance + // "" : [ tchapFeatureAnyHomeServer ] to allow a feature to any instance + static let tchapFeatureNotificationByEmail = "tchapFeatureNotificationByEmail" + static let tchapFeatureVoiceOverIP = "tchapFeatureVoiceOverIP" + static let tchapFeatureVideoOverIP = "tchapFeatureVideoOverIP" + static var tchapFeatureByHomeServer: [String: [String]] = [ + tchapFeatureNotificationByEmail: [ + "agent.dinum.tchap.gouv.fr" + ] + ] + // MARK: - Side Menu static let enableSideMenu: Bool = true && !newAppLayoutEnabled static let sideMenuShowInviteFriends: Bool = true diff --git a/Tchap/Extensions/Account+Tchap.swift b/Tchap/Extensions/Account+Tchap.swift new file mode 100644 index 0000000000..9223e9cd33 --- /dev/null +++ b/Tchap/Extensions/Account+Tchap.swift @@ -0,0 +1,38 @@ +// +// Copyright 2024 New Vector Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import Foundation + +@objc extension MXKAccount { + + func isFeatureActivated(_ featureId: String) -> Bool { + guard let targetedFeature = BuildSettings.tchapFeatureByHomeServer[featureId] ?? BuildSettings.tchapFeatureByHomeServer[BuildSettings.tchapFeatureAnyFeature] else { + return false + } + + if targetedFeature.contains(BuildSettings.tchapFeatureAnyHomeServer) { + return true + } + + guard let homeServerURL = self.mxCredentials.homeServer else { + return false + } + + let homeServerDomain = homeServerURL.replacingOccurrences(of: BuildSettings.serverUrlPrefix, with: "") + + return targetedFeature.contains(homeServerDomain) + } +} diff --git a/changelog.d/948.change b/changelog.d/948.change new file mode 100644 index 0000000000..4fb87f7822 --- /dev/null +++ b/changelog.d/948.change @@ -0,0 +1 @@ +Autoriser l'activation de nouvelles fonctionnalités par instance de serveur \ No newline at end of file