-
Notifications
You must be signed in to change notification settings - Fork 25
fix: schedule commit pending proposals - WPB-22062 #3963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/cycle-4.12
Are you sure you want to change the base?
Changes from 11 commits
5124f83
475cee0
83399b2
9d99c92
b1e6af5
afc5ab8
534fdd6
671632e
57cb852
36c5e90
6601da4
21bff1e
8e3f91f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
|
||
| conversation.qualifiedID | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| guard conversation.isSelfConversation else { | ||
| return | ||
| } | ||
|
|
@@ -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
|
||
| guard conversation.isSelfConversation else { | ||
| return | ||
| } | ||
|
|
@@ -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
|
||
| guard let mlsGroupID = conversation.mlsGroupID else { | ||
| return nil | ||
| } | ||
|
|
@@ -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
|
||
| conversation.mlsStatus = .ready | ||
| conversation.mlsGroupID = mlsGroupID | ||
| } | ||
|
|
@@ -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
|
||
| conversation.mlsStatus = .pendingJoinAfterReset | ||
| conversation.mlsGroupID = newMLSGroupID | ||
| } | ||
|
|
@@ -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
|
||
| guard conversation.conversationType == .oneOnOne else { | ||
| WireLogger.conversation.info( | ||
| "conversation type is not expected 'oneOnOne', aborting." | ||
|
|
@@ -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
|
||
| let otherUserDomain = otherUser.domain ?? self.localDomain | ||
| else { | ||
| WireLogger.conversation.warn( | ||
|
|
@@ -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
|
||
| localConversation.updateMutedStatus( | ||
| status: Int32(mutedStatus), | ||
| referenceDate: mutedReference | ||
|
|
@@ -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
|
||
| conversation.addParticipantAndUpdateConversationState( | ||
|
Check warning on line 240 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| user: user, | ||
|
Check warning on line 241 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| role: role | ||
| ) | ||
| } | ||
|
|
@@ -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
|
||
| conversation.internalEstimatedUnreadCount += 1 | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.internalEstimatedUnreadCount -= 1 | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.internalEstimatedUnreadSelfMentionCount += 1 | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.internalEstimatedUnreadSelfReplyCount += 1 | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.privateChannelPermission = PrivateChannelPermission(permission) | ||
| } | ||
| } | ||
|
|
@@ -301,7 +301,7 @@ | |
| domain: conversationDomain | ||
| ) | ||
|
|
||
| await context.perform { | ||
|
Check warning on line 304 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| conversation?.channelHistoryDepth = historyDepth | ||
| } | ||
| } | ||
|
|
@@ -333,9 +333,9 @@ | |
| ] | ||
| ) | ||
| } | ||
|
|
||
|
Check warning on line 336 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| 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
|
||
| taskGroup.addTask { [self] in | ||
| let user = await context.perform { [context] in | ||
| ZMUser.fetchOrCreate( | ||
|
|
@@ -359,7 +359,7 @@ | |
| } | ||
|
|
||
| var usersAndRoles: [UserAndRole?] = [] | ||
|
|
||
|
Check warning on line 362 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| for await userAndRole in taskGroup { | ||
| usersAndRoles.append(userAndRole) | ||
| } | ||
|
|
@@ -388,8 +388,8 @@ | |
| ) | ||
| } | ||
|
|
||
| await context.perform { | ||
|
Check warning on line 391 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| localConversation.addParticipantsAndUpdateConversationState( | ||
|
Check warning on line 392 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| usersAndRoles: usersAndRoles | ||
| ) | ||
| } | ||
|
|
@@ -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
|
||
| if user.objectID.isTemporaryID || conversation.objectID.isTemporaryID { | ||
| do { | ||
| try context.obtainPermanentIDs(for: [user, conversation]) | ||
|
|
@@ -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
|
||
| systemMessage.systemMessageType = message.type | ||
| systemMessage.sender = message.sender | ||
| systemMessage.users = message.users ?? Set() | ||
|
|
@@ -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
|
||
| conversation.append(systemMessage) | ||
| } | ||
| } | ||
|
|
@@ -534,7 +534,7 @@ | |
| domain: conversationDomain | ||
| ) | ||
|
|
||
| await context.perform { | ||
|
Check warning on line 537 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| conversation.isPendingMetadataRefresh = true | ||
| conversation.needsToBeUpdatedFromBackend = true | ||
| } | ||
|
|
@@ -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
|
||
| conversation.needsToBeUpdatedFromBackend | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.isArchived | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.isForcedReadOnly | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.isMessageSilenced(message, senderID: senderID) | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.commitPendingProposalDate = scheduledDate | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.updateSecurityLevelIfNeededAfterReceiving( | ||
| message: genericMessage, | ||
| timestamp: date | ||
|
|
@@ -660,8 +660,8 @@ | |
| return | ||
| } | ||
|
|
||
| await context.perform { | ||
|
Check warning on line 663 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| conversation.addParticipantAndSystemMessageIfMissing( | ||
|
Check warning on line 664 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| participant, | ||
| date: date | ||
| ) | ||
|
|
@@ -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
|
||
| conversation.mutedMessageTypes | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| return selfUser.mutedMessagesTypes.union(conversation.mutedMessageTypes) | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.lastReadServerTimeStamp | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.activeMessageDestructionTimeoutValue ?? .init(rawValue: 0) | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.setMessageDestructionTimeoutValue( | ||
| .init(rawValue: timeoutValue), | ||
| for: .groupConversation | ||
|
|
@@ -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
|
||
| conversation.hasReadReceiptsEnabled = hasReadReceiptsEnabled | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.messageProtocol | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| 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
|
||
| conversation.conversationType == .self | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.displayName | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| let allGroupConversations: [ZMConversation] = user.participantRoles.compactMap { | ||
| guard $0.conversation?.conversationType == .group else { | ||
| return nil | ||
|
|
@@ -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
|
||
| user.team, | ||
| user.isTeamMember, | ||
|
Check warning on line 786 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| conversation.team, | ||
| conversation.remoteIdentifier as UUID, | ||
| conversation.domain | ||
|
|
@@ -818,8 +818,8 @@ | |
| ) | ||
| } | ||
|
|
||
| await context.perform { | ||
|
Check warning on line 821 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| conversation.removeParticipantAndUpdateConversationState( | ||
|
Check warning on line 822 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| user: user, | ||
| initiatingUser: user | ||
| ) | ||
|
|
@@ -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
|
||
| teamOrConversation: TeamOrConversation.matching(conversation), | ||
| in: context | ||
| ) | ||
|
|
@@ -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
|
||
| conversation.accessModeStrings = accessModes | ||
| conversation.accessRoleStringsV2 = accessRoles | ||
|
|
||
|
|
@@ -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
|
||
| conversation.isDeletedRemotely = isDeletedRemotely | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.removeParticipantsAndUpdateConversationState( | ||
|
Check warning on line 882 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| users: users, | ||
|
Check warning on line 883 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| initiatingUser: initiatingUser | ||
| ) | ||
| } | ||
|
|
@@ -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
|
||
| conversation.localParticipants | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.userDefinedName | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| conversation.userDefinedName = newName | ||
| } | ||
| } | ||
|
|
@@ -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
|
||
| localConversation.conversationType = .connection | ||
|
|
||
|
Check warning on line 951 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| commonUpdate( | ||
|
Check warning on line 952 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| from: conversation, | ||
| for: localConversation, | ||
| serverTimestamp: serverTimestamp, | ||
|
|
@@ -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
|
||
| conversation.mlsGroupID | ||
| } | ||
|
|
||
| await context.perform { [self] in | ||
|
Check warning on line 1010 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| localConversation.conversationType = .`self` | ||
| localConversation.isPendingMetadataRefresh = false | ||
|
|
||
|
Check warning on line 1013 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| commonUpdate( | ||
|
Check warning on line 1014 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| from: conversation, | ||
| for: localConversation, | ||
| serverTimestamp: serverTimestamp, | ||
|
|
@@ -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
|
||
| 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
|
||
| localConversation.groupType = conversation.groupType.map { groupType in | ||
| switch groupType { | ||
| case .group: | ||
|
|
@@ -1089,7 +1089,7 @@ | |
| .disabled | ||
| } | ||
| } ?? .disabled | ||
|
|
||
|
Check warning on line 1092 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| commonUpdate( | ||
| from: conversation, | ||
| for: localConversation, | ||
|
|
@@ -1102,7 +1102,7 @@ | |
| from: conversation, | ||
| for: localConversation | ||
| ) | ||
|
|
||
|
Check warning on line 1105 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| if isInitialFetch { | ||
| assignMessageProtocol( | ||
| from: conversation, | ||
|
|
@@ -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
|
||
| 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
|
||
| localConversation.appendNewConversationSystemMessage( | ||
| at: .distantPast, | ||
| users: localConversation.localParticipants | ||
|
|
@@ -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
|
||
| linkOneOnOneUserIfNeeded(for: localConversation) | ||
|
|
||
| // All metadata has been updated, object does not need to be updated from backend | ||
|
|
@@ -1189,14 +1189,14 @@ | |
| let conversationType = BackendConversationType.clientConversationType( | ||
| rawValue: conversationTypeRawValue | ||
| ) | ||
|
|
||
|
Check warning on line 1192 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| 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
|
||
| assignMessageProtocol( | ||
|
Check warning on line 1199 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| from: conversation, | ||
| for: localConversation | ||
| ) | ||
|
|
@@ -1297,11 +1297,20 @@ | |
| domain: conversationDomain | ||
| ) | ||
|
|
||
| return await context.perform { | ||
|
Check warning on line 1300 in WireDomain/Sources/WireDomain/Repositories/Conversations/LocalStore/ConversationLocalStore.swift
|
||
| 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 | ||
|
|
||
| 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
|
||
| 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
|
||
| 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 |
|---|---|---|
|
|
@@ -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>? | ||
|
|
@@ -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
|
||
| if let id = conversation.qualifiedID { | ||
|
Check warning on line 56 in WireDomain/Sources/WireDomain/Synchronization/ConversationUpdatesGenerator.swift
|
||
| self.onConversationUpdated(UpdateConversationItem( | ||
| repository: self.repository, | ||
| conversationID: id.toAPIModel() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.