Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
signalapp
GitHub Repository: signalapp/Signal-iOS
Path: blob/main/SignalServiceKit/Messages/Interactions/Quotes/TSQuotedMessage.h
1 views
1
//
2
// Copyright 2018 Signal Messenger, LLC
3
// SPDX-License-Identifier: AGPL-3.0-only
4
//
5
6
@import Foundation;
7
8
NS_ASSUME_NONNULL_BEGIN
9
10
@class DBReadTransaction;
11
@class DBWriteTransaction;
12
@class DisplayableQuotedThumbnailAttachment;
13
@class MessageBodyRanges;
14
@class OWSAttachmentInfo;
15
@class QuotedThumbnailAttachmentMetadata;
16
@class SSKProtoDataMessage;
17
@class SignalServiceAddress;
18
@class TSMessage;
19
@class TSQuotedMessage;
20
@class TSThread;
21
22
@protocol QuotedMessageAttachmentHelper;
23
24
/// Note that ContentSource is NOT the same as OWSAttachmentInfoReference;
25
/// this tells us where we got the quote from (whether it has an attachment or not)
26
/// and doesn't ever change, including after downloading any attachments.
27
typedef NS_ENUM(NSUInteger, TSQuotedMessageContentSource) {
28
TSQuotedMessageContentSourceUnknown,
29
TSQuotedMessageContentSourceLocal,
30
TSQuotedMessageContentSourceRemote,
31
TSQuotedMessageContentSourceStory
32
};
33
34
35
@interface TSQuotedMessage : NSObject <NSSecureCoding, NSCopying>
36
37
@property (nullable, nonatomic, readonly) NSNumber *timestampValue;
38
@property (nonatomic, readonly) SignalServiceAddress *authorAddress;
39
@property (nonatomic, readonly) TSQuotedMessageContentSource bodySource;
40
41
// This property should be set IFF we are quoting a text message
42
// or attachment with caption.
43
@property (nullable, nonatomic, readonly) NSString *body;
44
@property (nonatomic, readonly, nullable) MessageBodyRanges *bodyRanges;
45
46
@property (nonatomic, readonly) BOOL isGiftBadge;
47
/// If we found the target message at receive time (TSQuotedMessageContentSourceLocal),
48
/// true if that target message was view once.
49
/// If we did not find the target message (TSQuotedMessageContentSourceRemote), will always
50
/// be false because we do not know if the target message was view-once. In these cases, we
51
/// take the body off the Quote proto we receive.
52
/// At send time, we always set the body of the outgoing Quote proto as the localized string
53
/// that indicates this was a reply to a view-once message.
54
@property (nonatomic, readonly) BOOL isTargetMessageViewOnce;
55
56
@property (nonatomic, readonly) BOOL isPoll;
57
58
#pragma mark - Attachments
59
60
- (nullable OWSAttachmentInfo *)attachmentInfo;
61
62
+ (instancetype)new NS_UNAVAILABLE;
63
- (instancetype)init NS_UNAVAILABLE;
64
65
// used when sending quoted messages
66
- (instancetype)initWithTimestamp:(nullable NSNumber *)timestamp
67
authorAddress:(SignalServiceAddress *)authorAddress
68
body:(nullable NSString *)body
69
bodyRanges:(nullable MessageBodyRanges *)bodyRanges
70
quotedAttachmentForSending:(nullable OWSAttachmentInfo *)attachmentInfo
71
isGiftBadge:(BOOL)isGiftBadge
72
isTargetMessageViewOnce:(BOOL)isTargetMessageViewOnce
73
isPoll:(BOOL)isPoll;
74
75
// used when receiving quoted messages. Do not call directly outside AttachmentManager.
76
- (instancetype)initWithTimestamp:(uint64_t)timestamp
77
authorAddress:(SignalServiceAddress *)authorAddress
78
body:(nullable NSString *)body
79
bodyRanges:(nullable MessageBodyRanges *)bodyRanges
80
bodySource:(TSQuotedMessageContentSource)bodySource
81
receivedQuotedAttachmentInfo:(nullable OWSAttachmentInfo *)attachmentInfo
82
isGiftBadge:(BOOL)isGiftBadge
83
isTargetMessageViewOnce:(BOOL)isTargetMessageViewOnce
84
isPoll:(BOOL)isPoll;
85
86
// used when restoring quoted messages from backups
87
+ (instancetype)quotedMessageFromBackupWithTargetMessageTimestamp:(nullable NSNumber *)timestamp
88
authorAddress:(SignalServiceAddress *)authorAddress
89
body:(nullable NSString *)body
90
bodyRanges:(nullable MessageBodyRanges *)bodyRanges
91
bodySource:(TSQuotedMessageContentSource)bodySource
92
quotedAttachmentInfo:(nullable OWSAttachmentInfo *)attachmentInfo
93
isGiftBadge:(BOOL)isGiftBadge
94
isTargetMessageViewOnce:(BOOL)isTargetMessageViewOnce
95
isPoll:(BOOL)isPoll;
96
97
@end
98
99
#pragma mark -
100
101
NS_ASSUME_NONNULL_END
102
103