Don't print empty bubbles.

e.g. if we add another "invisible" flag message in the future we want to
be able to roll it out immediately.

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent 69e8ca8eac
commit ec0cf36abb

@ -167,10 +167,9 @@ NS_ASSUME_NONNULL_BEGIN
{ {
OWSAssert(envelope != nil); OWSAssert(envelope != nil);
return [NSString stringWithFormat:@"<Envelope type: %@, source: %@.%d, timestamp: %llu content.length: %lu />", return [NSString stringWithFormat:@"<Envelope type: %@, source: %@, timestamp: %llu content.length: %lu />",
[self descriptionForEnvelopeType:envelope], [self descriptionForEnvelopeType:envelope],
envelope.source, envelopeAddress(envelope),
(unsigned int)envelope.sourceDevice,
envelope.timestamp, envelope.timestamp,
(unsigned long)envelope.content.length]; (unsigned long)envelope.content.length];
} }
@ -296,10 +295,9 @@ NS_ASSUME_NONNULL_BEGIN
DDLogDebug(@"%@ handled secure message.", self.tag); DDLogDebug(@"%@ handled secure message.", self.tag);
if (error) { if (error) {
DDLogError( DDLogError(
@"%@ handling secure message from address: %@.%d failed with error: %@", @"%@ handling secure message from address: %@ failed with error: %@",
self.tag, self.tag,
envelope.source, envelopeAddress(envelope),
(unsigned int)envelope.sourceDevice,
error); error);
OWSProdError( OWSProdError(
[OWSAnalyticsEvents messageManagerErrorCouldNotHandleSecureMessage]); [OWSAnalyticsEvents messageManagerErrorCouldNotHandleSecureMessage]);
@ -314,11 +312,10 @@ NS_ASSUME_NONNULL_BEGIN
completion:^(NSError *_Nullable error) { completion:^(NSError *_Nullable error) {
DDLogDebug(@"%@ handled pre-key whisper message", self.tag); DDLogDebug(@"%@ handled pre-key whisper message", self.tag);
if (error) { if (error) {
DDLogError(@"%@ handling pre-key whisper message from address: %@.%d failed " DDLogError(@"%@ handling pre-key whisper message from address: %@ failed "
@"with error: %@", @"with error: %@",
self.tag, self.tag,
envelope.source, envelopeAddress(envelope),
(unsigned int)envelope.sourceDevice,
error); error);
OWSProdError( OWSProdError(
[OWSAnalyticsEvents messageManagerErrorCouldNotHandlePrekeyBundle]); [OWSAnalyticsEvents messageManagerErrorCouldNotHandlePrekeyBundle]);
@ -478,7 +475,10 @@ NS_ASSUME_NONNULL_BEGIN
sourceId:envelope.source sourceId:envelope.source
sourceDeviceId:envelope.sourceDevice]; sourceDeviceId:envelope.sourceDevice];
if (duplicateEnvelope) { if (duplicateEnvelope) {
DDLogInfo(@"%@ Ignoring previously received envelope from %@.%d with timestamp: %llu", self.tag, envelope.source, (unsigned int)envelope.sourceDevice, envelope.timestamp); DDLogInfo(@"%@ Ignoring previously received envelope from %@ with timestamp: %llu",
self.tag,
envelopeAddress(envelope),
envelope.timestamp);
return; return;
} }
@ -543,9 +543,9 @@ NS_ASSUME_NONNULL_BEGIN
} }
// FIXME: https://github.com/WhisperSystems/Signal-iOS/issues/1340 // FIXME: https://github.com/WhisperSystems/Signal-iOS/issues/1340
DDLogInfo(@"%@ Received message from group that I left or don't know about from: %@.", DDLogInfo(@"%@ Received message from group that I left or don't know about from: %@",
self.tag, self.tag,
incomingEnvelope.source); envelopeAddress(incomingEnvelope));
NSString *recipientId = incomingEnvelope.source; NSString *recipientId = incomingEnvelope.source;
@ -844,12 +844,12 @@ NS_ASSUME_NONNULL_BEGIN
{ {
NSString *recipientId = incomingEnvelope.source; NSString *recipientId = incomingEnvelope.source;
if (!dataMessage.hasProfileKey) { if (!dataMessage.hasProfileKey) {
OWSFail(@"%@ recevied profile key message without profile key from recipient: %@", self.tag, recipientId); OWSFail(@"%@ received profile key message without profile key from recipient: %@", self.tag, recipientId);
return; return;
} }
NSData *profileKey = dataMessage.profileKey; NSData *profileKey = dataMessage.profileKey;
if (profileKey.length != kAES256_KeyByteLength) { if (profileKey.length != kAES256_KeyByteLength) {
OWSFail(@"%@ recevied profile key of unexpected length:%lu from recipient: %@", OWSFail(@"%@ received profile key of unexpected length:%lu from recipient: %@",
self.tag, self.tag,
(unsigned long)profileKey.length, (unsigned long)profileKey.length,
recipientId); recipientId);
@ -1001,15 +1001,22 @@ NS_ASSUME_NONNULL_BEGIN
break; break;
} }
case OWSSignalServiceProtosGroupContextTypeDeliver: { case OWSSignalServiceProtosGroupContextTypeDeliver: {
incomingMessage = [[TSIncomingMessage alloc] initWithTimestamp:timestamp DDLogDebug(@"%@ incoming message from: %@ for group: %@ with timestampe: %lu",
inThread:gThread self.tag,
authorId:envelope.source envelopeAddress(envelope),
sourceDeviceId:envelope.sourceDevice groupId,
messageBody:body (unsigned long)timestamp);
attachmentIds:attachmentIds if (body.length > 0) {
expiresInSeconds:dataMessage.expireTimer]; incomingMessage = [[TSIncomingMessage alloc] initWithTimestamp:timestamp
DDLogDebug(@"%@ incoming group text message: %@", self.tag, incomingMessage.debugDescription); inThread:gThread
[incomingMessage saveWithTransaction:transaction]; authorId:envelope.source
sourceDeviceId:envelope.sourceDevice
messageBody:body
attachmentIds:attachmentIds
expiresInSeconds:dataMessage.expireTimer];
[incomingMessage saveWithTransaction:transaction];
}
break; break;
} }
default: { default: {
@ -1019,20 +1026,26 @@ NS_ASSUME_NONNULL_BEGIN
thread = gThread; thread = gThread;
} else { } else {
TSContactThread *cThread = [TSContactThread getOrCreateThreadWithContactId:envelope.source DDLogDebug(@"%@ incoming message from: %@ with timestampe: %lu",
transaction:transaction self.tag,
relay:envelope.relay]; envelopeAddress(envelope),
(unsigned long)timestamp);
incomingMessage = [[TSIncomingMessage alloc] initWithTimestamp:timestamp if (body.length > 0) {
inThread:cThread TSContactThread *cThread = [TSContactThread getOrCreateThreadWithContactId:envelope.source
authorId:[cThread contactIdentifier] transaction:transaction
sourceDeviceId:envelope.sourceDevice relay:envelope.relay];
messageBody:body
attachmentIds:attachmentIds incomingMessage = [[TSIncomingMessage alloc] initWithTimestamp:timestamp
expiresInSeconds:dataMessage.expireTimer]; inThread:cThread
DDLogDebug(@"%@ incoming 1:1 text message: %@", self.tag, incomingMessage.debugDescription); authorId:[cThread contactIdentifier]
[incomingMessage saveWithTransaction:transaction]; sourceDeviceId:envelope.sourceDevice
thread = cThread; messageBody:body
attachmentIds:attachmentIds
expiresInSeconds:dataMessage.expireTimer];
[incomingMessage saveWithTransaction:transaction];
thread = cThread;
}
} }
if (thread && incomingMessage) { if (thread && incomingMessage) {
@ -1048,7 +1061,7 @@ NS_ASSUME_NONNULL_BEGIN
// Other clients allow attachments to be sent along with body, we want the text displayed as a separate // Other clients allow attachments to be sent along with body, we want the text displayed as a separate
// message // message
if ([attachmentIds count] > 0 && body != nil && ![body isEqualToString:@""]) { if ([attachmentIds count] > 0 && body != nil && body.length > 0) {
// We want the text to be displayed under the attachment // We want the text to be displayed under the attachment
uint64_t textMessageTimestamp = timestamp + 1; uint64_t textMessageTimestamp = timestamp + 1;
TSIncomingMessage *textMessage = [[TSIncomingMessage alloc] initWithTimestamp:textMessageTimestamp TSIncomingMessage *textMessage = [[TSIncomingMessage alloc] initWithTimestamp:textMessageTimestamp
@ -1064,7 +1077,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
}]; }];
if (incomingMessage && thread) { if (thread && incomingMessage) {
// In case we already have a read receipt for this new message (happens sometimes). // In case we already have a read receipt for this new message (happens sometimes).
OWSReadReceiptsProcessor *readReceiptsProcessor = OWSReadReceiptsProcessor *readReceiptsProcessor =
[[OWSReadReceiptsProcessor alloc] initWithIncomingMessage:incomingMessage [[OWSReadReceiptsProcessor alloc] initWithIncomingMessage:incomingMessage
@ -1114,10 +1127,7 @@ NS_ASSUME_NONNULL_BEGIN
} else if ([exception.name isEqualToString:UntrustedIdentityKeyException]) { } else if ([exception.name isEqualToString:UntrustedIdentityKeyException]) {
// Should no longer get here, since we now record the new identity for incoming messages. // Should no longer get here, since we now record the new identity for incoming messages.
OWSProdErrorWEnvelope([OWSAnalyticsEvents messageManagerErrorUntrustedIdentityKeyException], envelope); OWSProdErrorWEnvelope([OWSAnalyticsEvents messageManagerErrorUntrustedIdentityKeyException], envelope);
OWSFail(@"%@ Failed to trust identity on incoming message from: %@.%d", OWSFail(@"%@ Failed to trust identity on incoming message from: %@", self.tag, envelopeAddress(envelope));
self.tag,
envelope.source,
(unsigned int)envelope.sourceDevice);
return; return;
} else { } else {
OWSProdErrorWEnvelope([OWSAnalyticsEvents messageManagerErrorCorruptMessage], envelope); OWSProdErrorWEnvelope([OWSAnalyticsEvents messageManagerErrorCorruptMessage], envelope);
@ -1140,6 +1150,12 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - helpers #pragma mark - helpers
// used in log formatting
NSString *envelopeAddress(OWSSignalServiceProtosEnvelope *envelope)
{
return [NSString stringWithFormat:@"%@.%d", envelope.source, (unsigned int)envelope.sourceDevice];
}
- (BOOL)isDataMessageGroupAvatarUpdate:(OWSSignalServiceProtosDataMessage *)dataMessage - (BOOL)isDataMessageGroupAvatarUpdate:(OWSSignalServiceProtosDataMessage *)dataMessage
{ {
return dataMessage.hasGroup return dataMessage.hasGroup

Loading…
Cancel
Save