Skip to content

Commit

Permalink
Add support for idealEnabledRegions remote config
Browse files Browse the repository at this point in the history
  • Loading branch information
pete-signal authored Jan 10, 2024
1 parent efae48e commit bc33958
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
12 changes: 10 additions & 2 deletions SignalMessaging/Subscriptions/DonationUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,18 @@ public class DonationUtilities: Dependencies {
}()

let isIDEALAvailable = {
guard FeatureFlags.allowIDEALDonations else { return false }
// TODO[IDEAL]: Remove the "allow internal" check before release
guard
FeatureFlags.allowInternalIDEALDonations ||
RemoteConfig.idealEnabledRegions.contains(e164: localNumber)
else {
return false
}

switch donationMode {
case .oneTime, .monthly:
return true
// TODO[IDEAL]: Remove feature flag before release
return FeatureFlags.allowIDEALDonations
case .gift:
return false
}
Expand Down
3 changes: 2 additions & 1 deletion SignalServiceKit/src/Util/FeatureFlags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public class FeatureFlags: BaseFlags {

public static let groupCallDisposition = build.includes(.internal)

public static let allowIDEALDonations = build.includes(.dev)
public static let allowIDEALDonations = build.includes(.beta)
public static let allowInternalIDEALDonations = build.includes(.internal)

public static let shouldShowCallsTab = false

Expand Down
10 changes: 10 additions & 0 deletions SignalServiceKit/src/Util/RemoteConfigManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class RemoteConfig: BaseFlags {
private let creditAndDebitCardDisabledRegions: PhoneNumberRegions
private let paypalDisabledRegions: PhoneNumberRegions
private let sepaEnabledRegions: PhoneNumberRegions
private let idealEnabledRegions: PhoneNumberRegions

init(
clockSkew: TimeInterval,
Expand All @@ -44,6 +45,7 @@ public class RemoteConfig: BaseFlags {
self.creditAndDebitCardDisabledRegions = Self.parsePhoneNumberRegions(valueFlags: valueFlags, flag: .creditAndDebitCardDisabledRegions)
self.paypalDisabledRegions = Self.parsePhoneNumberRegions(valueFlags: valueFlags, flag: .paypalDisabledRegions)
self.sepaEnabledRegions = Self.parsePhoneNumberRegions(valueFlags: valueFlags, flag: .sepaEnabledRegions)
self.idealEnabledRegions = Self.parsePhoneNumberRegions(valueFlags: valueFlags, flag: .idealEnabledRegions)
}

fileprivate static var emptyConfig: RemoteConfig {
Expand Down Expand Up @@ -138,6 +140,11 @@ public class RemoteConfig: BaseFlags {
return remoteConfig.sepaEnabledRegions
}

public static var idealEnabledRegions: PhoneNumberRegions {
guard let remoteConfig = Self.remoteConfigManager.cachedConfig else { return [] }
return remoteConfig.idealEnabledRegions
}

public static var canDonateOneTimeWithApplePay: Bool {
!isEnabled(.applePayOneTimeDonationKillSwitch)
}
Expand Down Expand Up @@ -523,6 +530,7 @@ private enum ValueFlag: String, FlagType {
case creditAndDebitCardDisabledRegions = "global.donations.ccDisabledRegions"
case paypalDisabledRegions = "global.donations.paypalDisabledRegions"
case sepaEnabledRegions = "global.donations.sepaEnabledRegions"
case idealEnabledRegions = "global.donations.idealEnabledRegions"
case maxGroupCallRingSize = "global.calling.maxGroupCallRingSize"
case minNicknameLength = "global.nicknames.min"
case maxNicknameLength = "global.nicknames.max"
Expand All @@ -546,6 +554,7 @@ private enum ValueFlag: String, FlagType {
case .creditAndDebitCardDisabledRegions: fallthrough
case .paypalDisabledRegions: fallthrough
case .sepaEnabledRegions: fallthrough
case .idealEnabledRegions: fallthrough
case .maxGroupCallRingSize: fallthrough
case .minNicknameLength: fallthrough
case .maxNicknameLength: fallthrough
Expand All @@ -565,6 +574,7 @@ private enum ValueFlag: String, FlagType {
case .creditAndDebitCardDisabledRegions: fallthrough
case .paypalDisabledRegions: fallthrough
case .sepaEnabledRegions: fallthrough
case .idealEnabledRegions: fallthrough
case .maxGroupCallRingSize:
return true

Expand Down

0 comments on commit bc33958

Please sign in to comment.