Skip to content
Open
Show file tree
Hide file tree
Changes from 11 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 @@ -807,8 +807,8 @@
)

public lazy var workAgent: WorkAgent = .init(scheduler: PriorityOrderWorkItemScheduler())

Check warning on line 810 in WireDomain/Sources/WireDomain/Components/ClientSessionComponent.swift

View workflow job for this annotation

GitHub Actions / Test Results

Actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode

Actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode
public lazy var conversationUpdatesGenerator: ConversationUpdatesGeneratorProtocol = ConversationUpdatesGenerator(
public lazy var conversationUpdatesGenerator: IncrementalGeneratorProtocol = ConversationUpdatesGenerator(
repository: conversationRepository,
context: syncContext,
onConversationUpdated: { [weak self] workItem in
Expand All @@ -816,5 +816,30 @@
self?.workAgent.submitItem(workItem)
}
)

Check warning on line 819 in WireDomain/Sources/WireDomain/Components/ClientSessionComponent.swift

View workflow job for this annotation

GitHub Actions / Test Results

Actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode

Actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode
public lazy var commitPendingProposalsGenerator: LiveGeneratorProtocol = CommitPendingProposalsGenerator(
repository: conversationRepository,
mlsService: mlsService,
context: syncContext,
isMLSGroupBroken: { [weak self] groupID in
self?.isMLSGroupBroken(groupID: groupID) == true
},
onCommitPendingProposals: { [weak self] workItem in

self?.workAgent.submitItem(workItem)
}
)

public lazy var generatorsDirectory = GeneratorsDirectory(
generators: [
conversationUpdatesGenerator,
commitPendingProposalsGenerator
],
syncStatePublisher: syncStateSubject.eraseToAnyPublisher()
)

private func isMLSGroupBroken(groupID: MLSGroupID) -> Bool {
let brokenGroupIds = journal[.brokenMLSGroupIDs]
return brokenGroupIds.contains(groupID.description)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ struct UpdateEventDecryptor: UpdateEventDecryptorProtocol {

var decryptedEvents = [UpdateEvent]()
var brokenMLSGroupIDs = Set<String>()
var shouldCommitPendingProposals = false

for event in eventEnvelope.events {
logAttributes[.messageType] = event.name
Expand Down Expand Up @@ -120,7 +119,6 @@ struct UpdateEventDecryptor: UpdateEventDecryptorProtocol {
"decrypting MLS add message event...",
attributes: logAttributes
)
shouldCommitPendingProposals = true

do {
let decryptedEventData = try await mlsMessageDecryptor.decryptedMessageAddEventData(
Expand Down Expand Up @@ -170,23 +168,9 @@ struct UpdateEventDecryptor: UpdateEventDecryptorProtocol {
}
}

if shouldCommitPendingProposals {
Task.detached {
// we don't need to wait for this, as it can take a while to finish
// it should not block decryption
await commitPendingProposalsIfNeeded()
}
}

return EventDecryptorResult(events: decryptedEvents, brokenMLSGroupIDs: brokenMLSGroupIDs)
}

private func commitPendingProposalsIfNeeded() async {
// MLSService will be nil when called from push notification service.
// As we don't need to commit pending proposals in that case.
await mlsService?.commitPendingProposalsIfNeeded()
}

private func appendFailedToDecryptProteusMessage(
eventData: ConversationProteusMessageAddEvent,
error: ProteusError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
// MARK: - Public

public func qualifiedID(for conversation: ZMConversation) async -> QualifiedID? {
await context.perform {

Check warning on line 60 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.qualifiedID
}
}
Expand All @@ -66,7 +66,7 @@
_ lastReadMessage: LastRead,
in conversation: ZMConversation
) async {
await context.perform { [context] in

Check warning on line 69 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
guard conversation.isSelfConversation else {
return
}
Expand All @@ -82,7 +82,7 @@
_ clearedMessage: Cleared,
in conversation: ZMConversation
) async {
await context.perform { [context] in

Check warning on line 85 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
guard conversation.isSelfConversation else {
return
}
Expand All @@ -98,7 +98,7 @@
conversation: ZMConversation
) async -> (mlsGroupID: MLSGroupID, isMLSReady: Bool)? {

await context.perform {

Check warning on line 101 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
guard let mlsGroupID = conversation.mlsGroupID else {
return nil
}
Expand All @@ -112,7 +112,7 @@
mlsGroupID: MLSGroupID,
conversation: ZMConversation
) async {
await context.perform {

Check warning on line 115 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.mlsStatus = .ready
conversation.mlsGroupID = mlsGroupID
}
Expand All @@ -122,7 +122,7 @@
newMLSGroupID: MLSGroupID,
conversation: ZMConversation
) async {
await context.perform {

Check warning on line 125 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.mlsStatus = .pendingJoinAfterReset
conversation.mlsGroupID = newMLSGroupID
}
Expand All @@ -145,7 +145,7 @@
public func fetchOtherUserIDInOneOnOneConversation(
conversation: ZMConversation
) async -> WireDataModel.QualifiedID? {
await context.perform {

Check warning on line 148 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
guard conversation.conversationType == .oneOnOne else {
WireLogger.conversation.info(
"conversation type is not expected 'oneOnOne', aborting."
Expand All @@ -156,7 +156,7 @@

guard
let otherUser = conversation.localParticipantsExcludingSelf.first,
let otherUserID = otherUser.remoteIdentifier,

Check warning on line 159 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'self' with non-Sendable type 'ConversationLocalStore' in a '@Sendable' closure

Capture of 'self' with non-Sendable type 'ConversationLocalStore' in a '@sendable' closure

Check warning on line 159 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Implicit capture of 'self' requires that 'ConversationLocalStore' conforms to 'Sendable'

Implicit capture of 'self' requires that 'ConversationLocalStore' conforms to 'Sendable'
let otherUserDomain = otherUser.domain ?? self.localDomain
else {
WireLogger.conversation.warn(
Expand All @@ -182,7 +182,7 @@
let mutedStatus = mutedStatusInfo.status
let mutedReference = mutedStatusInfo.referenceDate

if let mutedStatus, let mutedReference {

Check warning on line 185 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
localConversation.updateMutedStatus(
status: Int32(mutedStatus),
referenceDate: mutedReference
Expand Down Expand Up @@ -236,9 +236,9 @@

await context.perform {
// If user is already part of the conversation, its role will be updated.
// If not, user will be added to the conversation.

Check warning on line 239 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.addParticipantAndUpdateConversationState(

Check warning on line 240 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'user' with non-Sendable type 'ZMUser' in a '@Sendable' closure

Capture of 'user' with non-Sendable type 'ZMUser' in a '@sendable' closure
user: user,

Check warning on line 241 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'role' with non-Sendable type 'Role' in a '@Sendable' closure

Capture of 'role' with non-Sendable type 'Role' in a '@sendable' closure
role: role
)
}
Expand All @@ -247,7 +247,7 @@
public func increaseUnreadCount(
for conversation: ZMConversation
) async {
await context.perform {

Check warning on line 250 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.internalEstimatedUnreadCount += 1
}
}
Expand All @@ -255,7 +255,7 @@
public func decreaseUnreadCount(
for conversation: ZMConversation
) async {
await context.perform {

Check warning on line 258 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.internalEstimatedUnreadCount -= 1
}
}
Expand All @@ -263,7 +263,7 @@
public func increaseUnreadSelfMentionCount(
for conversation: ZMConversation
) async {
await context.perform {

Check warning on line 266 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.internalEstimatedUnreadSelfMentionCount += 1
}
}
Expand All @@ -271,7 +271,7 @@
public func increaseUnreadSelfReplyCount(
for conversation: ZMConversation
) async {
await context.perform {

Check warning on line 274 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.internalEstimatedUnreadSelfReplyCount += 1
}
}
Expand All @@ -286,7 +286,7 @@
permission: Conversation.ChannelPermission,
conversation: ZMConversation
) async {
await context.perform {

Check warning on line 289 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure

Check warning on line 289 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'permission' with non-Sendable type 'Conversation.ChannelPermission' in a '@Sendable' closure

Capture of 'permission' with non-Sendable type 'Conversation.ChannelPermission' in a '@sendable' closure
conversation.privateChannelPermission = PrivateChannelPermission(permission)
}
}
Expand All @@ -301,7 +301,7 @@
domain: conversationDomain
)

await context.perform {

Check warning on line 304 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation?' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation?' in a '@sendable' closure
conversation?.channelHistoryDepth = historyDepth
}
}
Expand Down Expand Up @@ -333,9 +333,9 @@
]
)
}

Check warning on line 336 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode

Check warning on line 336 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode
let usersAndRoles = await withTaskGroup(of: UserAndRole?.self) { taskGroup in
for newParticipant in participants {

Check warning on line 338 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode

Check warning on line 338 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.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
taskGroup.addTask { [self] in
let user = await context.perform { [context] in
ZMUser.fetchOrCreate(
Expand All @@ -359,7 +359,7 @@
}

var usersAndRoles: [UserAndRole?] = []

Check warning on line 362 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode
for await userAndRole in taskGroup {
usersAndRoles.append(userAndRole)
}
Expand Down Expand Up @@ -388,8 +388,8 @@
)
}

await context.perform {

Check warning on line 391 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
localConversation.addParticipantsAndUpdateConversationState(

Check warning on line 392 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'usersAndRoles' with non-Sendable type '[UserAndRole]' (aka 'Array<(user: ZMUser, role: Optional<Role>)>') in a '@Sendable' closure

Capture of 'usersAndRoles' with non-Sendable type '[UserAndRole]' (aka 'Array<(user: ZMUser, role: Optional<Role>)>') in a '@sendable' closure
usersAndRoles: usersAndRoles
)
}
Expand All @@ -399,7 +399,7 @@
user: ZMUser,
conversation: ZMConversation
) async {
await context.perform { [context] in

Check warning on line 402 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'user' with non-Sendable type 'ZMUser' in a '@Sendable' closure

Capture of 'user' with non-Sendable type 'ZMUser' in a '@sendable' closure

Check warning on line 402 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure

Check warning on line 402 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Implicit capture of 'conversation' requires that 'ZMConversation' conforms to 'Sendable'

Implicit capture of 'conversation' requires that 'ZMConversation' conforms to 'Sendable'
if user.objectID.isTemporaryID || conversation.objectID.isTemporaryID {
do {
try context.obtainPermanentIDs(for: [user, conversation])
Expand All @@ -417,7 +417,7 @@
to conversation: ZMConversation
) async {
await context.perform { [context] in
let systemMessage = ZMSystemMessage(nonce: UUID(), managedObjectContext: context)

Check warning on line 420 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'message' with non-Sendable type 'SystemMessage' in a '@Sendable' closure

Capture of 'message' with non-Sendable type 'SystemMessage' in a '@sendable' closure
systemMessage.systemMessageType = message.type
systemMessage.sender = message.sender
systemMessage.users = message.users ?? Set()
Expand All @@ -436,7 +436,7 @@
systemMessage.relevantForConversationStatus = message.relevantForStatus
systemMessage.participantsRemovedReason = message.removedReason
systemMessage.domains = message.domains

Check warning on line 439 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.append(systemMessage)
}
}
Expand Down Expand Up @@ -534,7 +534,7 @@
domain: conversationDomain
)

await context.perform {

Check warning on line 537 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.isPendingMetadataRefresh = true
conversation.needsToBeUpdatedFromBackend = true
}
Expand Down Expand Up @@ -575,7 +575,7 @@
public func conversationNeedsBackendUpdate(
_ conversation: ZMConversation
) async -> Bool {
await context.perform {

Check warning on line 578 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.needsToBeUpdatedFromBackend
}
}
Expand All @@ -583,7 +583,7 @@
public func isConversationArchived(
_ conversation: ZMConversation
) async -> Bool {
await context.perform {

Check warning on line 586 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.isArchived
}
}
Expand All @@ -591,7 +591,7 @@
public func isConversationForcedReadOnly(
_ conversation: ZMConversation
) async -> Bool {
await context.perform {

Check warning on line 594 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.isForcedReadOnly
}
}
Expand All @@ -601,7 +601,7 @@
senderID: UUID?,
conversation: ZMConversation
) async -> Bool {
await context.perform {

Check warning on line 604 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.isMessageSilenced(message, senderID: senderID)
}
}
Expand All @@ -624,7 +624,7 @@
) async {
let scheduledDate = date + TimeInterval(commitDelay)

await context.perform {

Check warning on line 627 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.commitPendingProposalDate = scheduledDate
}
}
Expand All @@ -635,7 +635,7 @@
date: Date
) async {
// Update the legal hold state in the conversation
await context.perform {

Check warning on line 638 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.updateSecurityLevelIfNeededAfterReceiving(
message: genericMessage,
timestamp: date
Expand All @@ -660,8 +660,8 @@
return
}

await context.perform {

Check warning on line 663 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.addParticipantAndSystemMessageIfMissing(

Check warning on line 664 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'participant' with non-Sendable type 'ZMUser' in a '@Sendable' closure

Capture of 'participant' with non-Sendable type 'ZMUser' in a '@sendable' closure
participant,
date: date
)
Expand All @@ -671,7 +671,7 @@
public func conversationMutedMessageTypes(
_ conversation: ZMConversation
) async -> MutedMessageTypes {
await context.perform {

Check warning on line 674 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.mutedMessageTypes
}
}
Expand All @@ -680,7 +680,7 @@
_ conversation: ZMConversation
) async -> MutedMessageTypes {
await context.perform { [context] in
let selfUser = ZMUser.selfUser(in: context)

Check warning on line 683 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
return selfUser.mutedMessagesTypes.union(conversation.mutedMessageTypes)
}
}
Expand All @@ -688,7 +688,7 @@
public func lastReadServerTimestamp(
_ conversation: ZMConversation
) async -> Date? {
await context.perform {

Check warning on line 691 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.lastReadServerTimeStamp
}
}
Expand All @@ -696,7 +696,7 @@
public func conversationMessageDestructionTimeout(
_ conversation: ZMConversation
) async -> MessageDestructionTimeoutValue {
await context.perform {

Check warning on line 699 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.activeMessageDestructionTimeoutValue ?? .init(rawValue: 0)
}
}
Expand All @@ -705,7 +705,7 @@
timeoutValue: Double,
for conversation: ZMConversation
) async {
await context.perform {

Check warning on line 708 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.setMessageDestructionTimeoutValue(
.init(rawValue: timeoutValue),
for: .groupConversation
Expand All @@ -717,7 +717,7 @@
hasReadReceiptsEnabled: Bool,
for conversation: ZMConversation
) async {
await context.perform {

Check warning on line 720 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.hasReadReceiptsEnabled = hasReadReceiptsEnabled
}
}
Expand All @@ -725,7 +725,7 @@
public func messageProtocol(
for conversation: ZMConversation
) async -> WireDataModel.MessageProtocol {
await context.perform {

Check warning on line 728 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.messageProtocol
}
}
Expand All @@ -733,13 +733,13 @@
public func isGroupConversation(
_ conversation: ZMConversation
) async -> Bool {
await context.perform {

Check warning on line 736 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.conversationType == .group
}
}

public func isSelfConversation(_ conversation: ZMConversation) async -> Bool {
await context.perform {

Check warning on line 742 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.conversationType == .self
}
}
Expand All @@ -747,7 +747,7 @@
public func name(
for conversation: ZMConversation
) async -> String? {
await context.perform {

Check warning on line 750 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.displayName
}
}
Expand All @@ -767,7 +767,7 @@
}

let allGroupConversations = await context.perform {
// swiftformat:disable:next redundantProperty

Check warning on line 770 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'user' with non-Sendable type 'ZMUser' in a '@Sendable' closure

Capture of 'user' with non-Sendable type 'ZMUser' in a '@sendable' closure
let allGroupConversations: [ZMConversation] = user.participantRoles.compactMap {
guard $0.conversation?.conversationType == .group else {
return nil
Expand All @@ -781,9 +781,9 @@

for conversation in allGroupConversations {
let (userTeam, isTeamMember, conversationTeam, conversationID, conversationDomain) = await context.perform {
(

Check warning on line 784 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'user' with non-Sendable type 'ZMUser' in a '@Sendable' closure

Capture of 'user' with non-Sendable type 'ZMUser' in a '@sendable' closure
user.team,
user.isTeamMember,

Check warning on line 786 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.team,
conversation.remoteIdentifier as UUID,
conversation.domain
Expand Down Expand Up @@ -818,8 +818,8 @@
)
}

await context.perform {

Check warning on line 821 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.removeParticipantAndUpdateConversationState(

Check warning on line 822 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'user' with non-Sendable type 'ZMUser' in a '@Sendable' closure

Capture of 'user' with non-Sendable type 'ZMUser' in a '@sendable' closure
user: user,
initiatingUser: user
)
Expand All @@ -833,7 +833,7 @@
) async -> Role {
await context.perform { [context] in
Role.fetchOrCreateRole(
with: role,

Check warning on line 836 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
teamOrConversation: TeamOrConversation.matching(conversation),
in: context
)
Expand All @@ -845,7 +845,7 @@
accessModes: [String],
accessRoles: [String]
) async {
await context.perform { [context] in

Check warning on line 848 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.accessModeStrings = accessModes
conversation.accessRoleStringsV2 = accessRoles

Expand All @@ -868,7 +868,7 @@
isDeletedRemotely: Bool,
conversation: ZMConversation
) async {
await context.perform {

Check warning on line 871 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.isDeletedRemotely = isDeletedRemotely
}
}
Expand All @@ -878,9 +878,9 @@
users: Set<ZMUser>,
initiatingUser: ZMUser
) async {
await context.perform {

Check warning on line 881 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.removeParticipantsAndUpdateConversationState(

Check warning on line 882 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'users' with non-Sendable type 'Set<ZMUser>' in a '@Sendable' closure

Capture of 'users' with non-Sendable type 'Set<ZMUser>' in a '@sendable' closure
users: users,

Check warning on line 883 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'initiatingUser' with non-Sendable type 'ZMUser' in a '@Sendable' closure

Capture of 'initiatingUser' with non-Sendable type 'ZMUser' in a '@sendable' closure
initiatingUser: initiatingUser
)
}
Expand All @@ -889,7 +889,7 @@
public func localParticipants(
in conversation: ZMConversation
) async -> Set<ZMUser> {
await context.perform {

Check warning on line 892 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.localParticipants
}
}
Expand All @@ -897,7 +897,7 @@
public func conversationName(
conversation: ZMConversation
) async -> String? {
await context.perform {

Check warning on line 900 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.userDefinedName
}
}
Expand All @@ -906,7 +906,7 @@
newName: String,
conversation: ZMConversation
) async {
await context.perform {

Check warning on line 909 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
conversation.userDefinedName = newName
}
}
Expand Down Expand Up @@ -946,10 +946,10 @@
domain: conversation.qualifiedID?.domain
)

await context.perform { [self] in

Check warning on line 949 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
localConversation.conversationType = .connection

Check warning on line 951 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'self' with non-Sendable type 'ConversationLocalStore' in a '@Sendable' closure

Capture of 'self' with non-Sendable type 'ConversationLocalStore' in a '@sendable' closure
commonUpdate(

Check warning on line 952 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'Conversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'Conversation' in a '@sendable' closure
from: conversation,
for: localConversation,
serverTimestamp: serverTimestamp,
Expand Down Expand Up @@ -1003,15 +1003,15 @@
domain: conversation.qualifiedID?.domain
)

let mlsGroupID = await context.perform {

Check warning on line 1006 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'Conversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'Conversation' in a '@sendable' closure
conversation.mlsGroupID
}

await context.perform { [self] in

Check warning on line 1010 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
localConversation.conversationType = .`self`
localConversation.isPendingMetadataRefresh = false

Check warning on line 1013 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'self' with non-Sendable type 'ConversationLocalStore' in a '@Sendable' closure

Capture of 'self' with non-Sendable type 'ConversationLocalStore' in a '@sendable' closure
commonUpdate(

Check warning on line 1014 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'Conversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'Conversation' in a '@sendable' closure
from: conversation,
for: localConversation,
serverTimestamp: serverTimestamp,
Expand Down Expand Up @@ -1060,13 +1060,13 @@
domain: conversation.qualifiedID?.domain
)

await context.perform { [self] in

Check warning on line 1063 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure

Check warning on line 1063 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Mutation of captured var 'isInitialFetch' in concurrently-executing code

Mutation of captured var 'isInitialFetch' in concurrently-executing code
isInitialFetch = localConversation.isPendingInitialFetch

localConversation.conversationType = .group
localConversation.remoteIdentifier = id
localConversation.isPendingMetadataRefresh = false
localConversation.isPendingInitialFetch = false

Check warning on line 1069 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'Conversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'Conversation' in a '@sendable' closure
localConversation.groupType = conversation.groupType.map { groupType in
switch groupType {
case .group:
Expand All @@ -1089,7 +1089,7 @@
.disabled
}
} ?? .disabled

Check warning on line 1092 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'self' with non-Sendable type 'ConversationLocalStore' in a '@Sendable' closure

Capture of 'self' with non-Sendable type 'ConversationLocalStore' in a '@sendable' closure
commonUpdate(
from: conversation,
for: localConversation,
Expand All @@ -1102,7 +1102,7 @@
from: conversation,
for: localConversation
)

Check warning on line 1105 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Reference to captured var 'isInitialFetch' in concurrently-executing code

Reference to captured var 'isInitialFetch' in concurrently-executing code
if isInitialFetch {
assignMessageProtocol(
from: conversation,
Expand Down Expand Up @@ -1137,9 +1137,9 @@
isMLSEnabled: isMLSEnabled
)

await context.perform { [self] in

Check warning on line 1140 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Reference to captured var 'isInitialFetch' in concurrently-executing code

Reference to captured var 'isInitialFetch' in concurrently-executing code
if isInitialFetch {
// we just got a new conversation, we display new conversation header

Check warning on line 1142 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
localConversation.appendNewConversationSystemMessage(
at: .distantPast,
users: localConversation.localParticipants
Expand All @@ -1154,7 +1154,7 @@
}

// If we discover this group is actually a fake one on one,
// then we should link the one on one user.

Check warning on line 1157 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'self' with non-Sendable type 'ConversationLocalStore' in a '@Sendable' closure

Capture of 'self' with non-Sendable type 'ConversationLocalStore' in a '@sendable' closure
linkOneOnOneUserIfNeeded(for: localConversation)

// All metadata has been updated, object does not need to be updated from backend
Expand Down Expand Up @@ -1189,14 +1189,14 @@
let conversationType = BackendConversationType.clientConversationType(
rawValue: conversationTypeRawValue
)

Check warning on line 1192 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'localConversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
if localConversation.oneOnOneUser?.connection?.status == .sent {
localConversation.conversationType = .connection
} else {
localConversation.conversationType = conversationType
}

Check warning on line 1198 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'self' with non-Sendable type 'ConversationLocalStore' in a '@Sendable' closure

Capture of 'self' with non-Sendable type 'ConversationLocalStore' in a '@sendable' closure
assignMessageProtocol(

Check warning on line 1199 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'Conversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'Conversation' in a '@sendable' closure
from: conversation,
for: localConversation
)
Expand Down Expand Up @@ -1297,11 +1297,20 @@
domain: conversationDomain
)

return await context.perform {

Check warning on line 1300 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'handler' with non-Sendable type '(ZMConversation) -> (ZMConversation, MLSGroupID?)' in a '@Sendable' closure

Capture of 'handler' with non-Sendable type '(ZMConversation) -> (ZMConversation, MLSGroupID?)' in a '@sendable' closure

Check warning on line 1300 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
handler(conversation)
}
}

public func execute(
identifier: MLSGroupID,
block: @escaping @Sendable (ZMConversation?, NSManagedObjectContext) -> Void
) async {
await context.perform { [context] in
let conversation = ZMConversation.fetch(with: identifier, in: context)
block(conversation, context)
}
}
}

// MARK: - Private helpers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,8 @@ public protocol ConversationLocalStoreProtocol {

func fetchServerTimeDelta() async -> TimeInterval

func execute(
identifier: MLSGroupID,
block: @escaping @Sendable (ZMConversation?, NSManagedObjectContext) -> Void
) async
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,10 @@ public protocol ConversationRepositoryProtocol: Sendable {
conversationID: String
) async throws -> String?

/// Checks if selfUser is still in a given conversation
/// - Parameter groupID: mlsGroupID of the conversation
/// - Returns: true if selfUser belongs to the conversation, false otherwise
func isSelfAnActiveMember(
in groupID: WireDataModel.MLSGroupID
) async -> Bool
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@

import Foundation
import WireDataModel
import WireLogging

Check warning on line 21 in WireDomain/Sources/WireDomain/Repositories/Conversations/Repository/ConversationRepository.swift

View workflow job for this annotation

GitHub Actions / Test Results

Add '@preconcurrency' to suppress 'Sendable'-related warnings from module 'WireNetwork'

Add '@preconcurrency' to suppress 'Sendable'-related warnings from module 'WireNetwork'
import WireNetwork

public final class ConversationRepository: ConversationRepositoryProtocol {

// MARK: - Properties

Check warning on line 27 in WireDomain/Sources/WireDomain/Repositories/Conversations/Repository/ConversationRepository.swift

View workflow job for this annotation

GitHub Actions / Test Results

Stored property 'conversationsAPI' of 'Sendable'-conforming class 'ConversationRepository' has non-Sendable type 'any ConversationsAPI'; this is an error in the Swift 6 language mode

Stored property 'conversationsAPI' of 'Sendable'-conforming class 'ConversationRepository' has non-Sendable type 'any ConversationsAPI'; this is an error in the Swift 6 language mode
private let conversationsAPI: any ConversationsAPI

Check warning on line 28 in WireDomain/Sources/WireDomain/Repositories/Conversations/Repository/ConversationRepository.swift

View workflow job for this annotation

GitHub Actions / Test Results

Stored property 'conversationsLocalStore' of 'Sendable'-conforming class 'ConversationRepository' has non-Sendable type 'any ConversationLocalStoreProtocol'; this is an error in the Swift 6 language mode

Stored property 'conversationsLocalStore' of 'Sendable'-conforming class 'ConversationRepository' has non-Sendable type 'any ConversationLocalStoreProtocol'; this is an error in the Swift 6 language mode
private let conversationsLocalStore: any ConversationLocalStoreProtocol

Check warning on line 29 in WireDomain/Sources/WireDomain/Repositories/Conversations/Repository/ConversationRepository.swift

View workflow job for this annotation

GitHub Actions / Test Results

Stored property 'userLocalStore' of 'Sendable'-conforming class 'ConversationRepository' has non-Sendable type 'any UserLocalStoreProtocol'; this is an error in the Swift 6 language mode

Stored property 'userLocalStore' of 'Sendable'-conforming class 'ConversationRepository' has non-Sendable type 'any UserLocalStoreProtocol'; this is an error in the Swift 6 language mode
private let userLocalStore: any UserLocalStoreProtocol

Check warning on line 30 in WireDomain/Sources/WireDomain/Repositories/Conversations/Repository/ConversationRepository.swift

View workflow job for this annotation

GitHub Actions / Test Results

Stored property 'teamRepository' of 'Sendable'-conforming class 'ConversationRepository' has non-Sendable type 'any TeamRepositoryProtocol'; this is an error in the Swift 6 language mode

Stored property 'teamRepository' of 'Sendable'-conforming class 'ConversationRepository' has non-Sendable type 'any TeamRepositoryProtocol'; this is an error in the Swift 6 language mode
private let teamRepository: any TeamRepositoryProtocol

Check warning on line 31 in WireDomain/Sources/WireDomain/Repositories/Conversations/Repository/ConversationRepository.swift

View workflow job for this annotation

GitHub Actions / Test Results

Stored property 'messageRepository' of 'Sendable'-conforming class 'ConversationRepository' has non-Sendable type 'any MessageRepositoryProtocol'; this is an error in the Swift 6 language mode

Stored property 'messageRepository' of 'Sendable'-conforming class 'ConversationRepository' has non-Sendable type 'any MessageRepositoryProtocol'; this is an error in the Swift 6 language mode
private let messageRepository: any MessageRepositoryProtocol
private let localDomain: String
private let isFederationEnabled: Bool
private let isMLSEnabled: Bool

Check warning on line 35 in WireDomain/Sources/WireDomain/Repositories/Conversations/Repository/ConversationRepository.swift

View workflow job for this annotation

GitHub Actions / Test Results

Stored property 'mlsProvider' of 'Sendable'-conforming class 'ConversationRepository' has non-Sendable type 'MLSProvider'; this is an error in the Swift 6 language mode

Stored property 'mlsProvider' of 'Sendable'-conforming class 'ConversationRepository' has non-Sendable type 'MLSProvider'; this is an error in the Swift 6 language mode
private let mlsProvider: MLSProvider

// MARK: - Object lifecycle
Expand Down Expand Up @@ -377,6 +377,16 @@
await deleteMembership(for: removedUserIDs, time: date)
}

public func isSelfAnActiveMember(
in groupID: MLSGroupID
) async -> Bool {
nonisolated(unsafe) var isSelfAnActiveMember = false
await conversationsLocalStore.execute(identifier: groupID) { conversation, _ in
isSelfAnActiveMember = conversation?.isSelfAnActiveMember ?? false
}
return isSelfAnActiveMember
}

// MARK: - Private

private func addSystemMessage(
Expand Down Expand Up @@ -411,9 +421,9 @@

private func getRemovedUsers(
from userIDs: Set<UserID>
) async -> [WireDataModel.ZMUser] {

Check warning on line 424 in WireDomain/Sources/WireDomain/Repositories/Conversations/Repository/ConversationRepository.swift

View workflow job for this annotation

GitHub Actions / Test Results

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode

Check warning on line 424 in WireDomain/Sources/WireDomain/Repositories/Conversations/Repository/ConversationRepository.swift

View workflow job for this annotation

GitHub Actions / Test Results

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode
await withTaskGroup(of: WireDataModel.ZMUser.self) { taskGroup in
for userID in userIDs {

Check warning on line 426 in WireDomain/Sources/WireDomain/Repositories/Conversations/Repository/ConversationRepository.swift

View workflow job for this annotation

GitHub Actions / Test Results

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode
taskGroup.addTask { [self] in
await userLocalStore.fetchOrCreateUser(
id: userID.id,
Expand All @@ -423,7 +433,7 @@
}

var users: [WireDataModel.ZMUser] = []

Check warning on line 436 in WireDomain/Sources/WireDomain/Repositories/Conversations/Repository/ConversationRepository.swift

View workflow job for this annotation

GitHub Actions / Test Results

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode

Conformance of 'NSManagedObject' to 'Sendable' is unavailable in iOS; this is an error in the Swift 6 language mode
for await user in taskGroup {
users.append(user)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
//
// Wire
// Copyright (C) 2025 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
import Foundation
import WireDataModel
import WireLogging

public final class CommitPendingProposalsGenerator: NSObject, LiveGeneratorProtocol {

private let context: NSManagedObjectContext
private let fetchedResultsController: NSFetchedResultsController<ZMConversation>
private let repository: ConversationRepositoryProtocol
private let mlsService: MLSServiceInterface
private let isMLSGroupBroken: (MLSGroupID) -> Bool
private var onCommitPendingProposals: (CommitPendingProposalItem) -> Void

init(
repository: ConversationRepositoryProtocol,
mlsService: MLSServiceInterface,
context: NSManagedObjectContext,
isMLSGroupBroken: @escaping (MLSGroupID) -> Bool,
onCommitPendingProposals: @escaping (CommitPendingProposalItem) -> Void
) {
let request = NSFetchRequest<ZMConversation>(entityName: ZMConversation.entityName())
request.predicate = ZMConversation.commitPendingProposalDatePredicate()
request.sortDescriptors = [ZMConversation.sortCommitPendingProsalsByDateAscending()]
self.fetchedResultsController = NSFetchedResultsController(
fetchRequest: request,
managedObjectContext: context,
sectionNameKeyPath: nil,
cacheName: nil
)
self.context = context
self.onCommitPendingProposals = onCommitPendingProposals
self.repository = repository
self.mlsService = mlsService
self.isMLSGroupBroken = isMLSGroupBroken
super.init()
}

/// Starts monitoring and triggers work for any conversations with commitPendingProposalDate not nil.
public func start() async {
fetchedResultsController.delegate = self
do {
try fetchedResultsController.performFetch()
} catch {
WireLogger.conversation
.error("error fetching conversations with pending commit proposals: \(String(describing: error))")
}

let conversations = fetchedResultsController.fetchedObjects ?? []
for conversation in conversations {
await context.perform {

Check warning on line 67 in WireDomain/Sources/WireDomain/Synchronization/CommitPendingProsalsGenerator.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'self' with non-Sendable type 'CommitPendingProposalsGenerator' in a '@Sendable' closure

Capture of 'self' with non-Sendable type 'CommitPendingProposalsGenerator' in a '@sendable' closure

Check warning on line 67 in WireDomain/Sources/WireDomain/Synchronization/CommitPendingProsalsGenerator.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
self.commitPendingProposalItem(for: conversation)
}
}
}

private func commitPendingProposalItem(for conversation: ZMConversation) {
if let id = conversation.qualifiedID,
let timestamp = conversation.commitPendingProposalDate,
let mlsGroupID = conversation.mlsGroupID,
conversation.isSelfAnActiveMember,
!isMLSGroupBroken(mlsGroupID) {

Check warning on line 79 in WireDomain/Sources/WireDomain/Synchronization/CommitPendingProsalsGenerator.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
Task {
await generateItemForSubconversation(
parentID: mlsGroupID,
timestamp: timestamp,
conversationID: id
)
}

WireLogger.workAgent.debug(
"generate commit pending proposal work-item",
attributes: [.mlsGroupID: mlsGroupID.safeForLoggingDescription]
)
onCommitPendingProposals(
CommitPendingProposalItem(
repository: repository,
conversationID: id,
groupID: mlsGroupID,
timestamp: timestamp,
mlsService: mlsService
)
)
}
}

func generateItemForSubconversation(
parentID: MLSGroupID,
timestamp: Date,
conversationID: QualifiedID
) async {

if let subgroupID = await mlsService.subConferenceConversation(
parentGroupID: parentID
) {
WireLogger.workAgent.debug(
"generate subconversation commit pending proposal work-item for \(parentID.safeForLoggingDescription)",
attributes: [.mlsGroupID: subgroupID.safeForLoggingDescription]
)
onCommitPendingProposals(
CommitPendingProposalItem(
repository: repository,
conversationID: conversationID,
groupID: subgroupID,
timestamp: timestamp,
mlsService: mlsService
)
)
}
}

public func stop() {
fetchedResultsController.delegate = nil
}
}

// MARK: - NSFetchedResultsControllerDelegate

extension CommitPendingProposalsGenerator: NSFetchedResultsControllerDelegate {

public func controller(
_ controller: NSFetchedResultsController<NSFetchRequestResult>,
didChange anObject: Any,
at indexPath: IndexPath?,
for type: NSFetchedResultsChangeType,
newIndexPath: IndexPath?
) {
guard let conversation = anObject as? ZMConversation else {
fatal("unexpected object, expected ZMConversation")
}

switch type {
case .insert:
commitPendingProposalItem(for: conversation)

case .update:
break

case .move, .delete:
break

@unknown default:
break
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
import WireDataModel
import WireLogging

/// sourcery: AutoMockable
public protocol ConversationUpdatesGeneratorProtocol {
func start() async
func stop()
}

public final class ConversationUpdatesGenerator: NSObject, ConversationUpdatesGeneratorProtocol {
public final class ConversationUpdatesGenerator: NSObject, IncrementalGeneratorProtocol {

private let context: NSManagedObjectContext
private var fetchedResultsController: NSFetchedResultsController<ZMConversation>?
Expand Down Expand Up @@ -58,8 +52,8 @@

let conversations = fetchedResultsController?.fetchedObjects ?? []
for conversation in conversations {
await context.perform {

Check warning on line 55 in WireDomain/Sources/WireDomain/Synchronization/ConversationUpdatesGenerator.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@Sendable' closure

Capture of 'conversation' with non-Sendable type 'ZMConversation' in a '@sendable' closure
if let id = conversation.qualifiedID {

Check warning on line 56 in WireDomain/Sources/WireDomain/Synchronization/ConversationUpdatesGenerator.swift

View workflow job for this annotation

GitHub Actions / Test Results

Capture of 'self' with non-Sendable type 'ConversationUpdatesGenerator' in a '@Sendable' closure

Capture of 'self' with non-Sendable type 'ConversationUpdatesGenerator' in a '@sendable' closure
self.onConversationUpdated(UpdateConversationItem(
repository: self.repository,
conversationID: id.toAPIModel()
Expand Down
Loading
Loading