Merge branch 'mkirk/sync-session-reset'

pull/1/head
Michael Kirk 9 years ago
commit 8251f1e67b

@ -7,8 +7,9 @@
#import "OWSDisappearingMessagesJob.h" #import "OWSDisappearingMessagesJob.h"
#import "OWSIncomingSentMessageTranscript.h" #import "OWSIncomingSentMessageTranscript.h"
#import "OWSMessageSender.h" #import "OWSMessageSender.h"
#import "TSInfoMessage.h"
#import "TSOutgoingMessage.h" #import "TSOutgoingMessage.h"
#import "TSStorageManager.h" #import "TSStorageManager+SessionStore.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -17,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) OWSIncomingSentMessageTranscript *incomingSentMessageTranscript; @property (nonatomic, readonly) OWSIncomingSentMessageTranscript *incomingSentMessageTranscript;
@property (nonatomic, readonly) OWSMessageSender *messageSender; @property (nonatomic, readonly) OWSMessageSender *messageSender;
@property (nonatomic, readonly) TSNetworkManager *networkManager; @property (nonatomic, readonly) TSNetworkManager *networkManager;
@property (nonatomic, readonly) TSStorageManager *storageManager;
@end @end
@ -34,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
_incomingSentMessageTranscript = incomingSentMessageTranscript; _incomingSentMessageTranscript = incomingSentMessageTranscript;
_messageSender = messageSender; _messageSender = messageSender;
_networkManager = networkManager; _networkManager = networkManager;
_storageManager = [TSStorageManager sharedManager];
return self; return self;
} }
@ -42,6 +45,18 @@ NS_ASSUME_NONNULL_BEGIN
{ {
OWSIncomingSentMessageTranscript *transcript = self.incomingSentMessageTranscript; OWSIncomingSentMessageTranscript *transcript = self.incomingSentMessageTranscript;
DDLogDebug(@"%@ Recording transcript: %@", self.tag, transcript); DDLogDebug(@"%@ Recording transcript: %@", self.tag, transcript);
if (transcript.isEndSessionMessage) {
DDLogInfo(@"%@ EndSession was sent to recipient: %@.", self.tag, transcript.recipientId);
[self.storageManager deleteAllSessionsForContact:transcript.recipientId];
[[[TSInfoMessage alloc] initWithTimestamp:transcript.timestamp
inThread:transcript.thread
messageType:TSInfoMessageTypeSessionDidEnd] save];
// Don't continue processing lest we print a bubble for the session reset.
return;
}
TSThread *thread = transcript.thread; TSThread *thread = transcript.thread;
OWSAttachmentsProcessor *attachmentsProcessor = OWSAttachmentsProcessor *attachmentsProcessor =
[[OWSAttachmentsProcessor alloc] initWithAttachmentProtos:transcript.attachmentPointerProtos [[OWSAttachmentsProcessor alloc] initWithAttachmentProtos:transcript.attachmentPointerProtos

@ -1,4 +1,6 @@
// Copyright © 2016 Open Whisper Systems. All rights reserved. //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -24,6 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) TSThread *thread; @property (nonatomic, readonly) TSThread *thread;
@property (nonatomic, readonly) BOOL isGroupUpdate; @property (nonatomic, readonly) BOOL isGroupUpdate;
@property (nonatomic, readonly) BOOL isExpirationTimerUpdate; @property (nonatomic, readonly) BOOL isExpirationTimerUpdate;
@property (nonatomic, readonly) BOOL isEndSessionMessage;
@property (nullable, nonatomic, readonly) NSData *groupId; @property (nullable, nonatomic, readonly) NSData *groupId;
@property (nonatomic, readonly) NSString *body; @property (nonatomic, readonly) NSString *body;
@property (nonatomic, readonly) NSArray<OWSSignalServiceProtosAttachmentPointer *> *attachmentPointerProtos; @property (nonatomic, readonly) NSArray<OWSSignalServiceProtosAttachmentPointer *> *attachmentPointerProtos;

@ -1,4 +1,6 @@
// Copyright © 2016 Open Whisper Systems. All rights reserved. //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSIncomingSentMessageTranscript.h" #import "OWSIncomingSentMessageTranscript.h"
#import "OWSAttachmentsProcessor.h" #import "OWSAttachmentsProcessor.h"
@ -33,6 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
_groupId = _dataMessage.group.id; _groupId = _dataMessage.group.id;
_isGroupUpdate = _dataMessage.hasGroup && (_dataMessage.group.type == OWSSignalServiceProtosGroupContextTypeUpdate); _isGroupUpdate = _dataMessage.hasGroup && (_dataMessage.group.type == OWSSignalServiceProtosGroupContextTypeUpdate);
_isExpirationTimerUpdate = (_dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsExpirationTimerUpdate) != 0; _isExpirationTimerUpdate = (_dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsExpirationTimerUpdate) != 0;
_isEndSessionMessage = (_dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsEndSession) != 0;
return self; return self;
} }

@ -404,21 +404,21 @@ NS_ASSUME_NONNULL_BEGIN
}]; }];
if (ignoreMessage) { if (ignoreMessage) {
// FIXME: https://github.com/WhisperSystems/Signal-iOS/issues/1340 // FIXME: https://github.com/WhisperSystems/Signal-iOS/issues/1340
DDLogDebug(@"%@ Received message from group that I left or don't know about, ignoring", self.tag); DDLogInfo(@"%@ Received message from group that I left or don't know about, ignoring", self.tag);
return; return;
} }
} }
if ((dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsEndSession) != 0) { if ((dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsEndSession) != 0) {
DDLogVerbose(@"%@ Received end session message", self.tag); DDLogInfo(@"%@ Received end session message", self.tag);
[self handleEndSessionMessageWithEnvelope:incomingEnvelope dataMessage:dataMessage]; [self handleEndSessionMessageWithEnvelope:incomingEnvelope dataMessage:dataMessage];
} else if ((dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsExpirationTimerUpdate) != 0) { } else if ((dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsExpirationTimerUpdate) != 0) {
DDLogVerbose(@"%@ Received expiration timer update message", self.tag); DDLogInfo(@"%@ Received expiration timer update message", self.tag);
[self handleExpirationTimerUpdateMessageWithEnvelope:incomingEnvelope dataMessage:dataMessage]; [self handleExpirationTimerUpdateMessageWithEnvelope:incomingEnvelope dataMessage:dataMessage];
} else if (dataMessage.attachments.count > 0) { } else if (dataMessage.attachments.count > 0) {
DDLogVerbose(@"%@ Received media message attachment", self.tag); DDLogInfo(@"%@ Received media message attachment", self.tag);
[self handleReceivedMediaWithEnvelope:incomingEnvelope dataMessage:dataMessage]; [self handleReceivedMediaWithEnvelope:incomingEnvelope dataMessage:dataMessage];
} else { } else {
DDLogVerbose(@"%@ Received data message.", self.tag); DDLogInfo(@"%@ Received data message.", self.tag);
[self handleReceivedTextMessageWithEnvelope:incomingEnvelope dataMessage:dataMessage]; [self handleReceivedTextMessageWithEnvelope:incomingEnvelope dataMessage:dataMessage];
if ([self isDataMessageGroupAvatarUpdate:dataMessage]) { if ([self isDataMessageGroupAvatarUpdate:dataMessage]) {
DDLogVerbose(@"%@ Data message had group avatar attachment", self.tag); DDLogVerbose(@"%@ Data message had group avatar attachment", self.tag);

Loading…
Cancel
Save