From a098ba7125dd0d0fd66caf963c7e239aac6cd947 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Wed, 5 May 2021 12:13:48 +1000 Subject: [PATCH] Remove unused code --- Session.xcodeproj/project.pbxproj | 20 -- Session/Conversations/ConversationViewItem.m | 5 - Session/Conversations/ConversationViewModel.m | 2 - Session/Meta/Signal-Bridging-Header.h | 1 - Session/Notifications/AppNotifications.swift | 44 ---- .../Messages/Signal/TSErrorMessage.h | 76 ------ .../Messages/Signal/TSErrorMessage.m | 219 ------------------ .../TSErrorMessage_privateConstructor.h | 19 -- .../Messages/Signal/TSInteraction.h | 1 - .../Messages/Signal/TSInteraction.m | 2 - .../Meta/SessionMessagingKit.h | 3 - .../Notifications/NotificationsProtocol.h | 7 - .../Read Tracking/OWSReadReceiptManager.h | 19 -- .../Read Tracking/OWSReadTracking.h | 1 - .../TSUnreadIndicatorInteraction.h | 16 -- .../TSUnreadIndicatorInteraction.m | 38 --- .../Typing Indicators/TypingIndicators.swift | 5 +- SessionMessagingKit/Threads/TSThread.m | 9 - .../Utilities/OWSIdentityManager.m | 1 - .../Utilities/NoopNotificationsManager.swift | 8 - SignalUtilitiesKit/Utilities/ThreadUtil.m | 21 +- 21 files changed, 4 insertions(+), 513 deletions(-) delete mode 100644 SessionMessagingKit/Messages/Signal/TSErrorMessage.h delete mode 100644 SessionMessagingKit/Messages/Signal/TSErrorMessage.m delete mode 100644 SessionMessagingKit/Messages/Signal/TSErrorMessage_privateConstructor.h delete mode 100644 SessionMessagingKit/Sending & Receiving/Read Tracking/TSUnreadIndicatorInteraction.h delete mode 100644 SessionMessagingKit/Sending & Receiving/Read Tracking/TSUnreadIndicatorInteraction.m diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index a2c5841e8..9de8bbfba 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -378,8 +378,6 @@ C32C5D19256DD493003C73A2 /* OWSLinkPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = C33FDBA8255A581500E217F9 /* OWSLinkPreview.swift */; }; C32C5D23256DD4C0003C73A2 /* Mention.swift in Sources */ = {isa = PBXBuildFile; fileRef = C33FDA7E255A57FB00E217F9 /* Mention.swift */; }; C32C5D24256DD4C0003C73A2 /* MentionsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C33FDA81255A57FC00E217F9 /* MentionsManager.swift */; }; - C32C5D2E256DD4EA003C73A2 /* TSUnreadIndicatorInteraction.m in Sources */ = {isa = PBXBuildFile; fileRef = C38EF2C1255B6DA6007E1867 /* TSUnreadIndicatorInteraction.m */; }; - C32C5D37256DD4ED003C73A2 /* TSUnreadIndicatorInteraction.h in Headers */ = {isa = PBXBuildFile; fileRef = C38EF2BE255B6DA6007E1867 /* TSUnreadIndicatorInteraction.h */; settings = {ATTRIBUTES = (Public, ); }; }; C32C5D83256DD5B6003C73A2 /* SSKKeychainStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C33FDBBC255A581600E217F9 /* SSKKeychainStorage.swift */; }; C32C5D9C256DD6DC003C73A2 /* OWSOutgoingReceiptManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C33FDB6F255A580F00E217F9 /* OWSOutgoingReceiptManager.m */; }; C32C5DA5256DD6E5003C73A2 /* OWSOutgoingReceiptManager.h in Headers */ = {isa = PBXBuildFile; fileRef = C33FDABD255A580100E217F9 /* OWSOutgoingReceiptManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -405,9 +403,6 @@ C32C5EEE256DF54E003C73A2 /* TSDatabaseView.m in Sources */ = {isa = PBXBuildFile; fileRef = C33FDB46255A580C00E217F9 /* TSDatabaseView.m */; }; C32C5EF7256DF567003C73A2 /* TSDatabaseView.h in Headers */ = {isa = PBXBuildFile; fileRef = C33FDB2C255A580A00E217F9 /* TSDatabaseView.h */; settings = {ATTRIBUTES = (Public, ); }; }; C32C5F11256DF79A003C73A2 /* SSKIncrementingIdFinder.swift in Sources */ = {isa = PBXBuildFile; fileRef = C33FDB32255A580A00E217F9 /* SSKIncrementingIdFinder.swift */; }; - C32C5F1A256DFCAD003C73A2 /* TSErrorMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = C33FDAE7255A580500E217F9 /* TSErrorMessage.m */; }; - C32C5F23256DFCC0003C73A2 /* TSErrorMessage_privateConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = C33FDB5D255A580E00E217F9 /* TSErrorMessage_privateConstructor.h */; settings = {ATTRIBUTES = (Public, ); }; }; - C32C5F34256DFCC4003C73A2 /* TSErrorMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = C33FDBB0255A581500E217F9 /* TSErrorMessage.h */; settings = {ATTRIBUTES = (Public, ); }; }; C32C5FA1256DFED5003C73A2 /* NSArray+Functional.m in Sources */ = {isa = PBXBuildFile; fileRef = C33FDAB8255A580100E217F9 /* NSArray+Functional.m */; }; C32C5FAA256DFED9003C73A2 /* NSArray+Functional.h in Headers */ = {isa = PBXBuildFile; fileRef = C33FDB5C255A580E00E217F9 /* NSArray+Functional.h */; settings = {ATTRIBUTES = (Public, ); }; }; C32C5FBB256E0206003C73A2 /* OWSBackgroundTask.m in Sources */ = {isa = PBXBuildFile; fileRef = C33FDC1B255A581F00E217F9 /* OWSBackgroundTask.m */; }; @@ -1362,7 +1357,6 @@ C33FDAE1255A580400E217F9 /* OWSReadTracking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSReadTracking.h; sourceTree = ""; }; C33FDAE4255A580400E217F9 /* TSAttachmentStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSAttachmentStream.h; sourceTree = ""; }; C33FDAE6255A580400E217F9 /* TSInteraction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSInteraction.h; sourceTree = ""; }; - C33FDAE7255A580500E217F9 /* TSErrorMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSErrorMessage.m; sourceTree = ""; }; C33FDAE8255A580500E217F9 /* OWSMessageUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSMessageUtils.h; sourceTree = ""; }; C33FDAEA255A580500E217F9 /* OWSBackupFragment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSBackupFragment.h; sourceTree = ""; }; C33FDAEC255A580500E217F9 /* SignalRecipient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SignalRecipient.h; sourceTree = ""; }; @@ -1413,7 +1407,6 @@ C33FDB59255A580E00E217F9 /* OWSFailedAttachmentDownloadsJob.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSFailedAttachmentDownloadsJob.m; sourceTree = ""; }; C33FDB5B255A580E00E217F9 /* YapDatabaseTransaction+OWS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "YapDatabaseTransaction+OWS.m"; sourceTree = ""; }; C33FDB5C255A580E00E217F9 /* NSArray+Functional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+Functional.h"; sourceTree = ""; }; - C33FDB5D255A580E00E217F9 /* TSErrorMessage_privateConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSErrorMessage_privateConstructor.h; sourceTree = ""; }; C33FDB5F255A580E00E217F9 /* YapDatabaseConnection+OWS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "YapDatabaseConnection+OWS.h"; sourceTree = ""; }; C33FDB60255A580E00E217F9 /* TSMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSMessage.m; sourceTree = ""; }; C33FDB67255A580F00E217F9 /* OWSMediaGalleryFinder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSMediaGalleryFinder.h; sourceTree = ""; }; @@ -1448,7 +1441,6 @@ C33FDBA9255A581500E217F9 /* OWSIdentityManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSIdentityManager.m; sourceTree = ""; }; C33FDBAB255A581500E217F9 /* OWSFileSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSFileSystem.h; sourceTree = ""; }; C33FDBAE255A581500E217F9 /* SignalAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SignalAccount.h; sourceTree = ""; }; - C33FDBB0255A581500E217F9 /* TSErrorMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSErrorMessage.h; sourceTree = ""; }; C33FDBB4255A581600E217F9 /* NSURLSessionDataTask+StatusCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURLSessionDataTask+StatusCode.m"; sourceTree = ""; }; C33FDBB6255A581600E217F9 /* DataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DataSource.m; sourceTree = ""; }; C33FDBB7255A581600E217F9 /* SignalRecipient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SignalRecipient.m; sourceTree = ""; }; @@ -1559,8 +1551,6 @@ C38EF2A4255B6D93007E1867 /* ProfilePictureView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProfilePictureView.swift; path = "SignalUtilitiesKit/Profile Pictures/ProfilePictureView.swift"; sourceTree = SOURCE_ROOT; }; C38EF2B1255B6D9C007E1867 /* UIViewController+Utilities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIViewController+Utilities.swift"; path = "SignalUtilitiesKit/Utilities/UIViewController+Utilities.swift"; sourceTree = SOURCE_ROOT; }; C38EF2B2255B6D9C007E1867 /* UIView+Utilities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIView+Utilities.swift"; path = "SignalUtilitiesKit/Utilities/UIView+Utilities.swift"; sourceTree = SOURCE_ROOT; }; - C38EF2BE255B6DA6007E1867 /* TSUnreadIndicatorInteraction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TSUnreadIndicatorInteraction.h; path = "SessionMessagingKit/Sending & Receiving/Read Tracking/TSUnreadIndicatorInteraction.h"; sourceTree = SOURCE_ROOT; }; - C38EF2C1255B6DA6007E1867 /* TSUnreadIndicatorInteraction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TSUnreadIndicatorInteraction.m; path = "SessionMessagingKit/Sending & Receiving/Read Tracking/TSUnreadIndicatorInteraction.m"; sourceTree = SOURCE_ROOT; }; C38EF2CF255B6DAE007E1867 /* OWSProfileManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSProfileManager.m; path = "SignalUtilitiesKit/To Do/OWSProfileManager.m"; sourceTree = SOURCE_ROOT; }; C38EF2D1255B6DAF007E1867 /* OWSUserProfile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSUserProfile.m; path = "SessionMessagingKit/To Do/OWSUserProfile.m"; sourceTree = SOURCE_ROOT; }; C38EF2D2255B6DAF007E1867 /* OWSProfileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWSProfileManager.h; path = "SignalUtilitiesKit/To Do/OWSProfileManager.h"; sourceTree = SOURCE_ROOT; }; @@ -2548,9 +2538,6 @@ C32C5A99256DBDC1003C73A2 /* Signal */ = { isa = PBXGroup; children = ( - C33FDB5D255A580E00E217F9 /* TSErrorMessage_privateConstructor.h */, - C33FDBB0255A581500E217F9 /* TSErrorMessage.h */, - C33FDAE7255A580500E217F9 /* TSErrorMessage.m */, C33FDB9C255A581300E217F9 /* TSIncomingMessage.h */, C33FDA97255A57FE00E217F9 /* TSIncomingMessage.m */, C3B7845C25649DA600ADB2E7 /* TSIncomingMessage+Conversion.swift */, @@ -2576,8 +2563,6 @@ C33FDB1D255A580900E217F9 /* OWSReadReceiptManager.h */, C33FDA71255A57FA00E217F9 /* OWSReadReceiptManager.m */, C33FDAE1255A580400E217F9 /* OWSReadTracking.h */, - C38EF2BE255B6DA6007E1867 /* TSUnreadIndicatorInteraction.h */, - C38EF2C1255B6DA6007E1867 /* TSUnreadIndicatorInteraction.m */, ); path = "Read Tracking"; sourceTree = ""; @@ -3706,7 +3691,6 @@ C32C5EE5256DF506003C73A2 /* YapDatabaseConnection+OWS.h in Headers */, C32C5AAF256DBE8F003C73A2 /* TSMessage.h in Headers */, C32C5B8D256DC565003C73A2 /* SSKEnvironment.h in Headers */, - C32C5F34256DFCC4003C73A2 /* TSErrorMessage.h in Headers */, C32C59C6256DB41F003C73A2 /* TSGroupThread.h in Headers */, C3C2A6F425539DE700C340D1 /* SessionMessagingKit.h in Headers */, C32C59C2256DB41F003C73A2 /* TSContactThread.h in Headers */, @@ -3723,7 +3707,6 @@ C32C5AB3256DBE8F003C73A2 /* TSInteraction.h in Headers */, C32C5DA5256DD6E5003C73A2 /* OWSOutgoingReceiptManager.h in Headers */, C32C5B0A256DC076003C73A2 /* OWSDisappearingMessagesConfiguration.h in Headers */, - C32C5D37256DD4ED003C73A2 /* TSUnreadIndicatorInteraction.h in Headers */, C32C5ADF256DBFAA003C73A2 /* OWSReadTracking.h in Headers */, C3D9E486256775D20040E4F3 /* TSAttachmentPointer.h in Headers */, C32C5EF7256DF567003C73A2 /* TSDatabaseView.h in Headers */, @@ -3736,7 +3719,6 @@ B8856D72256F1421001CE70E /* OWSWindowManager.h in Headers */, B8AE761425ABFBB9001A84D2 /* GeneralUtilities.h in Headers */, C32C5B6B256DC357003C73A2 /* OWSDisappearingConfigurationUpdateInfoMessage.h in Headers */, - C32C5F23256DFCC0003C73A2 /* TSErrorMessage_privateConstructor.h in Headers */, C32C5BBA256DC7E3003C73A2 /* ProfileManagerProtocol.h in Headers */, C3A3A193256E20D4004D228D /* SignalRecipient.h in Headers */, B8856CF7256F105E001CE70E /* OWSAudioPlayer.h in Headers */, @@ -4774,7 +4756,6 @@ C32C5A02256DB658003C73A2 /* MessageSender+Convenience.swift in Sources */, B8566C6C256F60F50045A0B9 /* OWSUserProfile.m in Sources */, B8D0A25925E367AC00C1835E /* Notification+MessageReceiver.swift in Sources */, - C32C5D2E256DD4EA003C73A2 /* TSUnreadIndicatorInteraction.m in Sources */, C32C599E256DB02B003C73A2 /* TypingIndicators.swift in Sources */, C3DB66CC260AF1F3001EFC55 /* OpenGroupAPIV2+ObjC.swift in Sources */, C32C5BEF256DC8EE003C73A2 /* OWSDisappearingMessagesJob.m in Sources */, @@ -4822,7 +4803,6 @@ C32C5C88256DD0D2003C73A2 /* Storage+Messaging.swift in Sources */, C32C59C7256DB41F003C73A2 /* TSThread.m in Sources */, C300A5B22554AF9800555489 /* VisibleMessage+Profile.swift in Sources */, - C32C5F1A256DFCAD003C73A2 /* TSErrorMessage.m in Sources */, C32C5A75256DBBCF003C73A2 /* TSAttachmentPointer+Conversion.swift in Sources */, C32C5AF8256DC051003C73A2 /* OWSDisappearingMessagesConfiguration.m in Sources */, C32C5EBA256DE130003C73A2 /* OWSQuotedReplyModel.m in Sources */, diff --git a/Session/Conversations/ConversationViewItem.m b/Session/Conversations/ConversationViewItem.m index 633e94916..caccf4069 100644 --- a/Session/Conversations/ConversationViewItem.m +++ b/Session/Conversations/ConversationViewItem.m @@ -451,7 +451,6 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) case OWSInteractionType_Offer: case OWSInteractionType_TypingIndicator: return; - case OWSInteractionType_Error: case OWSInteractionType_Info: case OWSInteractionType_Call: self.systemMessageText = [self systemMessageTextWithTransaction:transaction]; @@ -651,10 +650,6 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) OWSAssertDebug(transaction); switch (self.interaction.interactionType) { - case OWSInteractionType_Error: { - TSErrorMessage *errorMessage = (TSErrorMessage *)self.interaction; - return [errorMessage previewTextWithTransaction:transaction]; - } case OWSInteractionType_Info: { TSInfoMessage *infoMessage = (TSInfoMessage *)self.interaction; return [infoMessage previewTextWithTransaction:transaction]; diff --git a/Session/Conversations/ConversationViewModel.m b/Session/Conversations/ConversationViewModel.m index 59651fa06..5ca40e558 100644 --- a/Session/Conversations/ConversationViewModel.m +++ b/Session/Conversations/ConversationViewModel.m @@ -1005,7 +1005,6 @@ NS_ASSUME_NONNULL_BEGIN case OWSInteractionType_IncomingMessage: case OWSInteractionType_OutgoingMessage: return interaction; - case OWSInteractionType_Error: case OWSInteractionType_Info: break; case OWSInteractionType_Call: @@ -1134,7 +1133,6 @@ NS_ASSUME_NONNULL_BEGIN break; case OWSInteractionType_IncomingMessage: case OWSInteractionType_OutgoingMessage: - case OWSInteractionType_Error: case OWSInteractionType_Info: case OWSInteractionType_Call: canShowDate = YES; diff --git a/Session/Meta/Signal-Bridging-Header.h b/Session/Meta/Signal-Bridging-Header.h index c95439b0d..956c13505 100644 --- a/Session/Meta/Signal-Bridging-Header.h +++ b/Session/Meta/Signal-Bridging-Header.h @@ -75,7 +75,6 @@ #import #import #import -#import #import #import #import diff --git a/Session/Notifications/AppNotifications.swift b/Session/Notifications/AppNotifications.swift index 98afdc81f..3ba8d5e62 100644 --- a/Session/Notifications/AppNotifications.swift +++ b/Session/Notifications/AppNotifications.swift @@ -255,50 +255,6 @@ public class NotificationPresenter: NSObject, NotificationsProtocol { } } - public func notifyUser(for errorMessage: TSErrorMessage, thread: TSThread, transaction: YapDatabaseReadWriteTransaction) { - - let notificationTitle: String? - switch self.previewType { - case .namePreview, .nameNoPreview: - notificationTitle = thread.name() - case .noNameNoPreview: - notificationTitle = nil - } - - let notificationBody = errorMessage.previewText(with: transaction) - - guard let threadId = thread.uniqueId else { - owsFailDebug("threadId was unexpectedly nil") - return - } - - let userInfo = [ - AppNotificationUserInfoKey.threadId: threadId - ] - - transaction.addCompletionQueue(DispatchQueue.main) { - let sound = self.requestSound(thread: thread) - self.adaptee.notify(category: .errorMessage, - title: notificationTitle, - body: notificationBody, - userInfo: userInfo, - sound: sound) - } - } - - public func notifyUser(forThreadlessErrorMessage errorMessage: TSErrorMessage, transaction: YapDatabaseReadWriteTransaction) { - let notificationBody = errorMessage.previewText(with: transaction) - - transaction.addCompletionQueue(DispatchQueue.main) { - let sound = self.checkIfShouldPlaySound() ? OWSSounds.globalNotificationSound() : nil - self.adaptee.notify(category: .threadlessErrorMessage, - title: nil, - body: notificationBody, - userInfo: [:], - sound: sound) - } - } - @objc public func cancelNotifications(threadId: String) { self.adaptee.cancelNotifications(threadId: threadId) diff --git a/SessionMessagingKit/Messages/Signal/TSErrorMessage.h b/SessionMessagingKit/Messages/Signal/TSErrorMessage.h deleted file mode 100644 index a0a65d6d5..000000000 --- a/SessionMessagingKit/Messages/Signal/TSErrorMessage.h +++ /dev/null @@ -1,76 +0,0 @@ -// -// Copyright (c) 2019 Open Whisper Systems. All rights reserved. -// - -#import -#import - -NS_ASSUME_NONNULL_BEGIN - -@class SNProtoEnvelope; - -typedef NS_ENUM(int32_t, TSErrorMessageType) { - TSErrorMessageNoSession, - // DEPRECATED: We no longer create TSErrorMessageWrongTrustedIdentityKey, but - // persisted legacy messages could exist indefinitly. - TSErrorMessageWrongTrustedIdentityKey, - TSErrorMessageInvalidKeyException, - // unused - TSErrorMessageMissingKeyId, - TSErrorMessageInvalidMessage, - // unused - TSErrorMessageDuplicateMessage, - TSErrorMessageInvalidVersion, - TSErrorMessageNonBlockingIdentityChange, - TSErrorMessageUnknownContactBlockOffer, - TSErrorMessageGroupCreationFailed, -}; - -@interface TSErrorMessage : TSMessage - -- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp - inThread:(nullable TSThread *)thread - messageBody:(nullable NSString *)body - attachmentIds:(NSArray *)attachmentIds - expiresInSeconds:(uint32_t)expiresInSeconds - expireStartedAt:(uint64_t)expireStartedAt - quotedMessage:(nullable TSQuotedMessage *)quotedMessage - contactShare:(nullable OWSContact *)contact - linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE; - -- (instancetype)initWithTimestamp:(uint64_t)timestamp - inThread:(nullable TSThread *)thread - messageBody:(nullable NSString *)body - attachmentIds:(NSArray *)attachmentIds - expiresInSeconds:(uint32_t)expiresInSeconds - expireStartedAt:(uint64_t)expireStartedAt NS_UNAVAILABLE; - -- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER; - -- (instancetype)initWithTimestamp:(uint64_t)timestamp - inThread:(nullable TSThread *)thread - failedMessageType:(TSErrorMessageType)errorMessageType - recipientId:(nullable NSString *)recipientId NS_DESIGNATED_INITIALIZER; - -+ (instancetype)corruptedMessageWithEnvelope:(SNProtoEnvelope *)envelope - withTransaction:(YapDatabaseReadWriteTransaction *)transaction; - -+ (instancetype)corruptedMessageInUnknownThread; - -+ (instancetype)invalidVersionWithEnvelope:(SNProtoEnvelope *)envelope - withTransaction:(YapDatabaseReadWriteTransaction *)transaction; - -+ (instancetype)invalidKeyExceptionWithEnvelope:(SNProtoEnvelope *)envelope - withTransaction:(YapDatabaseReadWriteTransaction *)transaction; - -+ (instancetype)missingSessionWithEnvelope:(SNProtoEnvelope *)envelope - withTransaction:(YapDatabaseReadWriteTransaction *)transaction; - -+ (instancetype)nonblockingIdentityChangeInThread:(TSThread *)thread recipientId:(NSString *)recipientId; - -@property (nonatomic, readonly) TSErrorMessageType errorType; -@property (nullable, nonatomic, readonly) NSString *recipientId; - -@end - -NS_ASSUME_NONNULL_END diff --git a/SessionMessagingKit/Messages/Signal/TSErrorMessage.m b/SessionMessagingKit/Messages/Signal/TSErrorMessage.m deleted file mode 100644 index a678823e2..000000000 --- a/SessionMessagingKit/Messages/Signal/TSErrorMessage.m +++ /dev/null @@ -1,219 +0,0 @@ -// -// Copyright (c) 2019 Open Whisper Systems. All rights reserved. -// - -#import "TSErrorMessage.h" -#import "SSKEnvironment.h" -#import "TSContactThread.h" -#import "TSErrorMessage_privateConstructor.h" -#import -#import -#import - -NS_ASSUME_NONNULL_BEGIN - -NSUInteger TSErrorMessageSchemaVersion = 1; - -@interface TSErrorMessage () - -@property (nonatomic, getter=wasRead) BOOL read; - -@property (nonatomic, readonly) NSUInteger errorMessageSchemaVersion; - -@end - -#pragma mark - - -@implementation TSErrorMessage - -- (nullable instancetype)initWithCoder:(NSCoder *)coder -{ - self = [super initWithCoder:coder]; - if (!self) { - return self; - } - - if (self.errorMessageSchemaVersion < 1) { - _read = YES; - } - - _errorMessageSchemaVersion = TSErrorMessageSchemaVersion; - - if (self.isDynamicInteraction) { - self.read = YES; - } - - return self; -} - -- (instancetype)initWithTimestamp:(uint64_t)timestamp - inThread:(nullable TSThread *)thread - failedMessageType:(TSErrorMessageType)errorMessageType - recipientId:(nullable NSString *)recipientId -{ - self = [super initMessageWithTimestamp:timestamp - inThread:thread - messageBody:nil - attachmentIds:@[] - expiresInSeconds:0 - expireStartedAt:0 - quotedMessage:nil - linkPreview:nil]; - - if (!self) { - return self; - } - - _errorType = errorMessageType; - _recipientId = recipientId; - _errorMessageSchemaVersion = TSErrorMessageSchemaVersion; - - if (self.isDynamicInteraction) { - self.read = YES; - } - - return self; -} - -- (instancetype)initWithTimestamp:(uint64_t)timestamp - inThread:(nullable TSThread *)thread - failedMessageType:(TSErrorMessageType)errorMessageType -{ - return [self initWithTimestamp:timestamp inThread:thread failedMessageType:errorMessageType recipientId:nil]; -} - -- (instancetype)initWithEnvelope:(SNProtoEnvelope *)envelope - withTransaction:(YapDatabaseReadWriteTransaction *)transaction - failedMessageType:(TSErrorMessageType)errorMessageType -{ - NSString *source = envelope.source; - TSContactThread *contactThread = - [TSContactThread getOrCreateThreadWithContactSessionID:source transaction:transaction]; - - // Legit usage of senderTimestamp. We don't actually currently surface it in the UI, but it serves as - // a reference to the envelope which we failed to process. - return [self initWithTimestamp:envelope.timestamp inThread:contactThread failedMessageType:errorMessageType]; -} - -- (OWSInteractionType)interactionType -{ - return OWSInteractionType_Error; -} - -- (NSString *)previewTextWithTransaction:(YapDatabaseReadTransaction *)transaction -{ - switch (_errorType) { - case TSErrorMessageNoSession: - return NSLocalizedString(@"ERROR_MESSAGE_NO_SESSION", @""); - case TSErrorMessageInvalidMessage: - return NSLocalizedString(@"ERROR_MESSAGE_INVALID_MESSAGE", @""); - case TSErrorMessageInvalidVersion: - return NSLocalizedString(@"ERROR_MESSAGE_INVALID_VERSION", @""); - case TSErrorMessageDuplicateMessage: - return NSLocalizedString(@"ERROR_MESSAGE_DUPLICATE_MESSAGE", @""); - case TSErrorMessageInvalidKeyException: - return NSLocalizedString(@"ERROR_MESSAGE_INVALID_KEY_EXCEPTION", @""); - case TSErrorMessageWrongTrustedIdentityKey: - return NSLocalizedString(@"ERROR_MESSAGE_WRONG_TRUSTED_IDENTITY_KEY", @""); - case TSErrorMessageNonBlockingIdentityChange: { - if (self.recipientId) { - NSString *messageFormat = NSLocalizedString(@"ERROR_MESSAGE_NON_BLOCKING_IDENTITY_CHANGE_FORMAT", - @"Shown when signal users safety numbers changed, embeds the user's {{name or phone number}}"); - - return [NSString stringWithFormat:messageFormat, self.recipientId]; - } else { - // recipientId will be nil for legacy errors - return NSLocalizedString( - @"ERROR_MESSAGE_NON_BLOCKING_IDENTITY_CHANGE", @"Shown when signal users safety numbers changed"); - } - break; - } - case TSErrorMessageUnknownContactBlockOffer: - return NSLocalizedString(@"UNKNOWN_CONTACT_BLOCK_OFFER", - @"Message shown in conversation view that offers to block an unknown user."); - case TSErrorMessageGroupCreationFailed: - return NSLocalizedString(@"GROUP_CREATION_FAILED", - @"Message shown in conversation view that indicates there were issues with group creation."); - default: - return NSLocalizedString(@"ERROR_MESSAGE_UNKNOWN_ERROR", @""); - break; - } -} - -+ (instancetype)corruptedMessageWithEnvelope:(SNProtoEnvelope *)envelope - withTransaction:(YapDatabaseReadWriteTransaction *)transaction -{ - return [[self alloc] initWithEnvelope:envelope - withTransaction:transaction - failedMessageType:TSErrorMessageInvalidMessage]; -} - -+ (instancetype)corruptedMessageInUnknownThread -{ - // MJK TODO - Seems like we could safely remove this timestamp - return [[self alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] - inThread:nil - failedMessageType:TSErrorMessageInvalidMessage]; -} - -+ (instancetype)invalidVersionWithEnvelope:(SNProtoEnvelope *)envelope - withTransaction:(YapDatabaseReadWriteTransaction *)transaction -{ - return [[self alloc] initWithEnvelope:envelope - withTransaction:transaction - failedMessageType:TSErrorMessageInvalidVersion]; -} - -+ (instancetype)invalidKeyExceptionWithEnvelope:(SNProtoEnvelope *)envelope - withTransaction:(YapDatabaseReadWriteTransaction *)transaction -{ - return [[self alloc] initWithEnvelope:envelope - withTransaction:transaction - failedMessageType:TSErrorMessageInvalidKeyException]; -} - -+ (instancetype)missingSessionWithEnvelope:(SNProtoEnvelope *)envelope - withTransaction:(YapDatabaseReadWriteTransaction *)transaction -{ - return - [[self alloc] initWithEnvelope:envelope withTransaction:transaction failedMessageType:TSErrorMessageNoSession]; -} - -+ (instancetype)nonblockingIdentityChangeInThread:(TSThread *)thread recipientId:(NSString *)recipientId -{ - // MJK TODO - should be safe to remove this senderTimestamp - return [[self alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] - inThread:thread - failedMessageType:TSErrorMessageNonBlockingIdentityChange - recipientId:recipientId]; -} - -#pragma mark - OWSReadTracking - -- (uint64_t)expireStartedAt -{ - return 0; -} - -- (BOOL)shouldAffectUnreadCounts -{ - return NO; -} - -- (void)markAsReadAtTimestamp:(uint64_t)readTimestamp - sendReadReceipt:(BOOL)sendReadReceipt - transaction:(YapDatabaseReadWriteTransaction *)transaction -{ - if (_read) { - return; - } - - _read = YES; - [self saveWithTransaction:transaction]; - - // Ignore sendReadReceipt - it doesn't apply to error messages. -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/SessionMessagingKit/Messages/Signal/TSErrorMessage_privateConstructor.h b/SessionMessagingKit/Messages/Signal/TSErrorMessage_privateConstructor.h deleted file mode 100644 index e402d95fb..000000000 --- a/SessionMessagingKit/Messages/Signal/TSErrorMessage_privateConstructor.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface TSErrorMessage () - -- (instancetype)initWithTimestamp:(uint64_t)timestamp - inThread:(nullable TSThread *)thread - failedMessageType:(TSErrorMessageType)errorMessageType NS_DESIGNATED_INITIALIZER; - -@property (atomic, nullable) NSData *envelopeData; - -@end - -NS_ASSUME_NONNULL_END diff --git a/SessionMessagingKit/Messages/Signal/TSInteraction.h b/SessionMessagingKit/Messages/Signal/TSInteraction.h index 7cdef9db1..4af4ce1cf 100644 --- a/SessionMessagingKit/Messages/Signal/TSInteraction.h +++ b/SessionMessagingKit/Messages/Signal/TSInteraction.h @@ -12,7 +12,6 @@ typedef NS_ENUM(NSInteger, OWSInteractionType) { OWSInteractionType_Unknown, OWSInteractionType_IncomingMessage, OWSInteractionType_OutgoingMessage, - OWSInteractionType_Error, OWSInteractionType_Call, OWSInteractionType_Info, OWSInteractionType_Offer, diff --git a/SessionMessagingKit/Messages/Signal/TSInteraction.m b/SessionMessagingKit/Messages/Signal/TSInteraction.m index a23a23ab6..e6d1a6a93 100644 --- a/SessionMessagingKit/Messages/Signal/TSInteraction.m +++ b/SessionMessagingKit/Messages/Signal/TSInteraction.m @@ -20,8 +20,6 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value) return @"OWSInteractionType_IncomingMessage"; case OWSInteractionType_OutgoingMessage: return @"OWSInteractionType_OutgoingMessage"; - case OWSInteractionType_Error: - return @"OWSInteractionType_Error"; case OWSInteractionType_Call: return @"OWSInteractionType_Call"; case OWSInteractionType_Info: diff --git a/SessionMessagingKit/Meta/SessionMessagingKit.h b/SessionMessagingKit/Meta/SessionMessagingKit.h index a770332f3..f989c52e6 100644 --- a/SessionMessagingKit/Meta/SessionMessagingKit.h +++ b/SessionMessagingKit/Meta/SessionMessagingKit.h @@ -42,8 +42,6 @@ FOUNDATION_EXPORT const unsigned char SessionMessagingKitVersionString[]; #import #import #import -#import -#import #import #import #import @@ -52,6 +50,5 @@ FOUNDATION_EXPORT const unsigned char SessionMessagingKitVersionString[]; #import #import #import -#import #import #import diff --git a/SessionMessagingKit/Sending & Receiving/Notifications/NotificationsProtocol.h b/SessionMessagingKit/Sending & Receiving/Notifications/NotificationsProtocol.h index 29093da1e..9fdeb18e4 100644 --- a/SessionMessagingKit/Sending & Receiving/Notifications/NotificationsProtocol.h +++ b/SessionMessagingKit/Sending & Receiving/Notifications/NotificationsProtocol.h @@ -20,13 +20,6 @@ NS_ASSUME_NONNULL_BEGIN inThread:(TSThread *)thread transaction:(YapDatabaseReadTransaction *)transaction; -- (void)notifyUserForErrorMessage:(TSErrorMessage *)error - thread:(TSThread *)thread - transaction:(YapDatabaseReadWriteTransaction *)transaction; - -- (void)notifyUserForThreadlessErrorMessage:(TSErrorMessage *)error - transaction:(YapDatabaseReadWriteTransaction *)transaction; - - (void)clearAllNotifications; @end diff --git a/SessionMessagingKit/Sending & Receiving/Read Tracking/OWSReadReceiptManager.h b/SessionMessagingKit/Sending & Receiving/Read Tracking/OWSReadReceiptManager.h index d369acf74..d2c07812b 100644 --- a/SessionMessagingKit/Sending & Receiving/Read Tracking/OWSReadReceiptManager.h +++ b/SessionMessagingKit/Sending & Receiving/Read Tracking/OWSReadReceiptManager.h @@ -16,22 +16,6 @@ NS_ASSUME_NONNULL_BEGIN extern NSString *const kIncomingMessageMarkedAsReadNotification; -// There are four kinds of read receipts: -// -// * Read receipts that this client sends to linked -// devices to inform them that a message has been read. -// * Read receipts that this client receives from linked -// devices that inform this client that a message has been read. -// * These read receipts are saved so that they can be applied -// if they arrive before the corresponding message. -// * Read receipts that this client sends to other users -// to inform them that a message has been read. -// * Read receipts that this client receives from other users -// that inform this client that a message has been read. -// * These read receipts are saved so that they can be applied -// if they arrive before the corresponding message. -// -// This manager is responsible for handling and emitting all four kinds. @interface OWSReadReceiptManager : NSObject - (instancetype)init NS_UNAVAILABLE; @@ -48,9 +32,6 @@ extern NSString *const kIncomingMessageMarkedAsReadNotification; sentTimestamps:(NSArray *)sentTimestamps readTimestamp:(uint64_t)readTimestamp; -- (void)applyEarlyReadReceiptsForOutgoingMessageFromLinkedDevice:(TSOutgoingMessage *)message - transaction:(YapDatabaseReadWriteTransaction *)transaction; - #pragma mark - Locally Read // This method cues this manager: diff --git a/SessionMessagingKit/Sending & Receiving/Read Tracking/OWSReadTracking.h b/SessionMessagingKit/Sending & Receiving/Read Tracking/OWSReadTracking.h index aa7b90fd5..d8afaaa41 100644 --- a/SessionMessagingKit/Sending & Receiving/Read Tracking/OWSReadTracking.h +++ b/SessionMessagingKit/Sending & Receiving/Read Tracking/OWSReadTracking.h @@ -23,7 +23,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) uint64_t sortId; @property (nonatomic, readonly) NSString *uniqueThreadId; - - (BOOL)shouldAffectUnreadCounts; /** diff --git a/SessionMessagingKit/Sending & Receiving/Read Tracking/TSUnreadIndicatorInteraction.h b/SessionMessagingKit/Sending & Receiving/Read Tracking/TSUnreadIndicatorInteraction.h deleted file mode 100644 index 4545e6d99..000000000 --- a/SessionMessagingKit/Sending & Receiving/Read Tracking/TSUnreadIndicatorInteraction.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -// This class is vestigial. -__attribute__((deprecated)) @interface TSUnreadIndicatorInteraction : TSInteraction - -- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER; - -@end - -NS_ASSUME_NONNULL_END diff --git a/SessionMessagingKit/Sending & Receiving/Read Tracking/TSUnreadIndicatorInteraction.m b/SessionMessagingKit/Sending & Receiving/Read Tracking/TSUnreadIndicatorInteraction.m deleted file mode 100644 index e9d96b4c9..000000000 --- a/SessionMessagingKit/Sending & Receiving/Read Tracking/TSUnreadIndicatorInteraction.m +++ /dev/null @@ -1,38 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import "TSUnreadIndicatorInteraction.h" - -NS_ASSUME_NONNULL_BEGIN - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-implementations" -@implementation TSUnreadIndicatorInteraction -#pragma clang diagnostic pop - -- (instancetype)initWithCoder:(NSCoder *)coder -{ - return [super initWithCoder:coder]; -} - -- (BOOL)shouldUseReceiptDateForSorting -{ - // Use the timestamp, not the "received at" timestamp to sort, - // since we're creating these interactions after the fact and back-dating them. - return NO; -} - -- (BOOL)isDynamicInteraction -{ - return YES; -} - -- (OWSInteractionType)interactionType -{ - return OWSInteractionType_Unknown; -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/SessionMessagingKit/Sending & Receiving/Typing Indicators/TypingIndicators.swift b/SessionMessagingKit/Sending & Receiving/Typing Indicators/TypingIndicators.swift index 8333f1763..fe2bd3d1b 100644 --- a/SessionMessagingKit/Sending & Receiving/Typing Indicators/TypingIndicators.swift +++ b/SessionMessagingKit/Sending & Receiving/Typing Indicators/TypingIndicators.swift @@ -5,7 +5,8 @@ import Foundation @objc(OWSTypingIndicators) -public protocol TypingIndicators: class { +public protocol TypingIndicators : AnyObject { + @objc func didStartTypingOutgoingInput(inThread thread: TSThread) @@ -43,7 +44,7 @@ public protocol TypingIndicators: class { // MARK: - @objc(OWSTypingIndicatorsImpl) -public class TypingIndicatorsImpl: NSObject, TypingIndicators { +public class TypingIndicatorsImpl : NSObject, TypingIndicators { @objc public static let typingIndicatorStateDidChange = Notification.Name("typingIndicatorStateDidChange") diff --git a/SessionMessagingKit/Threads/TSThread.m b/SessionMessagingKit/Threads/TSThread.m index d5107cf3b..16d43361c 100644 --- a/SessionMessagingKit/Threads/TSThread.m +++ b/SessionMessagingKit/Threads/TSThread.m @@ -316,15 +316,6 @@ BOOL IsNoteToSelfEnabled(void) return NO; } - if ([interaction isKindOfClass:[TSErrorMessage class]]) { - TSErrorMessage *errorMessage = (TSErrorMessage *)interaction; - if (errorMessage.errorType == TSErrorMessageNonBlockingIdentityChange) { - // Otherwise all group threads with the recipient will percolate to the top of the inbox, even though - // there was no meaningful interaction. - return NO; - } - } - return YES; } diff --git a/SessionMessagingKit/Utilities/OWSIdentityManager.m b/SessionMessagingKit/Utilities/OWSIdentityManager.m index 802fb0ac4..a4a017baf 100644 --- a/SessionMessagingKit/Utilities/OWSIdentityManager.m +++ b/SessionMessagingKit/Utilities/OWSIdentityManager.m @@ -14,7 +14,6 @@ #import "SSKEnvironment.h" #import "TSAccountManager.h" #import "TSContactThread.h" -#import "TSErrorMessage.h" #import "TSGroupThread.h" #import "TSMessage.h" #import "YapDatabaseConnection+OWS.h" diff --git a/SignalUtilitiesKit/Utilities/NoopNotificationsManager.swift b/SignalUtilitiesKit/Utilities/NoopNotificationsManager.swift index cb1c34536..50e95bb6c 100644 --- a/SignalUtilitiesKit/Utilities/NoopNotificationsManager.swift +++ b/SignalUtilitiesKit/Utilities/NoopNotificationsManager.swift @@ -9,14 +9,6 @@ public class NoopNotificationsManager: NSObject, NotificationsProtocol { owsFailDebug("") } - public func notifyUser(for error: TSErrorMessage, thread: TSThread, transaction: YapDatabaseReadWriteTransaction) { - Logger.warn("skipping notification for: \(error.description)") - } - - public func notifyUser(forThreadlessErrorMessage error: TSErrorMessage, transaction: YapDatabaseReadWriteTransaction) { - Logger.warn("skipping notification for: \(error.description)") - } - public func clearAllNotifications() { Logger.warn("clearAllNotifications") } diff --git a/SignalUtilitiesKit/Utilities/ThreadUtil.m b/SignalUtilitiesKit/Utilities/ThreadUtil.m index 4922fc4f5..ccd85df3b 100644 --- a/SignalUtilitiesKit/Utilities/ThreadUtil.m +++ b/SignalUtilitiesKit/Utilities/ThreadUtil.m @@ -5,7 +5,6 @@ #import "ThreadUtil.h" #import "OWSQuotedReplyModel.h" #import "OWSUnreadIndicator.h" -#import "TSUnreadIndicatorInteraction.h" #import #import #import @@ -82,24 +81,6 @@ NS_ASSUME_NONNULL_BEGIN ThreadDynamicInteractions *result = [ThreadDynamicInteractions new]; [dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { - // Find any "dynamic" interactions and safety number changes. - // - // We use different views for performance reasons. - NSMutableArray *nonBlockingSafetyNumberChanges = [NSMutableArray new]; - [[TSDatabaseView threadSpecialMessagesDatabaseView:transaction] - enumerateKeysAndObjectsInGroup:thread.uniqueId - usingBlock:^( - NSString *collection, NSString *key, id object, NSUInteger index, BOOL *stop) { - if ([object isKindOfClass:[TSErrorMessage class]]) { - TSErrorMessage *errorMessage = (TSErrorMessage *)object; - OWSAssertDebug( - errorMessage.errorType == TSErrorMessageNonBlockingIdentityChange); - [nonBlockingSafetyNumberChanges addObject:errorMessage]; - } else { - OWSFailDebug(@"Unexpected dynamic interaction type: %@", [object class]); - } - }]; - // Determine if there are "unread" messages in this conversation. // If we've been passed a firstUnseenInteractionTimestampParameter, // just use that value in order to preserve continuity of the @@ -122,7 +103,7 @@ NS_ASSUME_NONNULL_BEGIN thread:thread transaction:transaction maxRangeSize:maxRangeSize - nonBlockingSafetyNumberChanges:nonBlockingSafetyNumberChanges + nonBlockingSafetyNumberChanges:@[] hideUnreadMessagesIndicator:hideUnreadMessagesIndicator firstUnseenSortId:firstUnseenSortId];