diff --git a/src/Messages/Interactions/TSIncomingMessage.h b/src/Messages/Interactions/TSIncomingMessage.h index afa4e3319..d9062f199 100644 --- a/src/Messages/Interactions/TSIncomingMessage.h +++ b/src/Messages/Interactions/TSIncomingMessage.h @@ -36,31 +36,6 @@ extern NSString *const TSIncomingMessageWasReadOnThisDeviceNotification; sourceDeviceId:(uint32_t)sourceDeviceId messageBody:(nullable NSString *)body; -/** - * Inits an incoming group message with attachments - * - * @param timestamp - * When the message was created in milliseconds since epoch - * @param thread - * Thread to which the message belongs - * @param authorId - * Signal ID (i.e. e164) of the user who sent the message - * @param sourceDeviceId - * Numeric ID of the device used to send the message. Used to detect duplicate messages. - * @param body - * Body of the message - * @param attachmentIds - * The uniqueIds for the message's attachments - * - * @return initiated incoming group message - */ -- (instancetype)initWithTimestamp:(uint64_t)timestamp - inThread:(TSThread *)thread - authorId:(NSString *)authorId - sourceDeviceId:(uint32_t)sourceDeviceId - messageBody:(nullable NSString *)body - attachmentIds:(NSArray *)attachmentIds; - /** * Inits an incoming group message that expires. * @@ -93,8 +68,8 @@ extern NSString *const TSIncomingMessageWasReadOnThisDeviceNotification; /** - * For sake of a smaller API, you must specify an author id for all incoming messages - * though we technically could get the author id from a contact thread. + * For sake of a smaller API, and simplifying assumptions elsewhere, you must specify an author id for *all* incoming + * messages, even though we technically could infer the author id for a contact threads. */ - (instancetype)initWithTimestamp:(uint64_t)timestamp NS_UNAVAILABLE; - (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread NS_UNAVAILABLE; diff --git a/src/Messages/Interactions/TSIncomingMessage.m b/src/Messages/Interactions/TSIncomingMessage.m index d03df08fc..c91ea7cce 100644 --- a/src/Messages/Interactions/TSIncomingMessage.m +++ b/src/Messages/Interactions/TSIncomingMessage.m @@ -30,22 +30,7 @@ NSString *const TSIncomingMessageWasReadOnThisDeviceNotification = @"TSIncomingM authorId:authorId sourceDeviceId:sourceDeviceId messageBody:body - attachmentIds:@[]]; -} - -- (instancetype)initWithTimestamp:(uint64_t)timestamp - inThread:(TSThread *)thread - authorId:(NSString *)authorId - sourceDeviceId:(uint32_t)sourceDeviceId - messageBody:(nullable NSString *)body - attachmentIds:(NSArray *)attachmentIds -{ - return [self initWithTimestamp:timestamp - inThread:thread - authorId:authorId - sourceDeviceId:sourceDeviceId - messageBody:body - attachmentIds:attachmentIds + attachmentIds:@[] expiresInSeconds:0]; } diff --git a/src/Messages/TSMessagesManager.m b/src/Messages/TSMessagesManager.m index 00114498e..7eddd0124 100644 --- a/src/Messages/TSMessagesManager.m +++ b/src/Messages/TSMessagesManager.m @@ -662,27 +662,18 @@ NS_ASSUME_NONNULL_BEGIN [incomingMessage markAsReadLocallyWithTransaction:transaction]; } - // Android allows attachments to be sent with body. + // 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:@""]) { // We want the text to be displayed under the attachment uint64_t textMessageTimestamp = timestamp + 1; - TSIncomingMessage *textMessage; - if ([thread isGroupThread]) { - TSGroupThread *gThread = (TSGroupThread *)thread; - textMessage = [[TSIncomingMessage alloc] initWithTimestamp:textMessageTimestamp - inThread:gThread - authorId:envelope.source - sourceDeviceId:envelope.sourceDevice - messageBody:body]; - } else { - TSContactThread *cThread = (TSContactThread *)thread; - textMessage = [[TSIncomingMessage alloc] initWithTimestamp:textMessageTimestamp - inThread:cThread - authorId:[cThread contactIdentifier] - sourceDeviceId:envelope.sourceDevice - messageBody:body]; - } - textMessage.expiresInSeconds = dataMessage.expireTimer; + TSIncomingMessage *textMessage = [[TSIncomingMessage alloc] initWithTimestamp:textMessageTimestamp + inThread:thread + authorId:envelope.source + sourceDeviceId:envelope.sourceDevice + messageBody:body + attachmentIds:@[] + expiresInSeconds:dataMessage.expireTimer]; [textMessage saveWithTransaction:transaction]; } }