-
Notifications
You must be signed in to change notification settings - Fork 24
chore: separate user properties isApp and isBot - WPB-21441 #3970
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
Changes from 19 commits
8a58ae1
7c658d7
a32c61c
33ab6b6
86e95a5
291ff43
6234722
9b55828
deabb1e
b2d6409
5a90951
4f2fd2d
b2230d5
59edd7c
bdb435e
bab57b6
a67301a
9340106
edb5c09
f92bcd5
82076c5
5f4aba5
cf7e241
104ec35
375a366
4b0b73d
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 |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |
|
|
||
| import CoreData | ||
| import GenericMessageProtocol | ||
| import WireCryptobox | ||
|
Check warning on line 21 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| import WireDataModel | ||
| import WireLogging | ||
|
|
||
|
|
@@ -71,7 +71,7 @@ | |
|
|
||
| return await context.perform { [context] in | ||
| ZMOTRMessage.fetch( | ||
| withNonce: id, | ||
|
Check warning on line 74 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| for: conversation, | ||
| in: context | ||
| ) | ||
|
|
@@ -86,7 +86,7 @@ | |
| ZMUser.selfUser(in: context) | ||
| } | ||
|
|
||
| return await context.perform { | ||
|
Check warning on line 89 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| text.mentions.any { $0.userID.uppercased() == selfUser.remoteIdentifier.uuidString } | ||
| } | ||
| } | ||
|
|
@@ -94,7 +94,7 @@ | |
| public func isMessageQuotingSelf( | ||
| quotedMessage: ZMOTRMessage? | ||
| ) async -> Bool { | ||
| await context.perform { | ||
|
Check warning on line 97 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| quotedMessage?.sender?.isSelfUser ?? false | ||
| } | ||
| } | ||
|
|
@@ -150,8 +150,8 @@ | |
| ZMUser.selfUser(in: context) | ||
| } | ||
|
|
||
| return await context.perform { | ||
|
Check warning on line 153 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| let isSelf = conversation.isSelfConversation && senderID != selfUser.remoteIdentifier | ||
|
Check warning on line 154 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| return !isSelf && !conversation.isForcedReadOnly | ||
| } | ||
| } | ||
|
|
@@ -200,13 +200,13 @@ | |
| ) async { | ||
| await context.perform { [self] in | ||
| if isNewMessage { | ||
| do { | ||
|
Check warning on line 203 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| try clientMessage.setUnderlyingMessage(genericMessage) | ||
| clientMessage.updateNormalizedText() | ||
| } catch { | ||
| assertionFailure("Failed to set generic message: \(error.localizedDescription)") | ||
| } | ||
| } else { | ||
|
Check warning on line 209 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| applyLinkPreviewUpdate( | ||
| clientMessage: clientMessage, | ||
| updatedMessage: genericMessage, | ||
|
|
@@ -217,7 +217,7 @@ | |
| finalizeMessageUpdate( | ||
| message: clientMessage, | ||
| senderID: senderID, | ||
| senderDomain: senderDomain, | ||
|
Check warning on line 220 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| conversation: conversation | ||
| ) | ||
| } | ||
|
|
@@ -232,7 +232,7 @@ | |
| senderDomain: String | ||
| ) async { | ||
| await context.perform { [self] in | ||
| do { | ||
|
Check warning on line 235 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| try assetClientMessage.setUnderlyingMessage(genericMessage) | ||
| } catch { | ||
| return assertionFailure( | ||
|
|
@@ -242,7 +242,7 @@ | |
|
|
||
| // We assume received assets are V3 since backend no longer supports sending V2 assets. | ||
| assetClientMessage.version = 3 | ||
|
|
||
|
Check warning on line 245 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| assetTransferStateResolver.resolveTransferState( | ||
| assetMessage: assetClientMessage, | ||
| genericMessage: genericMessage, | ||
|
|
@@ -252,7 +252,7 @@ | |
| finalizeMessageUpdate( | ||
| message: assetClientMessage, | ||
| senderID: senderID, | ||
| senderDomain: senderDomain, | ||
|
Check warning on line 255 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| conversation: conversation | ||
| ) | ||
| } | ||
|
|
@@ -270,7 +270,7 @@ | |
| await context.perform { [self] in | ||
| guard let conversation = ZMConversation.fetch( | ||
| with: conversationID, | ||
| domain: conversationDomain, | ||
|
Check warning on line 273 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| in: context | ||
| ) else { return } | ||
|
|
||
|
|
@@ -294,7 +294,7 @@ | |
| _ hiddenMessage: MessageHide, | ||
| in conversation: ZMConversation | ||
| ) async { | ||
| await context.perform { [context] in | ||
|
Check warning on line 297 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| guard conversation.isSelfConversation else { | ||
| return | ||
| } | ||
|
|
@@ -313,7 +313,7 @@ | |
| ) async { | ||
| await context.perform { [context] in | ||
| ZMMessage.remove( | ||
| remotelyDeletedMessage: deletedMessage, | ||
|
Check warning on line 316 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| inConversation: conversation, | ||
| senderID: senderID, | ||
| inContext: context | ||
|
|
@@ -330,7 +330,7 @@ | |
| await context.perform { [context] in | ||
| ZMMessage.add( | ||
| reaction: messageReaction, | ||
| senderID: senderID, | ||
|
Check warning on line 333 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| conversation: conversation, | ||
| creationDate: date, | ||
| inContext: context | ||
|
|
@@ -347,7 +347,7 @@ | |
| ) async { | ||
| await context.perform { | ||
| _ = ZMMessageConfirmation.createMessageConfirmations( | ||
| confirmation, | ||
|
Check warning on line 350 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| conversation: conversation, | ||
| senderUUID: senderID, | ||
| senderDomain: senderDomain, | ||
|
|
@@ -369,7 +369,7 @@ | |
|
|
||
| ZMClientMessage.updateButtonStates( | ||
| buttonID: buttonID, | ||
| referenceMessageID: referenceMessageID, | ||
|
Check warning on line 372 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| for: conversation, | ||
| in: context | ||
| ) | ||
|
|
@@ -391,8 +391,8 @@ | |
|
|
||
| await context.perform { [self] in | ||
| guard let editedClientMessage = ZMClientMessage.fetch( | ||
| withNonce: editedMessageID, | ||
|
Check warning on line 394 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| for: conversation, | ||
|
Check warning on line 395 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| in: context | ||
| ) else { | ||
| return | ||
|
|
@@ -423,7 +423,7 @@ | |
| date: Date | ||
| ) async throws -> (ZMOTRMessage, isNew: Bool) { | ||
| try await context.perform { [self] in | ||
|
|
||
|
Check warning on line 426 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| if let clearedTime = conversation.clearedTimeStamp, clearedTime.compare(date) != .orderedAscending { | ||
| throw Failure.invalidInsertion(reason: "message is older than cleared time") | ||
| } | ||
|
|
@@ -439,7 +439,7 @@ | |
| let clientMessage = messageType == .asset ? | ||
| ZMAssetClientMessage.fetch( | ||
| withNonce: nonce, | ||
| for: conversation, | ||
|
Check warning on line 442 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| in: context | ||
| ) : | ||
| ZMClientMessage.fetch( | ||
|
|
@@ -532,7 +532,7 @@ | |
| case let .participantsRemovedAnonymously(participants, date): | ||
|
|
||
| let removedUsers = await context.perform { | ||
| participants.compactMap { id, domain in | ||
|
Check warning on line 535 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| let existing = conversation.localParticipants | ||
|
|
||
| return existing.first(where: { | ||
|
|
@@ -556,7 +556,7 @@ | |
| case let .participantsRemoved(participants, sender, date): | ||
|
|
||
| let removedUsers = await context.perform { | ||
| participants.compactMap { id, domain in | ||
|
Check warning on line 559 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| let existing = conversation.localParticipants | ||
|
|
||
| return existing.first(where: { | ||
|
|
@@ -658,7 +658,7 @@ | |
| let selfUser = await fetchSelfUser() | ||
|
|
||
| let (creator, localParticipants, userDefinedName) = await context.perform { | ||
| ( | ||
|
Check warning on line 661 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| conversation.creator, | ||
| conversation.localParticipants, | ||
| conversation.userDefinedName | ||
|
|
@@ -672,22 +672,22 @@ | |
| timestamp: date | ||
| ) | ||
|
|
||
| await context.perform { | ||
|
Check warning on line 675 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| newConversationMessage.text = userDefinedName | ||
|
|
||
|
Check warning on line 677 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| guard let selfUserTeam = selfUser.team, | ||
|
Check warning on line 678 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| conversation.team == selfUserTeam else { return } | ||
|
|
||
| let members = selfUserTeam.members.compactMap(\.user) | ||
|
Check warning on line 681 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| let guests = localParticipants.filter { | ||
| !$0.isApp && $0.membership == nil | ||
| !$0.isAppOrBot && $0.membership == nil | ||
| } | ||
|
|
||
| newConversationMessage.allTeamUsersAdded = localParticipants.isSuperset(of: members) | ||
| newConversationMessage.numberOfGuestsAdded = Int16(guests.count) | ||
| } | ||
|
|
||
| let hasReadReceiptsEnabled = await context.perform { | ||
|
Check warning on line 690 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| conversation.hasReadReceiptsEnabled | ||
| } | ||
|
|
||
|
|
@@ -738,11 +738,11 @@ | |
| timestamp: date | ||
| ) | ||
|
|
||
| let previousLastMessage = await context.perform { | ||
|
Check warning on line 741 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| conversation.lastMessage | ||
| } | ||
|
|
||
| await context.perform { [context] in | ||
|
Check warning on line 745 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| let lastMessage = previousLastMessage as? ZMSystemMessage | ||
| let isPotentialGapMigration = lastMessage?.systemMessageType == .mlsMigrationPotentialGap | ||
| let lastMessageTimestamp = lastMessage?.serverTimestamp | ||
|
|
@@ -775,7 +775,7 @@ | |
|
|
||
| case let .receiptModeIsOn(date): | ||
|
|
||
| let creator = await context.perform { | ||
|
Check warning on line 778 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| conversation.creator | ||
| } | ||
|
|
||
|
|
@@ -827,7 +827,7 @@ | |
| return [] | ||
| } | ||
|
|
||
| let senderClient = await context.perform { | ||
|
Check warning on line 830 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| sender.clients.first(where: { | ||
| $0.remoteIdentifier == senderClientID | ||
| }) | ||
|
|
@@ -858,7 +858,7 @@ | |
|
|
||
| let client = await context.perform { | ||
| UserClient.fetchUserClient( | ||
| withRemoteId: senderClientID, | ||
|
Check warning on line 861 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| forUser: sender, | ||
| createIfNeeded: true | ||
| ) | ||
|
|
@@ -910,8 +910,8 @@ | |
| timestamp: date | ||
| ) | ||
|
|
||
| await context.perform { | ||
|
Check warning on line 913 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| systemMessage.text = newName | ||
|
Check warning on line 914 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| systemMessage.visibleInConversation = conversation | ||
| conversation.updateTimestampsAfterUpdatingMessage(systemMessage) | ||
| } | ||
|
|
@@ -932,7 +932,7 @@ | |
| timestamp: date | ||
| ) | ||
|
|
||
| await context.perform { | ||
|
Check warning on line 935 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| let isArchived = conversation.isArchived | ||
| let mutedMessageTypes = conversation.mutedMessageTypes | ||
|
|
||
|
|
@@ -976,10 +976,10 @@ | |
| ) async -> ZMSystemMessage { | ||
| await context.perform { [context] in | ||
| let systemMessage = ZMSystemMessage(nonce: UUID(), managedObjectContext: context) | ||
| systemMessage.systemMessageType = messageType | ||
|
Check warning on line 979 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| systemMessage.sender = sender | ||
|
Check warning on line 980 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| systemMessage.users = users ?? Set() | ||
|
Check warning on line 981 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| systemMessage.addedUsers = addedUsers | ||
|
Check warning on line 982 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| systemMessage.clients = clients ?? Set() | ||
| systemMessage.serverTimestamp = timestamp | ||
| systemMessage.text = text | ||
|
|
@@ -1004,8 +1004,8 @@ | |
| _ messages: Set<ZMSystemMessage>, | ||
| to conversation: ZMConversation | ||
| ) async { | ||
| await context.perform { | ||
|
Check warning on line 1007 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| for message in messages { | ||
|
Check warning on line 1008 in WireDomain/Sources/WireDomain/Repositories/Message/MessageLocalStore.swift
|
||
| conversation.append(message) | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,7 @@ | |
| } | ||
| } | ||
|
|
||
| @objc | ||
| @objc(ZMContextProvider) | ||
| public protocol ContextProvider { | ||
|
|
||
| var account: Account { get } | ||
|
|
@@ -114,8 +114,8 @@ | |
|
|
||
| } | ||
|
|
||
| @objcMembers | ||
| public class CoreDataStack: NSObject, CoreDataStackProtocol { | ||
| @objc @objcMembers | ||
| public class CoreDataStack: NSObject, CoreDataStackProtocol, ContextProvider { | ||
|
|
||
| public let account: Account | ||
|
|
||
|
|
@@ -369,7 +369,7 @@ | |
|
|
||
| func configureViewContext(_ context: NSManagedObjectContext) async { | ||
| context.markAsUIContext() | ||
| await context.perform { | ||
|
Check warning on line 372 in wire-ios-data-model/Source/ManagedObjectContext/CoreDataStack.swift
|
||
| context.localDomain = self.localDomain | ||
| context.isFederationEnabled = self.isFederationEnabled | ||
| context.createDispatchGroups() | ||
|
|
@@ -381,17 +381,17 @@ | |
| } | ||
|
|
||
| func configureContextReferences() async { | ||
| await viewContext.perform { | ||
|
Check warning on line 384 in wire-ios-data-model/Source/ManagedObjectContext/CoreDataStack.swift
|
||
| self.viewContext.zm_sync = self.syncContext | ||
| } | ||
| await syncContext.perform { | ||
|
Check warning on line 387 in wire-ios-data-model/Source/ManagedObjectContext/CoreDataStack.swift
|
||
| self.syncContext.zm_userInterface = self.viewContext | ||
| } | ||
| } | ||
|
|
||
| func configureSyncContext(_ context: NSManagedObjectContext) async { | ||
| context.markAsSyncContext() | ||
| await context.perform { | ||
|
Check warning on line 394 in wire-ios-data-model/Source/ManagedObjectContext/CoreDataStack.swift
|
||
| context.localDomain = self.localDomain | ||
| context.isFederationEnabled = self.isFederationEnabled | ||
| context.createDispatchGroups() | ||
|
|
@@ -417,7 +417,7 @@ | |
|
|
||
| func configureSearchContext(_ context: NSManagedObjectContext) async { | ||
| context.markAsSearch() | ||
| await context.perform { | ||
|
Check warning on line 420 in wire-ios-data-model/Source/ManagedObjectContext/CoreDataStack.swift
|
||
| context.localDomain = self.localDomain | ||
| context.isFederationEnabled = self.isFederationEnabled | ||
| context.createDispatchGroups() | ||
|
|
@@ -430,7 +430,7 @@ | |
|
|
||
| func configureEventContext(_ context: NSManagedObjectContext) async { | ||
| await context.perform { | ||
| context.createDispatchGroups() | ||
|
Check warning on line 433 in wire-ios-data-model/Source/ManagedObjectContext/CoreDataStack.swift
|
||
| self.dispatchGroup.map(context.addGroup(_:)) | ||
| } | ||
| } | ||
|
|
@@ -559,7 +559,7 @@ | |
| } | ||
|
|
||
| // MARK: - | ||
|
|
||
|
Check warning on line 562 in wire-ios-data-model/Source/ManagedObjectContext/CoreDataStack.swift
|
||
| public class PersistentContainer: NSPersistentContainer { | ||
|
|
||
| var storeURL: URL? { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,7 +147,7 @@ | |
| @property (nonatomic) ZMConversationSecurityLevel securityLevel; | ||
| @end | ||
|
|
||
|
|
||
|
Check warning on line 150 in wire-ios-data-model/Source/Model/Conversation/ZMConversation.m
|
||
| @implementation ZMConversation | ||
|
|
||
| @dynamic userDefinedName; | ||
|
|
@@ -393,7 +393,7 @@ | |
| return [NSSet setWithObjects:ZMConversationConversationTypeKey, ZMConversationParticipantRolesKey, ZMConversationIsForcedReadOnlyKey, nil]; | ||
| } | ||
|
|
||
| + (instancetype)existingOneOnOneConversationWithUser:(ZMUser *)otherUser inUserSession:(id<ContextProvider>)session; | ||
| + (instancetype)existingOneOnOneConversationWithUser:(ZMUser *)otherUser inUserSession:(id<ZMContextProvider>)session; | ||
| { | ||
| NOT_USED(session); | ||
| return otherUser.oneOnOneConversation; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -155,7 +155,7 @@ | |
| @end | ||
|
|
||
|
|
||
|
|
||
|
Check warning on line 158 in wire-ios-data-model/Source/Model/User/ZMUser.m
|
||
| @implementation ZMUser | ||
|
|
||
| + (NSSet<NSString *> *)keyPathsForValuesAffectingIsApp | ||
|
|
@@ -163,6 +163,16 @@ | |
| return [NSSet setWithObjects:TypeKey, nil]; | ||
| } | ||
|
|
||
| + (NSSet<NSString *> *)keyPathsForValuesAffectingIsBot | ||
| { | ||
| return [NSSet setWithObjects:TypeKey, nil]; | ||
| } | ||
|
|
||
| + (NSSet<NSString *> *)keyPathsForValuesAffectingIsAppOrBot | ||
| { | ||
| return [NSSet setWithObjects:TypeKey, nil]; | ||
| } | ||
|
|
||
| - (BOOL)isSelfUser | ||
| { | ||
| if ([self isZombieObject]) { | ||
|
|
@@ -239,7 +249,7 @@ | |
|
|
||
| - (BOOL)canBeConnected; | ||
| { | ||
| if (self.isApp || self.isWirelessUser) { | ||
| if (self.isAppOrBot || self.isWirelessUser) { | ||
| return NO; | ||
| } | ||
| return ! self.isConnected && ! self.isPendingApprovalByOtherUser; | ||
|
|
@@ -710,7 +720,7 @@ | |
|
|
||
| @implementation ZMUser (Utilities) | ||
|
|
||
| + (ZMUser<ZMEditableUserType> *)selfUserInUserSession:(id<ContextProvider>)session | ||
| + (ZMUser<ZMEditableUserType> *)selfUserInUserSession:(id<ZMContextProvider>)session | ||
| { | ||
| VerifyReturnNil(session != nil); | ||
| return [self selfUserInContext:session.viewContext]; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.