Respond to CR.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent ced9d6f460
commit 6341905c9b

@ -34,6 +34,10 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
@interface TSOutgoingMessage : TSMessage @interface TSOutgoingMessage : TSMessage
- (instancetype)initWithTimestamp:(uint64_t)timestamp;
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread;
- (instancetype)initWithTimestamp:(uint64_t)timestamp - (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread inThread:(nullable TSThread *)thread
messageBody:(nullable NSString *)body; messageBody:(nullable NSString *)body;
@ -42,6 +46,11 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
inThread:(nullable TSThread *)thread inThread:(nullable TSThread *)thread
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage; groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage;
- (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds;
- (instancetype)initWithTimestamp:(uint64_t)timestamp - (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread inThread:(nullable TSThread *)thread
messageBody:(nullable NSString *)body messageBody:(nullable NSString *)body
@ -153,6 +162,7 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
#pragma mark - Sent Recipients #pragma mark - Sent Recipients
- (NSUInteger)sentRecipientsCount;
- (BOOL)wasSentToRecipient:(NSString *)contactId; - (BOOL)wasSentToRecipient:(NSString *)contactId;
- (void)updateWithSentRecipient:(NSString *)contactId transaction:(YapDatabaseReadWriteTransaction *)transaction; - (void)updateWithSentRecipient:(NSString *)contactId transaction:(YapDatabaseReadWriteTransaction *)transaction;
- (void)updateWithSentRecipient:(NSString *)contactId; - (void)updateWithSentRecipient:(NSString *)contactId;

@ -65,15 +65,11 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
- (instancetype)initWithTimestamp:(uint64_t)timestamp - (instancetype)initWithTimestamp:(uint64_t)timestamp
{ {
OWSAssert(0);
return [self initWithTimestamp:timestamp inThread:nil]; return [self initWithTimestamp:timestamp inThread:nil];
} }
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread - (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread
{ {
OWSAssert(0);
return [self initWithTimestamp:timestamp inThread:thread messageBody:nil]; return [self initWithTimestamp:timestamp inThread:thread messageBody:nil];
} }
@ -93,8 +89,6 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
messageBody:(nullable NSString *)body messageBody:(nullable NSString *)body
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
{ {
OWSAssert(0);
return [self initWithTimestamp:timestamp return [self initWithTimestamp:timestamp
inThread:thread inThread:thread
messageBody:body messageBody:body
@ -336,6 +330,13 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
return [self.sentRecipients containsObject:contactId]; return [self.sentRecipients containsObject:contactId];
} }
- (NSUInteger)sentRecipientsCount
{
OWSAssert(self.sentRecipients);
return self.sentRecipients.count;
}
- (void)updateWithSentRecipient:(NSString *)contactId transaction:(YapDatabaseReadWriteTransaction *)transaction - (void)updateWithSentRecipient:(NSString *)contactId transaction:(YapDatabaseReadWriteTransaction *)transaction
{ {
OWSAssert(transaction); OWSAssert(transaction);

@ -578,7 +578,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
DDLogError(@"%@ Unknown error finding contacts", self.tag); DDLogError(@"%@ Unknown error finding contacts", self.tag);
error = OWSErrorMakeFailedToSendOutgoingMessageError(); error = OWSErrorMakeFailedToSendOutgoingMessageError();
} }
// If not recipients were found, there's no reason to retry. It will just fail again. // If no recipients were found, there's no reason to retry. It will just fail again.
[error setIsRetryable:NO]; [error setIsRetryable:NO];
failureHandler(error); failureHandler(error);
return; return;
@ -609,6 +609,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
OWSAssert(recipientContactId.length > 0); OWSAssert(recipientContactId.length > 0);
NSArray<NSString *> *blockedPhoneNumbers = _blockingManager.blockedPhoneNumbers; NSArray<NSString *> *blockedPhoneNumbers = _blockingManager.blockedPhoneNumbers;
if ([blockedPhoneNumbers containsObject:recipientContactId]) { if ([blockedPhoneNumbers containsObject:recipientContactId]) {
DDLogInfo(@"%@ skipping 1:1 send to blocked contact: %@", self.tag, recipientContactId);
NSError *error = OWSErrorMakeMessageSendFailedToBlockListError(); NSError *error = OWSErrorMakeMessageSendFailedToBlockListError();
// No need to retry - the user will continue to be blocked. // No need to retry - the user will continue to be blocked.
[error setIsRetryable:NO]; [error setIsRetryable:NO];
@ -757,8 +758,17 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
return failureHandler(firstNonRetryableError); return failureHandler(firstNonRetryableError);
} else { } else {
// If we only received errors that we should ignore, // If we only received errors that we should ignore,
// consider this send a success. // consider this send a success, unless the message could
successHandler(); // not be sent to any recipient.
if (message.sentRecipientsCount == 0) {
NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeMessageSendNoValidRecipients,
NSLocalizedString(@"ERROR_DESCRIPTION_NO_VALID_RECIPIENTS",
@"Error indicating that an outgoing message had no valid recipients."));
[error setIsRetryable:NO];
failureHandler(error);
} else {
successHandler();
}
} }
}]; }];
} }

@ -23,6 +23,7 @@ typedef NS_ENUM(NSInteger, OWSErrorCode) {
OWSErrorCodeNoSuchSignalRecipient = 777404, OWSErrorCodeNoSuchSignalRecipient = 777404,
OWSErrorCodeMessageSendDisabledDueToPreKeyUpdateFailures = 777405, OWSErrorCodeMessageSendDisabledDueToPreKeyUpdateFailures = 777405,
OWSErrorCodeMessageSendFailedToBlockList = 777406, OWSErrorCodeMessageSendFailedToBlockList = 777406,
OWSErrorCodeMessageSendNoValidRecipients = 777407,
OWSErrorCodeContactsUpdaterRateLimit = 777407, OWSErrorCodeContactsUpdaterRateLimit = 777407,
}; };

Loading…
Cancel
Save