Skip to content

Commit

Permalink
Merge pull request #949 from tchapgouv/948-setup-feature-flag-per-ins…
Browse files Browse the repository at this point in the history
…tance

Setup feature activation by instance for Tchap
  • Loading branch information
NicolasBuquet authored Jan 8, 2024
2 parents 38b7856 + b75012b commit 81be1c7
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Btchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 : [ <instance> ] to allow any feature for an instance
// "<feature ID>" : [ 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
Expand Down
12 changes: 12 additions & 0 deletions DevTchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 : [ <instance> ] to allow any feature for an instance
// "<feature ID>" : [ 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
Expand Down
4 changes: 2 additions & 2 deletions Riot/Modules/Settings/SettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
14 changes: 14 additions & 0 deletions RiotNSE/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 : [ <instance> ] to allow any feature for an instance
// "<feature ID>" : [ 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
Expand Down
14 changes: 14 additions & 0 deletions RiotShareExtension/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 : [ <instance> ] to allow any feature for an instance
// "<feature ID>" : [ 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
Expand Down
14 changes: 14 additions & 0 deletions Tchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 : [ <instance> ] to allow any feature for an instance
// "<feature ID>" : [ 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
Expand Down
38 changes: 38 additions & 0 deletions Tchap/Extensions/Account+Tchap.swift
Original file line number Diff line number Diff line change
@@ -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)
}
}
1 change: 1 addition & 0 deletions changelog.d/948.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Autoriser l'activation de nouvelles fonctionnalités par instance de serveur

0 comments on commit 81be1c7

Please sign in to comment.