2017-02-07 21:09:04 +01:00
|
|
|
//
|
2018-02-07 18:44:09 +01:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2017-02-07 21:09:04 +01:00
|
|
|
//
|
2015-12-07 03:31:43 +01:00
|
|
|
|
2017-02-07 21:09:04 +01:00
|
|
|
#import "OWSReadTracking.h"
|
2015-12-07 03:31:43 +01:00
|
|
|
#import "TSMessage.h"
|
|
|
|
|
2016-08-29 00:48:35 +02:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2016-07-28 01:58:49 +02:00
|
|
|
@class TSContactThread;
|
|
|
|
@class TSGroupThread;
|
|
|
|
|
2017-02-07 21:09:04 +01:00
|
|
|
@interface TSIncomingMessage : TSMessage <OWSReadTracking>
|
2015-12-07 03:31:43 +01:00
|
|
|
|
2018-02-07 18:44:09 +01:00
|
|
|
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
|
|
|
|
inThread:(nullable TSThread *)thread
|
|
|
|
messageBody:(nullable NSString *)body
|
|
|
|
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
|
|
|
expiresInSeconds:(uint32_t)expiresInSeconds
|
|
|
|
expireStartedAt:(uint64_t)expireStartedAt
|
2018-04-27 22:14:25 +02:00
|
|
|
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
2018-05-01 17:26:01 +02:00
|
|
|
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
2016-08-29 00:48:35 +02:00
|
|
|
|
2016-10-05 17:42:44 +02:00
|
|
|
/**
|
|
|
|
* Inits an incoming group message that expires.
|
|
|
|
*
|
|
|
|
* @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
|
2017-02-16 00:32:27 +01:00
|
|
|
* @param sourceDeviceId
|
|
|
|
* Numeric ID of the device used to send the message. Used to detect duplicate messages.
|
2016-10-05 17:42:44 +02:00
|
|
|
* @param body
|
|
|
|
* Body of the message
|
|
|
|
* @param attachmentIds
|
|
|
|
* The uniqueIds for the message's attachments, possibly an empty list.
|
|
|
|
* @param expiresInSeconds
|
|
|
|
* Seconds from when the message is read until it is deleted.
|
2018-02-07 18:44:09 +01:00
|
|
|
* @param quotedMessage
|
|
|
|
* If this message is a quoted reply to another message, contains data about that message.
|
2016-10-05 17:42:44 +02:00
|
|
|
*
|
|
|
|
* @return initiated incoming group message
|
|
|
|
*/
|
2018-02-07 18:44:09 +01:00
|
|
|
- (instancetype)initIncomingMessageWithTimestamp:(uint64_t)timestamp
|
|
|
|
inThread:(TSThread *)thread
|
|
|
|
authorId:(NSString *)authorId
|
|
|
|
sourceDeviceId:(uint32_t)sourceDeviceId
|
|
|
|
messageBody:(nullable NSString *)body
|
|
|
|
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
|
|
|
expiresInSeconds:(uint32_t)expiresInSeconds
|
2018-04-27 21:29:19 +02:00
|
|
|
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
2018-05-01 17:26:01 +02:00
|
|
|
contactShare:(nullable OWSContact *)contactShare NS_DESIGNATED_INITIALIZER;
|
2016-10-07 01:42:52 +02:00
|
|
|
|
|
|
|
- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
|
|
|
|
2016-09-01 16:28:35 +02:00
|
|
|
/*
|
|
|
|
* Find a message matching the senderId and timestamp, if any.
|
|
|
|
*
|
|
|
|
* @param authorId
|
|
|
|
* Signal ID (i.e. e164) of the user who sent the message
|
|
|
|
* @params timestamp
|
|
|
|
* When the message was created in milliseconds since epoch
|
|
|
|
*
|
|
|
|
*/
|
2017-09-13 21:35:33 +02:00
|
|
|
+ (nullable instancetype)findMessageWithAuthorId:(NSString *)authorId
|
|
|
|
timestamp:(uint64_t)timestamp
|
|
|
|
transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
2016-09-01 16:28:35 +02:00
|
|
|
|
2017-02-22 01:21:09 +01:00
|
|
|
// This will be 0 for messages created before we were tracking sourceDeviceId
|
2017-02-16 00:32:27 +01:00
|
|
|
@property (nonatomic, readonly) UInt32 sourceDeviceId;
|
2015-12-07 03:31:43 +01:00
|
|
|
|
2017-09-21 23:09:55 +02:00
|
|
|
// NOTE: Use messageAuthorId instead wherever possible.
|
|
|
|
@property (nonatomic, readonly) NSString *authorId;
|
|
|
|
|
2017-09-21 22:58:07 +02:00
|
|
|
- (NSString *)messageAuthorId;
|
|
|
|
|
2018-04-18 02:53:27 +02:00
|
|
|
// convenience method for expiring a message which was just read
|
|
|
|
- (void)markAsReadNowWithSendReadReceipt:(BOOL)sendReadReceipt
|
|
|
|
transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
|
|
|
|
2015-12-07 03:31:43 +01:00
|
|
|
@end
|
2016-08-29 00:48:35 +02:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|