diff --git a/SignalServiceKit/Attachments/AttachmentLimits.swift b/SignalServiceKit/Attachments/AttachmentLimits.swift index d1ff163bda..4e1fc70b8c 100644 --- a/SignalServiceKit/Attachments/AttachmentLimits.swift +++ b/SignalServiceKit/Attachments/AttachmentLimits.swift @@ -40,7 +40,9 @@ public struct OutgoingAttachmentLimits { public static func currentLimits( remoteConfig: RemoteConfig = .current, - callingCode: Int? = ImageQualityLevel.defaultCallingCode(), + callingCode: Int? = DependenciesBridge.shared.tsAccountManager.localIdentifiersWithMaybeSneakyTransaction.flatMap({ + return SSKEnvironment.shared.phoneNumberUtilRef.localCallingCode(localIdentifiers: $0) + }), ) -> Self { return Self(remoteConfig: remoteConfig, callingCode: callingCode) } diff --git a/SignalServiceKit/Contacts/PhoneNumberUtil.swift b/SignalServiceKit/Contacts/PhoneNumberUtil.swift index ec59ccd1b3..c9126ede89 100644 --- a/SignalServiceKit/Contacts/PhoneNumberUtil.swift +++ b/SignalServiceKit/Contacts/PhoneNumberUtil.swift @@ -108,9 +108,7 @@ public class PhoneNumberUtil: NSObject { i -= 1 } } -} -extension PhoneNumberUtil { /// Returns calling codes for libPhoneNumber-unsupported country codes. /// /// These are country codes that NSLocale.isoCountryCodes contains but @@ -245,6 +243,10 @@ extension PhoneNumberUtil { return Locale.current.localizedString(forRegionCode: countryCode)?.nilIfEmpty ?? unknownValue } + public func localCallingCode(localIdentifiers: LocalIdentifiers) -> Int? { + return parseE164(localIdentifiers.phoneNumber)?.getCallingCode() + } + private func _parsePhoneNumber(filteredValue: String, countryCode: String = defaultCountryCode()) -> PhoneNumber? { do { let phoneNumber = try parse(filteredValue, defaultRegion: countryCode) diff --git a/SignalServiceKit/Environment/RemoteConfigManager.swift b/SignalServiceKit/Environment/RemoteConfigManager.swift index 0e86fdf243..403be2305b 100644 --- a/SignalServiceKit/Environment/RemoteConfigManager.swift +++ b/SignalServiceKit/Environment/RemoteConfigManager.swift @@ -401,7 +401,7 @@ public class RemoteConfig { private static func countryCodeBucketValue(csvString: String, localIdentifiers: LocalIdentifiers) -> String? { let phoneNumberUtil = SSKEnvironment.shared.phoneNumberUtilRef - let callingCode = phoneNumberUtil.parseE164(localIdentifiers.phoneNumber)?.getCallingCode() + let callingCode = phoneNumberUtil.localCallingCode(localIdentifiers: localIdentifiers) return countryCodeValue(csvString: csvString, callingCode: callingCode) } diff --git a/SignalServiceKit/Util/ImageQuality.swift b/SignalServiceKit/Util/ImageQuality.swift index 34d1f2261b..d379a1a700 100644 --- a/SignalServiceKit/Util/ImageQuality.swift +++ b/SignalServiceKit/Util/ImageQuality.swift @@ -61,13 +61,6 @@ public enum ImageQualityLevel: UInt, Comparable { return remoteConfig.standardMediaQualityLevel(callingCode: callingCode) ?? .two } - public static func defaultCallingCode( - phoneNumberUtil: PhoneNumberUtil = SSKEnvironment.shared.phoneNumberUtilRef, - localIdentifiers: LocalIdentifiers? = DependenciesBridge.shared.tsAccountManager.localIdentifiersWithMaybeSneakyTransaction, - ) -> Int? { - return localIdentifiers.flatMap({ phoneNumberUtil.parseE164($0.phoneNumber) })?.getCallingCode() - } - public var startingTier: ImageQualityTier { switch self { case .one: return .four