Don't send a profile tag when registering a pusher. (#6442)

* Re-organise AppSettings a bit.

Some of the preferences were in the wrong sections.

* Don't send a profile tag when registering a pusher.
This commit is contained in:
Doug
2026-10-29 15:34:19 +00:00
committed by GitHub
parent f6a75aabc6
commit 296ceba684
7 changed files with 26 additions and 61 deletions
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.3.0 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.4.1 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all
@@ -106,6 +106,12 @@ final nonisolated class AppSettings: @unchecked Sendable {
@UserPreference
var lastVersionLaunched: String?
/// Whether a user session has ever been set up on this device. Deliberately not cleared on
/// logout: it stops the Classic app migration prompt from reappearing when an Element X
/// user is signed out unexpectedly (invalidated token, corrupted storage, etc).
@UserPreference(defaultValue: false)
var hasSignedInBefore: Bool
/// Defaults to `true` for new users, and we use a migration to set it to `false` for existing users.
@UserPreference(defaultValue: true)
var hasSeenNewSoundBanner: Bool
@@ -228,11 +234,7 @@ final nonisolated class AppSettings: @unchecked Sendable {
}
@UserPreference(defaultValue: false)
var hideQuietNotificationAlerts: Bool
/// Tag describing which set of device specific rules a pusher executes.
@UserPreference
var pusherProfileTag: String?
var hasRunNotificationPermissionsOnboarding: Bool
/// The device's last boot time as recorded by the NSE.
@UserPreference
@@ -281,24 +283,11 @@ final nonisolated class AppSettings: @unchecked Sendable {
}
/// Whether the user has opted in to send analytics.
///
/// **Note:** Opt-in is app-wide, not per-session.
@UserPreference(defaultValue: AnalyticsConsentState.unknown)
var analyticsConsentState: AnalyticsConsentState
/// Whether a user session has ever been set up on this device. Deliberately not cleared on
/// logout: it stops the Classic app migration prompt from reappearing when an Element X
/// user is signed out unexpectedly (invalidated token, corrupted storage, etc).
@UserPreference(defaultValue: false)
var hasSignedInBefore: Bool
@UserPreference(defaultValue: false)
var hasRunNotificationPermissionsOnboarding: Bool
@UserPreference(defaultValue: false)
var hasRequestedLocationAlwaysLocationAuthorization: Bool
@UserPreference(defaultValue: [FrequentlyUsedEmoji]())
var frequentlyUsedSystemEmojis: [FrequentlyUsedEmoji]
// MARK: - Live Location
@UserPreference(defaultValue: 10)
@@ -307,6 +296,9 @@ final nonisolated class AppSettings: @unchecked Sendable {
@UserPreference(defaultValue: false)
var liveLocationDisclaimerDisplayed: Bool
@UserPreference(defaultValue: false)
var hasRequestedLocationAlwaysLocationAuthorization: Bool
// MARK: - Room Screen
@UserPreference(defaultValue: AppBuildType.current == .debug)
@@ -318,6 +310,9 @@ final nonisolated class AppSettings: @unchecked Sendable {
@UserPreference(defaultValue: AudioPlaybackSpeed.default)
var voiceMessagePlaybackSpeed: AudioPlaybackSpeed
@UserPreference(defaultValue: [FrequentlyUsedEmoji]())
var frequentlyUsedSystemEmojis: [FrequentlyUsedEmoji]
/// Whether or not to show a warning on the media caption composer so the user knows
/// that captions might not be visible to users who are using other Matrix clients.
let shouldShowMediaCaptionWarning = true
@@ -352,7 +347,9 @@ final nonisolated class AppSettings: @unchecked Sendable {
// MARK: - Feature Flags
/// Others
@UserPreference(defaultValue: AppBuildType.current != .release)
var developerOptionsEnabled: Bool
@UserPreference(defaultValue: false)
var fuzzyRoomListSearchEnabled: Bool
@@ -395,8 +392,8 @@ final nonisolated class AppSettings: @unchecked Sendable {
@UserPreference(key: "clientPausingAndResumingEnabledV2", defaultValue: false, volatile: true)
var clientPausingAndResumingEnabled: Bool
@UserPreference(defaultValue: AppBuildType.current != .release)
var developerOptionsEnabled: Bool
@UserPreference(defaultValue: false)
var hideQuietNotificationAlerts: Bool
/// Runs calls through the native matrix-rust-rtc stack instead of the Element Call web view.
@UserPreference(defaultValue: false)
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.3.0 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.4.1 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.3.0 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.4.1 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all
@@ -151,23 +151,9 @@ final class NotificationService: NotificationServiceProtocol {
defaultPayload: defaultPayload.toJsonString())),
appDisplayName: "\(InfoPlistReader.main.bundleDisplayName) (iOS)",
deviceDisplayName: UIDevice.current.name,
profileTag: pusherProfileTag(),
profileTag: nil,
lang: Bundle.app.preferredLocalizations.first ?? "en",
// Otherwise accounts on the same homeserver delete each other's pusher.
append: userSettings.app.multiAccountEnabled)
}
private func pusherProfileTag() -> String {
if let currentTag = userSettings.app.pusherProfileTag {
return currentTag
}
let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
let newTag = (0..<16).map { _ in
let offset = Int.random(in: 0..<chars.count)
return String(chars[chars.index(chars.startIndex, offsetBy: offset)])
}.joined()
userSettings.app.pusherProfileTag = newTag
return newTag
}
}
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.3.0 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.4.1 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all
@@ -43,7 +43,7 @@ final class NotificationServiceTests {
defaultPayload: defaultPayload.toJsonString())),
appDisplayName: "\(InfoPlistReader.main.bundleDisplayName) (iOS)",
deviceDisplayName: UIDevice.current.name,
profileTag: appSettings.pusherProfileTag,
profileTag: nil,
lang: Bundle.app.preferredLocalizations.first ?? "en",
append: false)
#expect(clientProxy.setPusherWithReceivedInvocations == [expectedConfiguration])
@@ -60,24 +60,6 @@ final class NotificationServiceTests {
#expect(configuration.append)
}
@Test
func registeringGeneratesAndSavesTheProfileTag() async {
appSettings.pusherProfileTag = nil
await makeService().register(deviceToken: Data())
#expect(appSettings.pusherProfileTag != nil)
}
@Test
func registeringKeepsTheSavedProfileTag() async {
appSettings.pusherProfileTag = "12345"
await makeService().register(deviceToken: Data())
#expect(appSettings.pusherProfileTag == "12345")
}
@Test
func registeringWhileTurnedOffDeletesThePusher() async throws {
let service = makeService(isEnabled: false)