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

Setup feature activation by instance for Tchap #949

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
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 tchapFeatureAnyInstance = "*" // To allow a feature for any instance
// tchapFeatureAnyFeature : [ <instance> ] to allow any feature for an instance
// "<feature ID>" : [ tchapFeatureAnyInstance ] 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 tchapFeatureByInstance: [String: [String]] = [
tchapFeatureAnyFeature: [ tchapFeatureAnyInstance ]
]

// 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 tchapFeatureAnyInstance = "*" // To allow a feature for any instance
// tchapFeatureAnyFeature : [ <instance> ] to allow any feature for an instance
// "<feature ID>" : [ tchapFeatureAnyInstance ] 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 tchapFeatureByInstance: [String: [String]] = [
tchapFeatureAnyFeature: [ tchapFeatureAnyInstance ]
]

// 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 tchapFeatureAnyInstance = "*" // To allow a feature for any instance
// tchapFeatureAnyFeature : [ <instance> ] to allow any feature for an instance
// "<feature ID>" : [ tchapFeatureAnyInstance ] to allow a feature to any instance
static let tchapFeatureNotificationByEmail = "tchapFeatureNotificationByEmail"
static let tchapFeatureVoiceOverIP = "tchapFeatureVoiceOverIP"
static let tchapFeatureVideoOverIP = "tchapFeatureVideoOverIP"
static var tchapFeatureByInstance: [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 tchapFeatureAnyInstance = "*" // To allow a feature for any instance
// tchapFeatureAnyFeature : [ <instance> ] to allow any feature for an instance
// "<feature ID>" : [ tchapFeatureAnyInstance ] to allow a feature to any instance
static let tchapFeatureNotificationByEmail = "tchapFeatureNotificationByEmail"
static let tchapFeatureVoiceOverIP = "tchapFeatureVoiceOverIP"
static let tchapFeatureVideoOverIP = "tchapFeatureVideoOverIP"
static var tchapFeatureByInstance: [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 tchapFeatureAnyInstance = "*" // To allow a feature for any instance
// tchapFeatureAnyFeature : [ <instance> ] to allow any feature for an instance
// "<feature ID>" : [ tchapFeatureAnyInstance ] to allow a feature to any instance
static let tchapFeatureNotificationByEmail = "tchapFeatureNotificationByEmail"
static let tchapFeatureVoiceOverIP = "tchapFeatureVoiceOverIP"
static let tchapFeatureVideoOverIP = "tchapFeatureVideoOverIP"
static var tchapFeatureByInstance: [String: [String]] = [
tchapFeatureNotificationByEmail: [
"agent.dinum.tchap.gouv.fr"
]
]

// MARK: - Side Menu
static let enableSideMenu: Bool = true && !newAppLayoutEnabled
static let sideMenuShowInviteFriends: Bool = true
Expand Down
28 changes: 28 additions & 0 deletions Tchap/Extensions/Account+Tchap.swift
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

la gestion des features ne devrait pas dépendre de Account. Dans une classe d'utilitaire si il y'en a une ou dans BuildSetting ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Les features sont basées sur le homeServer qui est stocké dans les credentials de l'Account.

Je pense que c'est le bon endroit.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// 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.tchapFeatureByInstance[featureId] ?? BuildSettings.tchapFeatureByInstance[BuildSettings.tchapFeatureAnyFeature] else {
return false
}

return targetedFeature.contains(BuildSettings.tchapFeatureAnyInstance) || targetedFeature.contains(self.identityServerURL.replacingOccurrences(of: BuildSettings.serverUrlPrefix, with: ""))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on devrait utiliser le homeserver url au lieu de l'IS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}
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
Loading