mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Code cleanup.
No need to use contactThread method to get recipient ID since we still have the envelope. And with that, it's pretty easy to justify getting rid of one of our now barely used IncomingMessage initializers. // FREEBIE
This commit is contained in:
parent
975726e022
commit
b389bb3bb8
|
@ -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<NSString *> *)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;
|
||||
|
|
|
@ -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<NSString *> *)attachmentIds
|
||||
{
|
||||
return [self initWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
authorId:authorId
|
||||
sourceDeviceId:sourceDeviceId
|
||||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
attachmentIds:@[]
|
||||
expiresInSeconds:0];
|
||||
}
|
||||
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue