From 624edfb413093c836d2959d240a17aa356f64b8b Mon Sep 17 00:00:00 2001 From: JanNiklas Grabowski Date: Mon, 18 Sep 2023 14:37:34 +0200 Subject: [PATCH 1/2] MESSENGER-4751 use privacy url of well known --- Config/BWIBuildSettings.swift | 1 - .../AllChats/AllChatsViewController.swift | 12 +++++- .../Modules/Settings/SettingsViewController.m | 4 +- Riot/Modules/TabBar/MasterTabBarController.m | 6 ++- .../Login/AuthenticationLoginModels.swift | 7 +--- .../View/AuthenticationLoginScreen.swift | 39 ++++++++++++------- 6 files changed, 42 insertions(+), 27 deletions(-) diff --git a/Config/BWIBuildSettings.swift b/Config/BWIBuildSettings.swift index cf7afe206..cdaa252e3 100644 --- a/Config/BWIBuildSettings.swift +++ b/Config/BWIBuildSettings.swift @@ -266,7 +266,6 @@ class BWIBuildSettings: NSObject { // Note: Set empty strings to hide the related entry in application settings var applicationCopyrightUrlString = "https://messenger.bwi.de/copyright" - var applicationPrivacyPolicyUrlString = "https://messenger.bwi.de/datenschutz" var applicationTermsConditionsUrlString = "" var applicationPrivacyPolicyWithMatomoSectionUrlString = "https://messenger.bwi.de/datenschutz#c6637" diff --git a/Riot/Modules/Home/AllChats/AllChatsViewController.swift b/Riot/Modules/Home/AllChats/AllChatsViewController.swift index e74cd8e65..d0ab60b04 100644 --- a/Riot/Modules/Home/AllChats/AllChatsViewController.swift +++ b/Riot/Modules/Home/AllChats/AllChatsViewController.swift @@ -455,8 +455,16 @@ class AllChatsViewController: HomeViewController { alert.addAction(UIAlertAction(title: BWIL10n.bwiAnalyticsAlertInfoButton, style: .default, handler: { [self] action in - if let url = URL(string: BWIBuildSettings.shared.applicationPrivacyPolicyWithMatomoSectionUrlString) { - UIApplication.shared.open(url) + if let defaultURL = URL(string: BWIBuildSettings.shared.applicationPrivacyPolicyWithMatomoSectionUrlString) { + guard let wellKnownDataPrivacyURL = URL(string: self.mainSession.homeserverWellknown.dataPrivacyURL() ?? ""), let defaultHost = defaultURL.host else { + UIApplication.shared.open(defaultURL) + return + } + if !wellKnownDataPrivacyURL.absoluteString.contains(defaultHost) { + UIApplication.shared.open(wellKnownDataPrivacyURL) + } else { + UIApplication.shared.open(defaultURL) + } } showMatomoConsentAlertOnCloseModal = true })) diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index e16daa0a5..049844414 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -759,7 +759,7 @@ ChangePasswordCoordinatorBridgePresenterDelegate> { [sectionAbout addRowWithTag:ABOUT_ACCEPTABLE_USE_INDEX]; } - if (BWIBuildSettings.shared.applicationPrivacyPolicyUrlString.length) + if (self.mainSession.homeserverWellknown.dataPrivacyURL != nil) { [sectionAbout addRowWithTag:ABOUT_PRIVACY_INDEX]; } @@ -3415,7 +3415,7 @@ ChangePasswordCoordinatorBridgePresenterDelegate> } else if (row == ABOUT_PRIVACY_INDEX) { - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:BWIBuildSettings.shared.applicationPrivacyPolicyUrlString] options:@{} completionHandler:nil]; + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.mainSession.homeserverWellknown.dataPrivacyURL] options:@{} completionHandler:nil]; } else if (row == ABOUT_ACCESSIBILITY_DECLARATION_INDEX) { diff --git a/Riot/Modules/TabBar/MasterTabBarController.m b/Riot/Modules/TabBar/MasterTabBarController.m index 22614bf80..220d62bf9 100644 --- a/Riot/Modules/TabBar/MasterTabBarController.m +++ b/Riot/Modules/TabBar/MasterTabBarController.m @@ -1089,8 +1089,10 @@ message:[BWIL10n bwiAnalyticsAlertBody:AppInfo.current.displayName] preferredStyle:UIAlertControllerStyleAlert]; - [alert addAction:[UIAlertAction actionWithTitle:BWIL10n.bwiAnalyticsAlertInfoButton style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:BWIBuildSettings.shared.applicationPrivacyPolicyUrlString] options:@{} completionHandler:nil]; + [alert addAction:[UIAlertAction actionWithTitle:BWIL10n.bwiAnalyticsAlertInfoButton style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + if (self->mxSessionArray.firstObject.homeserverWellknown.dataPrivacyURL != nil) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self->mxSessionArray.firstObject.homeserverWellknown.dataPrivacyURL] options:@{} completionHandler:nil]; + } }]]; [alert addAction:[UIAlertAction actionWithTitle:BWIL10n.bwiAnalyticsAlertCancelButton style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { BWIAnalytics.sharedTracker.running = NO; diff --git a/RiotSwiftUI/Modules/Authentication/Login/AuthenticationLoginModels.swift b/RiotSwiftUI/Modules/Authentication/Login/AuthenticationLoginModels.swift index 356bd5fd3..e3cd5b4a6 100644 --- a/RiotSwiftUI/Modules/Authentication/Login/AuthenticationLoginModels.swift +++ b/RiotSwiftUI/Modules/Authentication/Login/AuthenticationLoginModels.swift @@ -88,11 +88,8 @@ struct AuthenticationLoginViewState: BindableState { hasValidCredentials && !isLoading } - var dataPrivacyString: String { - guard let urlString = AuthenticationService.shared.wellknown?.dataPrivacyURL() else { - return BWIBuildSettings.shared.applicationPrivacyPolicyUrlString - } - return urlString + var dataPrivacyString: String? { + return AuthenticationService.shared.wellknown?.dataPrivacyURL() } } diff --git a/RiotSwiftUI/Modules/Authentication/Login/View/AuthenticationLoginScreen.swift b/RiotSwiftUI/Modules/Authentication/Login/View/AuthenticationLoginScreen.swift index 60e1b2d35..fead5cd83 100644 --- a/RiotSwiftUI/Modules/Authentication/Login/View/AuthenticationLoginScreen.swift +++ b/RiotSwiftUI/Modules/Authentication/Login/View/AuthenticationLoginScreen.swift @@ -209,22 +209,31 @@ struct AuthenticationLoginScreen: View { } var dataPrivacyForm: some View { - Button(action: { - let tosURL = URL.init(string: viewModel.viewState.dataPrivacyString)! // add your link here - if UIApplication.shared.canOpenURL(tosURL) { - UIApplication.shared.open(tosURL) + VStack() { + if viewModel.viewState.dataPrivacyString != nil { + Button(action: { + guard let urlString = viewModel.viewState.dataPrivacyString else { + return + } + let tosURL = URL.init(string: urlString)! // add your link here + if UIApplication.shared.canOpenURL(tosURL) { + UIApplication.shared.open(tosURL) + } + }, label: { + Text(BWIL10n.authenticationDataprivacyText) + .font(theme.fonts.footnote) + .foregroundColor(theme.colors.primaryContent) + + + Text(BWIL10n.authenticationDataprivacyLink) + .font(theme.fonts.footnote) + .foregroundColor(.blue) + .underline() + }) + .padding([.horizontal], 20) + } else { + EmptyView() } - }, label: { - Text(BWIL10n.authenticationDataprivacyText) - .font(theme.fonts.footnote) - .foregroundColor(theme.colors.primaryContent) - + - Text(BWIL10n.authenticationDataprivacyLink) - .font(theme.fonts.footnote) - .foregroundColor(.blue) - .underline() - }) - .padding([.horizontal], 20) + } } var loginDescription: some View { From 35c7ebade7fdf0dc549743a5a7ee7ec6124b75f6 Mon Sep 17 00:00:00 2001 From: JanNiklas Grabowski Date: Mon, 18 Sep 2023 17:54:49 +0200 Subject: [PATCH 2/2] MESSENGER-4751 add feature flag --- Config/BWIBuildSettings.swift | 4 ++++ Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift | 1 + Config/BuM/BWIBuildSettings+BuM.swift | 1 + .../Home/AllChats/AllChatsViewController.swift | 16 ++++++++++------ Riot/Modules/Settings/SettingsViewController.m | 15 +++++++++++++-- Riot/Modules/TabBar/MasterTabBarController.m | 8 ++++++-- .../Login/AuthenticationLoginModels.swift | 6 +++++- 7 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Config/BWIBuildSettings.swift b/Config/BWIBuildSettings.swift index cdaa252e3..13fcd2a60 100644 --- a/Config/BWIBuildSettings.swift +++ b/Config/BWIBuildSettings.swift @@ -266,9 +266,13 @@ class BWIBuildSettings: NSObject { // Note: Set empty strings to hide the related entry in application settings var applicationCopyrightUrlString = "https://messenger.bwi.de/copyright" + var applicationPrivacyPolicyUrlString = "https://messenger.bwi.de/datenschutz" var applicationTermsConditionsUrlString = "" var applicationPrivacyPolicyWithMatomoSectionUrlString = "https://messenger.bwi.de/datenschutz#c6637" + // (#4751) use privacy policy link of well known + var bwiUseWellKnownPrivacyPolicyLink: Bool = false + // MARk: - Matrix permalinks // Paths for URLs that will considered as Matrix permalinks. Those permalinks are opened within the app var permalinkSupportedHosts: [String: [String]] = [:] diff --git a/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift b/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift index 24791e993..6cc9f294a 100644 --- a/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift +++ b/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift @@ -38,6 +38,7 @@ extension BWIBuildSettings { showMaintenanceInfoMessageType = true ignoreBlockingMaintenance = true enableAllChatsToolbar = false + bwiUseWellKnownPrivacyPolicyLink = true itunesAppLink = "itms://itunes.apple.com/app/bundesmessenger-beta/id1617068656?mt=8" } diff --git a/Config/BuM/BWIBuildSettings+BuM.swift b/Config/BuM/BWIBuildSettings+BuM.swift index 1605a0865..90a587b43 100644 --- a/Config/BuM/BWIBuildSettings+BuM.swift +++ b/Config/BuM/BWIBuildSettings+BuM.swift @@ -27,6 +27,7 @@ extension BWIBuildSettings { authScreenShowTestServerOptions = false bwiNotificationTimes = true enableNewSessionManagerByDefault = true + bwiUseWellKnownPrivacyPolicyLink = true itunesAppLink = "itms://itunes.apple.com/app/bundesmessenger/id1616866351?mt=8" } diff --git a/Riot/Modules/Home/AllChats/AllChatsViewController.swift b/Riot/Modules/Home/AllChats/AllChatsViewController.swift index d0ab60b04..94476c631 100644 --- a/Riot/Modules/Home/AllChats/AllChatsViewController.swift +++ b/Riot/Modules/Home/AllChats/AllChatsViewController.swift @@ -456,12 +456,16 @@ class AllChatsViewController: HomeViewController { style: .default, handler: { [self] action in if let defaultURL = URL(string: BWIBuildSettings.shared.applicationPrivacyPolicyWithMatomoSectionUrlString) { - guard let wellKnownDataPrivacyURL = URL(string: self.mainSession.homeserverWellknown.dataPrivacyURL() ?? ""), let defaultHost = defaultURL.host else { - UIApplication.shared.open(defaultURL) - return - } - if !wellKnownDataPrivacyURL.absoluteString.contains(defaultHost) { - UIApplication.shared.open(wellKnownDataPrivacyURL) + if BWIBuildSettings.shared.bwiUseWellKnownPrivacyPolicyLink { + guard let wellKnownDataPrivacyURL = URL(string: self.mainSession.homeserverWellknown.dataPrivacyURL() ?? ""), let defaultHost = defaultURL.host else { + UIApplication.shared.open(defaultURL) + return + } + if !wellKnownDataPrivacyURL.absoluteString.contains(defaultHost) { + UIApplication.shared.open(wellKnownDataPrivacyURL) + } else { + UIApplication.shared.open(defaultURL) + } } else { UIApplication.shared.open(defaultURL) } diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 049844414..66f8afe94 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -759,7 +759,11 @@ ChangePasswordCoordinatorBridgePresenterDelegate> { [sectionAbout addRowWithTag:ABOUT_ACCEPTABLE_USE_INDEX]; } - if (self.mainSession.homeserverWellknown.dataPrivacyURL != nil) + if (self.mainSession.homeserverWellknown.dataPrivacyURL != nil && BWIBuildSettings.shared.bwiUseWellKnownPrivacyPolicyLink) + { + [sectionAbout addRowWithTag:ABOUT_PRIVACY_INDEX]; + } + else if (BWIBuildSettings.shared.applicationPrivacyPolicyUrlString.length && !BWIBuildSettings.shared.bwiUseWellKnownPrivacyPolicyLink) { [sectionAbout addRowWithTag:ABOUT_PRIVACY_INDEX]; } @@ -3415,7 +3419,14 @@ ChangePasswordCoordinatorBridgePresenterDelegate> } else if (row == ABOUT_PRIVACY_INDEX) { - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.mainSession.homeserverWellknown.dataPrivacyURL] options:@{} completionHandler:nil]; + if (BWIBuildSettings.shared.bwiUseWellKnownPrivacyPolicyLink) + { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.mainSession.homeserverWellknown.dataPrivacyURL] options:@{} completionHandler:nil]; + } + else + { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:BWIBuildSettings.shared.applicationPrivacyPolicyUrlString] options:@{} completionHandler:nil]; + } } else if (row == ABOUT_ACCESSIBILITY_DECLARATION_INDEX) { diff --git a/Riot/Modules/TabBar/MasterTabBarController.m b/Riot/Modules/TabBar/MasterTabBarController.m index 220d62bf9..72cb22927 100644 --- a/Riot/Modules/TabBar/MasterTabBarController.m +++ b/Riot/Modules/TabBar/MasterTabBarController.m @@ -1090,8 +1090,12 @@ preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:BWIL10n.bwiAnalyticsAlertInfoButton style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { - if (self->mxSessionArray.firstObject.homeserverWellknown.dataPrivacyURL != nil) { - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self->mxSessionArray.firstObject.homeserverWellknown.dataPrivacyURL] options:@{} completionHandler:nil]; + if (BWIBuildSettings.shared.bwiUseWellKnownPrivacyPolicyLink) { + if (self->mxSessionArray.firstObject.homeserverWellknown.dataPrivacyURL != nil) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self->mxSessionArray.firstObject.homeserverWellknown.dataPrivacyURL] options:@{} completionHandler:nil]; + } + } else { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:BWIBuildSettings.shared.applicationPrivacyPolicyUrlString] options:@{} completionHandler:nil]; } }]]; [alert addAction:[UIAlertAction actionWithTitle:BWIL10n.bwiAnalyticsAlertCancelButton style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { diff --git a/RiotSwiftUI/Modules/Authentication/Login/AuthenticationLoginModels.swift b/RiotSwiftUI/Modules/Authentication/Login/AuthenticationLoginModels.swift index e3cd5b4a6..2c3699a97 100644 --- a/RiotSwiftUI/Modules/Authentication/Login/AuthenticationLoginModels.swift +++ b/RiotSwiftUI/Modules/Authentication/Login/AuthenticationLoginModels.swift @@ -89,7 +89,11 @@ struct AuthenticationLoginViewState: BindableState { } var dataPrivacyString: String? { - return AuthenticationService.shared.wellknown?.dataPrivacyURL() + if BWIBuildSettings.shared.bwiUseWellKnownPrivacyPolicyLink { + return AuthenticationService.shared.wellknown?.dataPrivacyURL() + } else { + return BWIBuildSettings.shared.applicationPrivacyPolicyUrlString + } } }