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
This commit is contained in:
Michael Kirk 2017-08-28 17:29:25 -04:00
parent 69e8ca8eac
commit ec0cf36abb
1 changed files with 58 additions and 42 deletions

View File

@ -167,10 +167,9 @@ NS_ASSUME_NONNULL_BEGIN
{
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],
envelope.source,
(unsigned int)envelope.sourceDevice,
envelopeAddress(envelope),
envelope.timestamp,
(unsigned long)envelope.content.length];
}
@ -296,10 +295,9 @@ NS_ASSUME_NONNULL_BEGIN
DDLogDebug(@"%@ handled secure message.", self.tag);
if (error) {
DDLogError(
@"%@ handling secure message from address: %@.%d failed with error: %@",
@"%@ handling secure message from address: %@ failed with error: %@",
self.tag,
envelope.source,
(unsigned int)envelope.sourceDevice,
envelopeAddress(envelope),
error);
OWSProdError(
[OWSAnalyticsEvents messageManagerErrorCouldNotHandleSecureMessage]);
@ -314,11 +312,10 @@ NS_ASSUME_NONNULL_BEGIN
completion:^(NSError *_Nullable error) {
DDLogDebug(@"%@ handled pre-key whisper message", self.tag);
if (error) {
DDLogError(@"%@ handling pre-key whisper message from address: %@.%d failed "
DDLogError(@"%@ handling pre-key whisper message from address: %@ failed "
@"with error: %@",
self.tag,
envelope.source,
(unsigned int)envelope.sourceDevice,
envelopeAddress(envelope),
error);
OWSProdError(
[OWSAnalyticsEvents messageManagerErrorCouldNotHandlePrekeyBundle]);
@ -478,7 +475,10 @@ NS_ASSUME_NONNULL_BEGIN
sourceId:envelope.source
sourceDeviceId:envelope.sourceDevice];
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;
}
@ -543,9 +543,9 @@ NS_ASSUME_NONNULL_BEGIN
}
// 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,
incomingEnvelope.source);
envelopeAddress(incomingEnvelope));
NSString *recipientId = incomingEnvelope.source;
@ -844,12 +844,12 @@ NS_ASSUME_NONNULL_BEGIN
{
NSString *recipientId = incomingEnvelope.source;
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;
}
NSData *profileKey = dataMessage.profileKey;
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,
(unsigned long)profileKey.length,
recipientId);
@ -1001,15 +1001,22 @@ NS_ASSUME_NONNULL_BEGIN
break;
}
case OWSSignalServiceProtosGroupContextTypeDeliver: {
incomingMessage = [[TSIncomingMessage alloc] initWithTimestamp:timestamp
inThread:gThread
authorId:envelope.source
sourceDeviceId:envelope.sourceDevice
messageBody:body
attachmentIds:attachmentIds
expiresInSeconds:dataMessage.expireTimer];
DDLogDebug(@"%@ incoming group text message: %@", self.tag, incomingMessage.debugDescription);
[incomingMessage saveWithTransaction:transaction];
DDLogDebug(@"%@ incoming message from: %@ for group: %@ with timestampe: %lu",
self.tag,
envelopeAddress(envelope),
groupId,
(unsigned long)timestamp);
if (body.length > 0) {
incomingMessage = [[TSIncomingMessage alloc] initWithTimestamp:timestamp
inThread:gThread
authorId:envelope.source
sourceDeviceId:envelope.sourceDevice
messageBody:body
attachmentIds:attachmentIds
expiresInSeconds:dataMessage.expireTimer];
[incomingMessage saveWithTransaction:transaction];
}
break;
}
default: {
@ -1019,20 +1026,26 @@ NS_ASSUME_NONNULL_BEGIN
thread = gThread;
} else {
TSContactThread *cThread = [TSContactThread getOrCreateThreadWithContactId:envelope.source
transaction:transaction
relay:envelope.relay];
DDLogDebug(@"%@ incoming message from: %@ with timestampe: %lu",
self.tag,
envelopeAddress(envelope),
(unsigned long)timestamp);
if (body.length > 0) {
TSContactThread *cThread = [TSContactThread getOrCreateThreadWithContactId:envelope.source
transaction:transaction
relay:envelope.relay];
incomingMessage = [[TSIncomingMessage alloc] initWithTimestamp:timestamp
inThread:cThread
authorId:[cThread contactIdentifier]
sourceDeviceId:envelope.sourceDevice
messageBody:body
attachmentIds:attachmentIds
expiresInSeconds:dataMessage.expireTimer];
DDLogDebug(@"%@ incoming 1:1 text message: %@", self.tag, incomingMessage.debugDescription);
[incomingMessage saveWithTransaction:transaction];
thread = cThread;
incomingMessage = [[TSIncomingMessage alloc] initWithTimestamp:timestamp
inThread:cThread
authorId:[cThread contactIdentifier]
sourceDeviceId:envelope.sourceDevice
messageBody:body
attachmentIds:attachmentIds
expiresInSeconds:dataMessage.expireTimer];
[incomingMessage saveWithTransaction:transaction];
thread = cThread;
}
}
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
// 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
uint64_t textMessageTimestamp = timestamp + 1;
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).
OWSReadReceiptsProcessor *readReceiptsProcessor =
[[OWSReadReceiptsProcessor alloc] initWithIncomingMessage:incomingMessage
@ -1114,10 +1127,7 @@ NS_ASSUME_NONNULL_BEGIN
} else if ([exception.name isEqualToString:UntrustedIdentityKeyException]) {
// Should no longer get here, since we now record the new identity for incoming messages.
OWSProdErrorWEnvelope([OWSAnalyticsEvents messageManagerErrorUntrustedIdentityKeyException], envelope);
OWSFail(@"%@ Failed to trust identity on incoming message from: %@.%d",
self.tag,
envelope.source,
(unsigned int)envelope.sourceDevice);
OWSFail(@"%@ Failed to trust identity on incoming message from: %@", self.tag, envelopeAddress(envelope));
return;
} else {
OWSProdErrorWEnvelope([OWSAnalyticsEvents messageManagerErrorCorruptMessage], envelope);
@ -1140,6 +1150,12 @@ NS_ASSUME_NONNULL_BEGIN
#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
{
return dataMessage.hasGroup