Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ struct GenerateNotificationUseCase: GenerateNotificationUseCaseProtocol {
for await events in updateEvents {
logger.info(
"Processing \(events.count) pending events...",
attributes: .newNSE
attributes: .newNSE, .safePublic
)

for event in events {
if let notification = await generateNotification(for: event) {
logger.info(
"Generated a notification from an event",
attributes: .newNSE
attributes: .newNSE, .safePublic
)
notifications.append(notification)
}
Expand All @@ -83,7 +83,7 @@ struct GenerateNotificationUseCase: GenerateNotificationUseCaseProtocol {
event: conversationEvent
)
} catch {
var attributes = LogAttributes.newNSE
var attributes = LogAttributes.newNSE + .safePublic
attributes[.eventId] = eventID.safeForLoggingDescription

logger.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
self.minTLSVersion = minTLSVersion
self.preferredAPIVersion = preferredAPIVersion
registerProviderFactories()
logger.info("initializing new notification service", attributes: .newNSE)
logger.info("initializing new notification service", attributes: .newNSE, .safePublic)
}

// MARK: - Notifications
Expand All @@ -75,7 +75,7 @@
if onGoingTask != nil {
logger.warn(
"onGoingtask not null: a notification is already being processed",
attributes: .newNSE
attributes: .newNSE, .safePublic
)
}

Expand All @@ -83,13 +83,14 @@
contentHandler($0) // Finishes current notification flow by calling system built-in handler.
self?.onGoingTask = nil // Current notification flow was completed, nil out the task.
}

Check warning on line 86 in WireDomain/Sources/WireDomain/Notifications/NotificationServiceExtension.swift

View workflow job for this annotation

GitHub Actions / Test Results

Passing closure as a 'sending' parameter risks causing data races between code in the current task and concurrent execution of the closure; this is an error in the Swift 6 language mode

Passing closure as a 'sending' parameter risks causing data races between code in the current task and concurrent execution of the closure; this is an error in the Swift 6 language mode
onGoingTask = Task {
do {
try Task.checkCancellation()
} catch {
// With the "filtering" entitlement, we can tell iOS to not display a user notification by passing empty
// content to the content handler. See https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_usernotifications_filtering
logger.warn("onGoingtask got cancelled: showing no notifications", attributes: .newNSE, .safePublic)
return notificationContentHandler(.emptyNotification)
}

Expand Down Expand Up @@ -131,7 +132,7 @@
}

public func serviceExtensionTimeWillExpire() {
logger.warn("new notification service will expire", attributes: .newNSE)
logger.warn("new notification service will expire", attributes: .newNSE, .safePublic)
onGoingTask?.cancel()
}
}
Expand Down Expand Up @@ -182,7 +183,7 @@
)
case let .unableToLoadStores(loadStoresError):
logger.error(
"Loading coreDataStack with error: \(loadStoresError.localizedDescription)",
"Loading coreDataStack with error: \(String(describing: loadStoresError))",
attributes: .newNSE, .safePublic
)
}
Expand All @@ -192,8 +193,8 @@
switch error {
case let .unableToPullPendingEvents(error):
logger.error(
"Could not pull pending events: \(error.localizedDescription)",
attributes: .newNSE
"Could not pull pending events: \(String(describing: error))",
attributes: .newNSE, .safePublic
)
}
}
Expand Down Expand Up @@ -270,7 +271,7 @@

