Merge branch 'charlesmchen/silentMessages'

pull/1/head
Matthew Chen 8 years ago
commit 6aec891771

@ -36,6 +36,13 @@ NS_ASSUME_NONNULL_BEGIN
return NO; return NO;
} }
- (BOOL)isSilent
{
// Avoid "phantom messages" for "recipient read receipts".
return YES;
}
- (NSData *)buildPlainTextData:(SignalRecipient *)recipient - (NSData *)buildPlainTextData:(SignalRecipient *)recipient
{ {
OWSAssert(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. // Map of "recipient id"-to-"read time" of the recipients who have read the message.
@property (atomic, readonly) NSDictionary<NSString *, NSNumber *> *recipientReadMap; @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. * 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 #pragma mark - Update Methods
// This method does the work for the "updateWith..." methods. Please see // This method does the work for the "updateWith..." methods. Please see

@ -879,7 +879,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
NSArray<NSDictionary *> *deviceMessages; NSArray<NSDictionary *> *deviceMessages;
@try { @try {
deviceMessages = [self deviceMessages:message forRecipient:recipient inThread:thread]; deviceMessages = [self deviceMessages:message forRecipient:recipient];
} @catch (NSException *exception) { } @catch (NSException *exception) {
deviceMessages = @[]; deviceMessages = @[];
if ([exception.name isEqualToString:UntrustedIdentityKeyException]) { if ([exception.name isEqualToString:UntrustedIdentityKeyException]) {
@ -1173,8 +1173,10 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
- (NSArray<NSDictionary *> *)deviceMessages:(TSOutgoingMessage *)message - (NSArray<NSDictionary *> *)deviceMessages:(TSOutgoingMessage *)message
forRecipient:(SignalRecipient *)recipient forRecipient:(SignalRecipient *)recipient
inThread:(TSThread *)thread
{ {
OWSAssert(message);
OWSAssert(recipient);
NSMutableArray *messagesArray = [NSMutableArray arrayWithCapacity:recipient.devices.count]; NSMutableArray *messagesArray = [NSMutableArray arrayWithCapacity:recipient.devices.count];
NSData *plainText = [message buildPlainTextData:recipient]; NSData *plainText = [message buildPlainTextData:recipient];
@ -1191,7 +1193,8 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
messageDict = [self encryptedMessageWithPlaintext:plainText messageDict = [self encryptedMessageWithPlaintext:plainText
toRecipient:recipient.uniqueId toRecipient:recipient.uniqueId
deviceId:deviceNumber deviceId:deviceNumber
keyingStorage:[TSStorageManager sharedManager]]; keyingStorage:self.storageManager
isSilent:message.isSilent];
} @catch (NSException *exception) { } @catch (NSException *exception) {
encryptionException = exception; encryptionException = exception;
} }
@ -1225,7 +1228,13 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
toRecipient:(NSString *)identifier toRecipient:(NSString *)identifier
deviceId:(NSNumber *)deviceNumber deviceId:(NSNumber *)deviceNumber
keyingStorage:(TSStorageManager *)storage keyingStorage:(TSStorageManager *)storage
isSilent:(BOOL)isSilent
{ {
OWSAssert(plainText);
OWSAssert(identifier.length > 0);
OWSAssert(deviceNumber);
OWSAssert(storage);
if (![storage containsSession:identifier deviceId:[deviceNumber intValue]]) { if (![storage containsSession:identifier deviceId:[deviceNumber intValue]]) {
__block dispatch_semaphore_t sema = dispatch_semaphore_create(0); __block dispatch_semaphore_t sema = dispatch_semaphore_create(0);
__block PreKeyBundle *_Nullable bundle; __block PreKeyBundle *_Nullable bundle;
@ -1305,6 +1314,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
recipientId:identifier recipientId:identifier
device:[deviceNumber intValue] device:[deviceNumber intValue]
content:serializedMessage content:serializedMessage
isSilent:isSilent
registrationId:cipher.remoteRegistrationId]; registrationId:cipher.remoteRegistrationId];
NSError *error; 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 "TSConstants.h"
#import <Mantle/Mantle.h> #import <Mantle/Mantle.h>
@ -7,6 +8,9 @@
/** /**
* Contstructs the per-device-message parameters used when submitting a message to * Contstructs the per-device-message parameters used when submitting a message to
* the Signal Web Service. * 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> @interface OWSMessageServiceParams : MTLModel <MTLJSONSerializing>
@ -15,11 +19,13 @@
@property (nonatomic, readonly) int destinationDeviceId; @property (nonatomic, readonly) int destinationDeviceId;
@property (nonatomic, readonly) int destinationRegistrationId; @property (nonatomic, readonly) int destinationRegistrationId;
@property (nonatomic, readonly) NSString *content; @property (nonatomic, readonly) NSString *content;
@property (nonatomic, readonly) BOOL silent;
- (instancetype)initWithType:(TSWhisperMessageType)type - (instancetype)initWithType:(TSWhisperMessageType)type
recipientId:(NSString *)destination recipientId:(NSString *)destination
device:(int)deviceId device:(int)deviceId
content:(NSData *)content content:(NSData *)content
isSilent:(BOOL)isSilent
registrationId:(int)registrationId; registrationId:(int)registrationId;
@end @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 "OWSMessageServiceParams.h"
#import "NSData+Base64.h" #import "NSData+Base64.h"
@ -16,6 +17,7 @@
recipientId:(NSString *)destination recipientId:(NSString *)destination
device:(int)deviceId device:(int)deviceId
content:(NSData *)content content:(NSData *)content
isSilent:(BOOL)isSilent
registrationId:(int)registrationId registrationId:(int)registrationId
{ {
self = [super init]; self = [super init];
@ -29,6 +31,7 @@
_destinationDeviceId = deviceId; _destinationDeviceId = deviceId;
_destinationRegistrationId = registrationId; _destinationRegistrationId = registrationId;
_content = [content base64EncodedString]; _content = [content base64EncodedString];
_silent = isSilent;
return self; return self;
} }

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

Loading…
Cancel
Save