parent
ced9d6f460
commit
6341905c9b
|
@ -34,6 +34,10 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
|
|||
|
||||
@interface TSOutgoingMessage : TSMessage
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body;
|
||||
|
@ -42,6 +46,11 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
|
|||
inThread:(nullable TSThread *)thread
|
||||
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
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
|
@ -153,6 +162,7 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
|
|||
|
||||
#pragma mark - Sent Recipients
|
||||
|
||||
- (NSUInteger)sentRecipientsCount;
|
||||
- (BOOL)wasSentToRecipient:(NSString *)contactId;
|
||||
- (void)updateWithSentRecipient:(NSString *)contactId transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
- (void)updateWithSentRecipient:(NSString *)contactId;
|
||||
|
|
|
@ -65,15 +65,11 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
{
|
||||
OWSAssert(0);
|
||||
|
||||
return [self initWithTimestamp:timestamp inThread:nil];
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread
|
||||
{
|
||||
OWSAssert(0);
|
||||
|
||||
return [self initWithTimestamp:timestamp inThread:thread messageBody:nil];
|
||||
}
|
||||
|
||||
|
@ -93,8 +89,6 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
|
||||
{
|
||||
OWSAssert(0);
|
||||
|
||||
return [self initWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:body
|
||||
|
@ -336,6 +330,13 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|||
return [self.sentRecipients containsObject:contactId];
|
||||
}
|
||||
|
||||
- (NSUInteger)sentRecipientsCount
|
||||
{
|
||||
OWSAssert(self.sentRecipients);
|
||||
|
||||
return self.sentRecipients.count;
|
||||
}
|
||||
|
||||
- (void)updateWithSentRecipient:(NSString *)contactId transaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
OWSAssert(transaction);
|
||||
|
|
|
@ -578,7 +578,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|||
DDLogError(@"%@ Unknown error finding contacts", self.tag);
|
||||
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];
|
||||
failureHandler(error);
|
||||
return;
|
||||
|
@ -609,6 +609,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|||
OWSAssert(recipientContactId.length > 0);
|
||||
NSArray<NSString *> *blockedPhoneNumbers = _blockingManager.blockedPhoneNumbers;
|
||||
if ([blockedPhoneNumbers containsObject:recipientContactId]) {
|
||||
DDLogInfo(@"%@ skipping 1:1 send to blocked contact: %@", self.tag, recipientContactId);
|
||||
NSError *error = OWSErrorMakeMessageSendFailedToBlockListError();
|
||||
// No need to retry - the user will continue to be blocked.
|
||||
[error setIsRetryable:NO];
|
||||
|
@ -757,8 +758,17 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|||
return failureHandler(firstNonRetryableError);
|
||||
} else {
|
||||
// If we only received errors that we should ignore,
|
||||
// consider this send a success.
|
||||
successHandler();
|
||||
// consider this send a success, unless the message could
|
||||
// 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,
|
||||
OWSErrorCodeMessageSendDisabledDueToPreKeyUpdateFailures = 777405,
|
||||
OWSErrorCodeMessageSendFailedToBlockList = 777406,
|
||||
OWSErrorCodeMessageSendNoValidRecipients = 777407,
|
||||
OWSErrorCodeContactsUpdaterRateLimit = 777407,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue