mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Create block offer when non-contacts send you a message.
// FREEBIE
This commit is contained in:
parent
adee71ba9b
commit
17b751d22a
6 changed files with 83 additions and 10 deletions
|
@ -36,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
- (void)updateSignalContactIntersectionWithABContacts:(NSArray<Contact *> *)abContacts
|
||||
success:(void (^)())success
|
||||
failure:(void (^)(NSError *error))failure;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Created by Frederic Jacobs on 12/11/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSSignalServiceProtos.pb.h"
|
||||
#import "TSMessage.h"
|
||||
|
@ -15,6 +16,7 @@ typedef NS_ENUM(int32_t, TSErrorMessageType) {
|
|||
TSErrorMessageDuplicateMessage,
|
||||
TSErrorMessageInvalidVersion,
|
||||
TSErrorMessageNonBlockingIdentityChange,
|
||||
TSErrorMessageUnknownContactBlockOffer,
|
||||
};
|
||||
|
||||
-(instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
//
|
||||
// TSErrorMessage.m
|
||||
// TextSecureKit
|
||||
//
|
||||
// Created by Frederic Jacobs on 12/11/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSErrorMessage.h"
|
||||
|
@ -36,8 +32,14 @@
|
|||
}
|
||||
|
||||
_errorType = errorMessageType;
|
||||
// TODO Move this out of model class.
|
||||
[[TextSecureKitEnv sharedEnv].notificationsManager notifyUserForErrorMessage:self inThread:thread];
|
||||
// TODO: Move this out of model class.
|
||||
//
|
||||
// For now, dispatch async to ensure we're not inside a transaction
|
||||
// and thereby avoid deadlock.
|
||||
TSErrorMessage *errorMessage = self;
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[[TextSecureKitEnv sharedEnv].notificationsManager notifyUserForErrorMessage:errorMessage inThread:thread];
|
||||
});
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -47,7 +49,7 @@
|
|||
failedMessageType:(TSErrorMessageType)errorMessageType
|
||||
{
|
||||
TSContactThread *contactThread =
|
||||
[TSContactThread getOrCreateThreadWithContactId:envelope.source transaction:transaction];
|
||||
[TSContactThread getOrCreateThreadWithContactId:envelope.source transaction:transaction relay:nil];
|
||||
|
||||
return [self initWithTimestamp:envelope.timestamp inThread:contactThread failedMessageType:errorMessageType];
|
||||
}
|
||||
|
@ -68,6 +70,8 @@
|
|||
return NSLocalizedString(@"ERROR_MESSAGE_WRONG_TRUSTED_IDENTITY_KEY", @"");
|
||||
case TSErrorMessageNonBlockingIdentityChange:
|
||||
return NSLocalizedString(@"ERROR_MESSAGE_NON_BLOCKING_IDENTITY_CHANGE", @"");
|
||||
case TSErrorMessageUnknownContactBlockOffer:
|
||||
return NSLocalizedString(@"UNKNOWN_CONTACT_BLOCK_OFFER", nil);
|
||||
default:
|
||||
return NSLocalizedString(@"ERROR_MESSAGE_UNKNOWN_ERROR", @"");
|
||||
break;
|
||||
|
|
|
@ -1231,6 +1231,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|||
DDLogWarn(@"%@ Got exception: %@", self.tag, exception);
|
||||
|
||||
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
// TODO: This error message is never created?
|
||||
TSErrorMessage *errorMessage;
|
||||
|
||||
if (message.groupMetaMessage == TSGroupMessageNone) {
|
||||
|
|
19
src/Messages/OWSUnknownContactBlockOfferMessage.h
Normal file
19
src/Messages/OWSUnknownContactBlockOfferMessage.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSErrorMessage.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSUnknownContactBlockOfferMessage : TSErrorMessage
|
||||
|
||||
+ (instancetype)unknownContactBlockOfferMessage:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
contactId:(NSString *)contactId;
|
||||
|
||||
@property (nonatomic, readonly) NSString *contactId;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
46
src/Messages/OWSUnknownContactBlockOfferMessage.m
Normal file
46
src/Messages/OWSUnknownContactBlockOfferMessage.m
Normal file
|
@ -0,0 +1,46 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSUnknownContactBlockOfferMessage.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSUnknownContactBlockOfferMessage ()
|
||||
|
||||
@property (nonatomic) NSString *contactId;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWSUnknownContactBlockOfferMessage
|
||||
|
||||
+ (instancetype)unknownContactBlockOfferMessage:(uint64_t)timestamp
|
||||
thread:(TSThread *)thread
|
||||
contactId:(NSString *)contactId
|
||||
{
|
||||
return [[OWSUnknownContactBlockOfferMessage alloc] initWithTimestamp:timestamp thread:thread contactId:contactId];
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp thread:(TSThread *)thread contactId:(NSString *)contactId
|
||||
{
|
||||
self = [super initWithTimestamp:timestamp inThread:thread failedMessageType:TSErrorMessageUnknownContactBlockOffer];
|
||||
|
||||
if (self) {
|
||||
_contactId = contactId;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable NSDate *)receiptDateForSorting
|
||||
{
|
||||
// Always use date, since we're creating these interactions after the fact
|
||||
// and back-dating them.
|
||||
return self.date;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
Loading…
Reference in a new issue