private func logDefaultError(_ error: any Error) {
logger.error(
"Unable to create a session: \(error.localizedDescription)",
"Unable to create a session: \(String(describing: error))",
attributes: .newNSE, .safePublic
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct PullEventsUseCase: PullEventsUseCaseProtocol {
func invoke() async throws -> AsyncStream<[UpdateEvent]> {
logger.info(
"Attempting to fetch pending events",
attributes: .newNSE
attributes: .newNSE, .safePublic
)

do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ struct ShowNotificationUseCase: ShowNotificationUseCaseProtocol {

WireLogger.calling.info(
"Detected a call event",
attributes: .newNSE
attributes: .newNSE, .safePublic
)

try await CXProvider.reportNewIncomingVoIPPushPayload(callKitContent)
} catch {
WireLogger.calling.error(
"failed to wake up main app: \(error.localizedDescription)",
attributes: .newNSE
"failed to wake up main app: \(String(describing: error))",
attributes: .newNSE, .safePublic
)
}
}
Expand Down Expand Up @@ -102,7 +102,7 @@ struct ShowNotificationUseCase: ShowNotificationUseCaseProtocol {

WireLogger.notifications.info(
"Showing notification to the user",
attributes: .newNSE
attributes: .newNSE, .safePublic
)

// Displays the notification to the user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
return newToken
} catch {
WireLogger.authentication.error(
"Failed to renew access token with error: \(error.localizedDescription)"
"Failed to renew access token with error: \(String(describing: error))", attributes: .safePublic
)

currentToken = nil
Expand All @@ -124,6 +124,10 @@
case .invalidCredentials:
// can't recover, deleting cookies and logging out
try await cookieStorage.removeCookies()
WireLogger.authentication.info(
"Removed cookies (invalidCredentials)", attributes: .safePublic
)

onAuthenticationFailure()
}

Expand Down Expand Up @@ -158,7 +162,7 @@
if let lastKnownToken {
request.setAccessToken(lastKnownToken)
}

Check warning on line 165 in WireNetwork/Sources/WireNetwork/Authentication/AuthenticationManager.swift

View workflow job for this annotation

GitHub Actions / Test Results

Sending 'self.networkService' risks causing data races; this is an error in the Swift 6 language mode

Sending 'self.networkService' risks causing data races; this is an error in the Swift 6 language mode
let (data, response) = try await networkService.executeRequest(request)

let decoder = JSONDecoder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ private class NewMessageNotificationBuilder: EventNotificationBuilder {
conversation.isMessageSilenced(message, senderID: senderUUID) {
WireLogger.push
.info(
"Not creating local notification for message with nonce = \(event.messageNonce?.safeForLoggingDescription) because conversation is silenced"
"Not creating local notification for message with nonce = \(event.messageNonce?.safeForLoggingDescription) because conversation is silenced",
attributes: .safePublic
)
return false
} else if conversation == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
// MARK: - Methods

public func storeLocalToken(_ token: PushToken?) {
if PushTokenStorage.pushToken != nil, token != PushTokenStorage.pushToken {
WireLogger.push.info("updating token \(token == nil ? "to nil" : "")", attributes: .safePublic)
}
PushTokenStorage.pushToken = token
onTokenChange?(token)
}
Expand Down Expand Up @@ -181,7 +184,7 @@
/// The action's error.

mutating func perform(in context: NotificationContext) async throws -> Result {
try await withCheckedThrowingContinuation { continuation in

Check warning on line 187 in wire-ios-sync-engine/Source/SessionManager/PushTokenService.swift

View workflow job for this annotation

GitHub Actions / Test Results

Converting a value of type '(__shared sending Result<Self.Result, Self.Failure>) -> ()' to type '(Result<Self.Result, Self.Failure>) -> Void' risks causing data races; this is an error in the Swift 6 language mode

Converting a value of type '(__shared sending Result<Self.Result, Self.Failure>) -> ()' to type '(Result<Self.Result, Self.Failure>) -> Void' risks causing data races; this is an error in the Swift 6 language mode
perform(in: context, resultHandler: continuation.resume(with:))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

// MARK: - Token registration

public func configurePushToken(session: ZMUserSession) {

Check warning on line 40 in wire-ios-sync-engine/Source/SessionManager/SessionManager+PushToken.swift

View workflow job for this annotation

GitHub Actions / Test Results

Value 'localToken' was defined but never used; consider replacing with boolean test

Value 'localToken' was defined but never used; consider replacing with boolean test
guard let localToken = pushTokenService.localToken else {
WireLogger.push.info("no local token, will generate one")
generateLocalToken(session: session)
Expand All @@ -59,7 +59,7 @@
WireLogger.push.info("syncLocalTokenWithRemote")

guard let clientID = session.selfUserClient?.remoteIdentifier else {
WireLogger.push.info("syncLocalTokenWithRemote: failed: no self client id")
WireLogger.push.info("syncLocalTokenWithRemote: failed: no self client id", attributes: .safePublic)
return
}

Expand All @@ -72,11 +72,14 @@
in: notificationContext
)

WireLogger.push.info("syncLocalTokenWithRemote: success")
WireLogger.push.info("syncLocalTokenWithRemote: success", attributes: .safePublic)

} catch {
WireLogger.push
.error("syncLocalTokenWithRemote: failed: pushTokenService failed: \(error.localizedDescription)")
.error(
"syncLocalTokenWithRemote: failed: pushTokenService failed: \(String(describing: error))",
attributes: .safePublic
)
}
session.syncManagedObjectContext.leaveAllGroups(groups)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import UserNotifications
import WireFoundation
import WireLogging
import WireUtilities

struct ShouldPresentNotificationPermissionHintUseCase<
Expand All @@ -33,8 +34,16 @@ struct ShouldPresentNotificationPermissionHintUseCase<

// show hint only if `authorizationStatus` is `.denied`
let notificationSettings = await userNotificationCenter.notificationSettings()
guard notificationSettings.authorizationStatus == .denied else { return false }
guard notificationSettings.authorizationStatus == .denied else {
WireLogger.push.info(
"notifications authorizationStatus settings: \(notificationSettings.authorizationStatus)",
attributes: .safePublic
)

return false
}

WireLogger.push.info("notifications authorizationStatus settings are denied", attributes: .safePublic)
let lastPresentationDate = userDefaults.value(for: .lastTimeNotificationPermissionHintWasShown)
if let lastPresentationDate, lastPresentationDate > currentDateProvider.now.addingTimeInterval(-.oneDay) {
// hint has already been shown within the last 24 hours
Expand Down
Loading