mirror of https://github.com/oxen-io/session-ios
Remove unused code
parent
8512691f2b
commit
a098ba7125
@ -1,76 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <SessionMessagingKit/OWSReadTracking.h>
|
|
||||||
#import <SessionMessagingKit/TSMessage.h>
|
|
||||||
|
|
||||||
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 <OWSReadTracking>
|
|
||||||
|
|
||||||
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
|
|
||||||
inThread:(nullable TSThread *)thread
|
|
||||||
messageBody:(nullable NSString *)body
|
|
||||||
attachmentIds:(NSArray<NSString *> *)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<NSString *> *)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
|
|
@ -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 <SignalCoreKit/NSDate+OWS.h>
|
|
||||||
#import <YapDatabase/YapDatabaseConnection.h>
|
|
||||||
#import <SessionMessagingKit/SessionMessagingKit-Swift.h>
|
|
||||||
|
|
||||||
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
|
|
@ -1,19 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <SessionMessagingKit/TSErrorMessage.h>
|
|
||||||
|
|
||||||
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
|
|
@ -1,16 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <SessionMessagingKit/TSInteraction.h>
|
|
||||||
|
|
||||||
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
|
|
@ -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
|
|
Loading…
Reference in New Issue