Send silent messages where appropriate.

// FREEBIE
pull/1/head
Matthew Chen 7 years ago
parent cc2d08d036
commit 9b5affb390

@ -36,6 +36,13 @@ NS_ASSUME_NONNULL_BEGIN
return NO;
}
- (BOOL)isSilent
{
// Avoid "phantom messages" for "recipient read receipts".
return YES;
}
- (NSData *)buildPlainTextData:(SignalRecipient *)recipient
{
OWSAssert(recipient);

@ -110,6 +110,8 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
// Map of "recipient id"-to-"read time" of the recipients who have read the message.
@property (atomic, readonly) NSDictionary<NSString *, NSNumber *> *recipientReadMap;
@property (nonatomic, readonly) BOOL isSilent;
/**
* Signal Identifier (e.g. e164 number) or nil if in a group thread.
*/

@ -228,6 +228,11 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
}
}
- (BOOL)isSilent
{
return NO;
}
#pragma mark - Update Methods
// This method does the work for the "updateWith..." methods. Please see

@ -879,7 +879,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
NSArray<NSDictionary *> *deviceMessages;
@try {
deviceMessages = [self deviceMessages:message forRecipient:recipient inThread:thread];
deviceMessages = [self deviceMessages:message forRecipient:recipient];
} @catch (NSException *exception) {
deviceMessages = @[];
if ([exception.name isEqualToString:UntrustedIdentityKeyException]) {
@ -1173,8 +1173,10 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
- (NSArray<NSDictionary *> *)deviceMessages:(TSOutgoingMessage *)message
forRecipient:(SignalRecipient *)recipient
inThread:(TSThread *)thread
{
OWSAssert(message);
OWSAssert(recipient);
NSMutableArray *messagesArray = [NSMutableArray arrayWithCapacity:recipient.devices.count];
NSData *plainText = [message buildPlainTextData:recipient];
@ -1191,7 +1193,8 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
messageDict = [self encryptedMessageWithPlaintext:plainText
toRecipient:recipient.uniqueId
deviceId:deviceNumber
keyingStorage:[TSStorageManager sharedManager]];
keyingStorage:self.storageManager
isSilent:message.isSilent];
} @catch (NSException *exception) {
encryptionException = exception;
}
@ -1225,7 +1228,13 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
toRecipient:(NSString *)identifier
deviceId:(NSNumber *)deviceNumber
keyingStorage:(TSStorageManager *)storage
isSilent:(BOOL)isSilent
{
OWSAssert(plainText);
OWSAssert(identifier.length > 0);
OWSAssert(deviceNumber);
OWSAssert(storage);
if (![storage containsSession:identifier deviceId:[deviceNumber intValue]]) {
__block dispatch_semaphore_t sema = dispatch_semaphore_create(0);
__block PreKeyBundle *_Nullable bundle;
@ -1305,6 +1314,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
recipientId:identifier
device:[deviceNumber intValue]
content:serializedMessage
isSilent:isSilent
registrationId:cipher.remoteRegistrationId];
NSError *error;

@ -1,5 +1,6 @@
// Created by Frederic Jacobs on 18/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "TSConstants.h"
#import <Mantle/Mantle.h>
@ -7,6 +8,9 @@
/**
* Contstructs the per-device-message parameters used when submitting a message to
* the Signal Web Service.
*
* See:
* https://github.com/WhisperSystems/libsignal-service-java/blob/master/java/src/main/java/org/whispersystems/signalservice/internal/push/OutgoingPushMessage.java
*/
@interface OWSMessageServiceParams : MTLModel <MTLJSONSerializing>
@ -15,11 +19,13 @@
@property (nonatomic, readonly) int destinationDeviceId;
@property (nonatomic, readonly) int destinationRegistrationId;
@property (nonatomic, readonly) NSString *content;
@property (nonatomic, readonly) BOOL silent;
- (instancetype)initWithType:(TSWhisperMessageType)type
recipientId:(NSString *)destination
device:(int)deviceId
content:(NSData *)content
isSilent:(BOOL)isSilent
registrationId:(int)registrationId;
@end

@ -1,5 +1,6 @@
// Created by Frederic Jacobs on 18/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSMessageServiceParams.h"
#import "NSData+Base64.h"
@ -16,6 +17,7 @@
recipientId:(NSString *)destination
device:(int)deviceId
content:(NSData *)content
isSilent:(BOOL)isSilent
registrationId:(int)registrationId
{
self = [super init];
@ -29,6 +31,7 @@
_destinationDeviceId = deviceId;
_destinationRegistrationId = registrationId;
_content = [content base64EncodedString];
_silent = isSilent;
return self;
}

@ -112,6 +112,13 @@ NS_ASSUME_NONNULL_BEGIN
return NO;
}
- (BOOL)isSilent
{
// Avoid "phantom messages" for "outgoing call messages".
return YES;
}
//
///**
// * override thread accessor in superclass, since this model is never saved.

Loading…
Cancel
Save