mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge branch 'charlesmchen/linkPreviews2'
This commit is contained in:
commit
74ccee26a8
49 changed files with 324 additions and 107 deletions
2
Pods
2
Pods
|
@ -1 +1 @@
|
|||
Subproject commit b46f53105951613fedd8117b83931f43f6ab12f1
|
||||
Subproject commit ea60f60ea01bc51fc2434248890b494e37da98a5
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
@ -452,6 +452,7 @@ private class MockIncomingMessage: TSIncomingMessage {
|
|||
expiresInSeconds: 0,
|
||||
quotedMessage: nil,
|
||||
contactShare: nil,
|
||||
linkPreview: nil,
|
||||
serverTimestamp: nil,
|
||||
wasReceivedByUD: false)
|
||||
}
|
||||
|
@ -481,7 +482,8 @@ private class MockOutgoingMessage: TSOutgoingMessage {
|
|||
isVoiceMessage: false,
|
||||
groupMetaMessage: .unspecified,
|
||||
quotedMessage: nil,
|
||||
contactShare: nil)
|
||||
contactShare: nil,
|
||||
linkPreview: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DebugUIMessages.h"
|
||||
|
@ -879,6 +879,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isRead:NO
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
transaction:transaction];
|
||||
|
||||
// This is a hack to "back-date" the message.
|
||||
|
@ -1775,6 +1776,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isRead:NO
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
transaction:transaction];
|
||||
}];
|
||||
}
|
||||
|
@ -1823,6 +1825,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isRead:isRead
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
transaction:transaction];
|
||||
}];
|
||||
}
|
||||
|
@ -2006,6 +2009,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isRead:quotedMessageIsRead
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
transaction:transaction];
|
||||
OWSAssertDebug(messageToQuote);
|
||||
|
||||
|
@ -2038,6 +2042,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isRead:replyIsRead
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
transaction:transaction];
|
||||
}
|
||||
}
|
||||
|
@ -2887,6 +2892,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isRead:NO
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
transaction:transaction];
|
||||
[message setReceivedAtTimestamp:(uint64_t)((int64_t)[NSDate ows_millisecondTimeStamp] + dateOffset)];
|
||||
[message saveWithTransaction:transaction];
|
||||
|
@ -2957,6 +2963,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
isRead:NO
|
||||
quotedMessage:nil
|
||||
contactShare:contact
|
||||
linkPreview:nil
|
||||
transaction:transaction];
|
||||
[message saveWithTransaction:transaction];
|
||||
}];
|
||||
|
@ -3757,6 +3764,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
serverTimestamp:nil
|
||||
wasReceivedByUD:NO];
|
||||
[message markAsReadNowWithSendReadReceipt:NO transaction:transaction];
|
||||
|
@ -3771,6 +3779,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
isRead:NO
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
transaction:transaction];
|
||||
break;
|
||||
}
|
||||
|
@ -3801,6 +3810,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
serverTimestamp:nil
|
||||
wasReceivedByUD:NO];
|
||||
[message markAsReadNowWithSendReadReceipt:NO transaction:transaction];
|
||||
|
@ -3831,6 +3841,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
isVoiceMessage:NO
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
transaction:transaction];
|
||||
break;
|
||||
}
|
||||
|
@ -4197,7 +4208,8 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
OWSLogError(@"resurrectNewOutgoingMessages2 timestamp: %llu.", message.timestamp);
|
||||
[messages addObject:message];
|
||||
}
|
||||
|
@ -4265,6 +4277,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
serverTimestamp:nil
|
||||
wasReceivedByUD:NO];
|
||||
[message markAsReadNowWithSendReadReceipt:NO transaction:transaction];
|
||||
|
@ -4281,7 +4294,8 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
[message saveWithTransaction:transaction];
|
||||
[message updateWithFakeMessageState:TSOutgoingMessageStateSent transaction:transaction];
|
||||
[message updateWithSentRecipient:recipientId wasSentByUD:NO transaction:transaction];
|
||||
|
@ -4310,6 +4324,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
expiresInSeconds:60
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
serverTimestamp:nil
|
||||
wasReceivedByUD:NO];
|
||||
// private setter to avoid starting expire machinery.
|
||||
|
@ -4479,6 +4494,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
isRead:(BOOL)isRead
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
OWSAssertDebug(thread);
|
||||
|
@ -4505,6 +4521,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
isVoiceMessage:attachment.isVoiceMessage
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare
|
||||
linkPreview:linkPreview
|
||||
transaction:transaction];
|
||||
}
|
||||
|
||||
|
@ -4518,6 +4535,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
OWSAssertDebug(thread);
|
||||
|
@ -4540,7 +4558,8 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
isVoiceMessage:isVoiceMessage
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare];
|
||||
contactShare:contactShare
|
||||
linkPreview:linkPreview];
|
||||
|
||||
if (attachmentId.length > 0 && filename.length > 0) {
|
||||
message.attachmentFilenameMap[attachmentId] = filename;
|
||||
|
@ -4630,6 +4649,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
expiresInSeconds:0
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
serverTimestamp:nil
|
||||
wasReceivedByUD:NO];
|
||||
[message markAsReadNowWithSendReadReceipt:NO transaction:transaction];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSOrphanDataCleaner.h"
|
||||
|
@ -81,7 +81,8 @@
|
|||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
[incomingMessage save];
|
||||
|
||||
return incomingMessage;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ThreadUtil.h"
|
||||
|
@ -134,7 +134,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:isVoiceMessage
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:[quotedReplyModel buildQuotedMessageForSending]
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
|
||||
NSMutableArray<OWSOutgoingAttachmentInfo *> *attachmentInfos = [NSMutableArray new];
|
||||
for (SignalAttachment *attachment in attachments) {
|
||||
|
@ -167,7 +168,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:contactShare];
|
||||
contactShare:contactShare
|
||||
linkPreview:nil];
|
||||
|
||||
[self.dbConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
[message saveWithTransaction:transaction];
|
||||
|
@ -246,7 +248,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:isVoiceMessage
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:[quotedReplyModel buildQuotedMessageForSending]
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
|
||||
NSMutableArray<OWSOutgoingAttachmentInfo *> *attachmentInfos = [NSMutableArray new];
|
||||
for (SignalAttachment *attachment in attachments) {
|
||||
|
@ -303,7 +306,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:contactShare];
|
||||
contactShare:contactShare
|
||||
linkPreview:nil];
|
||||
|
||||
[messageSender sendMessage:message
|
||||
success:^{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSOutgoingSyncMessage.h"
|
||||
|
@ -19,7 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE;
|
||||
|
||||
+ (OWSReceiptsForSenderMessage *)deliveryReceiptsForSenderMessageWithThread:(nullable TSThread *)thread
|
||||
messageTimestamps:(NSArray<NSNumber *> *)messageTimestamps;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSReceiptsForSenderMessage.h"
|
||||
|
@ -51,7 +51,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSRecordTranscriptJob.h"
|
||||
|
@ -109,7 +109,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:transcript.quotedMessage
|
||||
contactShare:transcript.contact];
|
||||
contactShare:transcript.contact
|
||||
linkPreview:transcript.linkPreview];
|
||||
|
||||
NSArray<TSAttachmentPointer *> *attachmentPointers =
|
||||
[TSAttachmentPointer attachmentPointersFromProtos:transcript.attachmentPointerProtos
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class OWSContact;
|
||||
@class OWSLinkPreview;
|
||||
@class SSKProtoAttachmentPointer;
|
||||
@class SSKProtoDataMessage;
|
||||
@class SSKProtoSyncMessageSent;
|
||||
|
@ -35,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property (nonatomic, readonly) TSThread *thread;
|
||||
@property (nonatomic, readonly, nullable) TSQuotedMessage *quotedMessage;
|
||||
@property (nonatomic, readonly, nullable) OWSContact *contact;
|
||||
@property (nonatomic, readonly, nullable) OWSLinkPreview *linkPreview;
|
||||
|
||||
// If either nonUdRecipientIds or udRecipientIds is nil,
|
||||
// this is either a legacy transcript or it reflects a legacy sync message.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSIncomingSentMessageTranscript.h"
|
||||
|
@ -45,6 +45,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
_quotedMessage = [TSQuotedMessage quotedMessageForDataMessage:_dataMessage thread:_thread transaction:transaction];
|
||||
_contact = [OWSContacts contactForDataMessage:_dataMessage transaction:transaction];
|
||||
_linkPreview =
|
||||
[OWSLinkPreview buildValidatedLinkPreviewWithDataMessage:_dataMessage body:_body transaction:transaction];
|
||||
|
||||
if (sentProto.unidentifiedStatus.count > 0) {
|
||||
NSMutableArray<NSString *> *nonUdRecipientIds = [NSMutableArray new];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSOutgoingMessage.h"
|
||||
|
@ -22,7 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSOutgoingSyncMessage.h"
|
||||
|
@ -29,7 +29,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSOutgoingSyncMessage.h"
|
||||
|
@ -17,7 +17,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithThread:(nullable TSThread *)thread groupId:(NSData *)groupId;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSSyncGroupsRequestMessage.h"
|
||||
|
@ -30,7 +30,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSContact.h"
|
||||
|
@ -509,8 +509,8 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
|
|||
|
||||
- (void)removeAvatarAttachmentWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
TSAttachmentStream *_Nullable attachment =
|
||||
[TSAttachmentStream fetchObjectWithUniqueID:self.avatarAttachmentId transaction:transaction];
|
||||
TSAttachment *_Nullable attachment =
|
||||
[TSAttachment fetchObjectWithUniqueID:self.avatarAttachmentId transaction:transaction];
|
||||
[attachment removeWithTransaction:transaction];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSOutgoingMessage.h"
|
||||
|
@ -20,7 +20,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithConfiguration:(OWSDisappearingMessagesConfiguration *)configuration thread:(TSThread *)thread;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSDisappearingMessagesConfigurationMessage.h"
|
||||
|
@ -36,7 +36,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSOutgoingMessage.h"
|
||||
|
@ -23,7 +23,8 @@ typedef NSData *_Nonnull (^DynamicOutgoingMessageBlock)(SignalRecipient *);
|
|||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block thread:(nullable TSThread *)thread;
|
||||
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSDynamicOutgoingMessage.h"
|
||||
|
@ -37,7 +37,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
|
||||
if (self) {
|
||||
_block = block;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSOutgoingMessage.h"
|
||||
|
@ -18,7 +18,8 @@ NS_SWIFT_NAME(EndSessionMessage)
|
|||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE;
|
||||
|
||||
// MJK TODO can we remove the sender timestamp?
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread NS_DESIGNATED_INITIALIZER;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSEndSessionMessage.h"
|
||||
|
@ -25,7 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
}
|
||||
|
||||
- (BOOL)shouldBeSaved
|
||||
|
|
100
SignalServiceKit/src/Messages/Interactions/OWSLinkPreview.swift
Normal file
100
SignalServiceKit/src/Messages/Interactions/OWSLinkPreview.swift
Normal file
|
@ -0,0 +1,100 @@
|
|||
//
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc(OWSLinkPreview)
|
||||
public class OWSLinkPreview: MTLModel {
|
||||
@objc
|
||||
public var urlString: String?
|
||||
|
||||
@objc
|
||||
public var title: String?
|
||||
|
||||
@objc
|
||||
public var attachmentId: String?
|
||||
|
||||
@objc
|
||||
public init(urlString: String, title: String?, attachmentId: String?) {
|
||||
self.urlString = urlString
|
||||
self.title = title
|
||||
self.attachmentId = attachmentId
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
@objc
|
||||
public required init!(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
}
|
||||
|
||||
@objc
|
||||
public required init(dictionary dictionaryValue: [AnyHashable: Any]!) throws {
|
||||
try super.init(dictionary: dictionaryValue)
|
||||
}
|
||||
|
||||
@objc
|
||||
public class func buildValidatedLinkPreview(dataMessage: SSKProtoDataMessage,
|
||||
body: String?,
|
||||
transaction: YapDatabaseReadWriteTransaction) -> OWSLinkPreview? {
|
||||
guard let previewProto = dataMessage.preview else {
|
||||
return nil
|
||||
}
|
||||
let urlString = previewProto.url
|
||||
|
||||
guard URL(string: urlString) != nil else {
|
||||
owsFailDebug("Could not parse preview URL.")
|
||||
return nil
|
||||
}
|
||||
|
||||
guard let body = body else {
|
||||
owsFailDebug("Preview for message without body.")
|
||||
return nil
|
||||
}
|
||||
let bodyComponents = body.components(separatedBy: .whitespacesAndNewlines)
|
||||
guard bodyComponents.contains(urlString) else {
|
||||
owsFailDebug("URL not present in body.")
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: Verify that url host is in whitelist.
|
||||
|
||||
let title: String? = previewProto.title?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
|
||||
var imageAttachmentId: String?
|
||||
if let imageProto = previewProto.image {
|
||||
if let imageAttachmentPointer = TSAttachmentPointer(fromProto: imageProto, albumMessage: nil) {
|
||||
imageAttachmentPointer.save(with: transaction)
|
||||
imageAttachmentId = imageAttachmentPointer.uniqueId
|
||||
} else {
|
||||
owsFailDebug("Could not parse image proto.")
|
||||
}
|
||||
}
|
||||
|
||||
var hasTitle = false
|
||||
if let titleValue = title {
|
||||
hasTitle = titleValue.count > 0
|
||||
}
|
||||
let hasImage = imageAttachmentId != nil
|
||||
if !hasTitle && !hasImage {
|
||||
owsFailDebug("Preview has neither title nor image.")
|
||||
return nil
|
||||
}
|
||||
|
||||
return OWSLinkPreview(urlString: urlString, title: title, attachmentId: imageAttachmentId)
|
||||
}
|
||||
|
||||
@objc
|
||||
public func removeAttachment(transaction: YapDatabaseReadWriteTransaction) {
|
||||
guard let attachmentId = attachmentId else {
|
||||
owsFailDebug("No attachment id.")
|
||||
return
|
||||
}
|
||||
guard let attachment = TSAttachment.fetch(uniqueId: attachmentId, transaction: transaction) else {
|
||||
owsFailDebug("Could not load attachment.")
|
||||
return
|
||||
}
|
||||
attachment.remove(with: transaction)
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSReadTracking.h"
|
||||
|
@ -35,7 +35,8 @@ typedef NS_ENUM(int32_t, TSErrorMessageType) {
|
|||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contact NS_UNAVAILABLE;
|
||||
contactShare:(nullable OWSContact *)contact
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSErrorMessage.h"
|
||||
|
@ -60,7 +60,8 @@ NSUInteger TSErrorMessageSchemaVersion = 1;
|
|||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSReadTracking.h"
|
||||
|
@ -23,7 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* Inits an incoming group message that expires.
|
||||
|
@ -56,6 +57,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview
|
||||
serverTimestamp:(nullable NSNumber *)serverTimestamp
|
||||
wasReceivedByUD:(BOOL)wasReceivedByUD NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSIncomingMessage.h"
|
||||
|
@ -52,8 +52,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview
|
||||
serverTimestamp:(nullable NSNumber *)serverTimestamp
|
||||
wasReceivedByUD:(BOOL)wasReceivedByUD {
|
||||
wasReceivedByUD:(BOOL)wasReceivedByUD
|
||||
{
|
||||
self = [super initMessageWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
messageBody:body
|
||||
|
@ -61,7 +63,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare];
|
||||
contactShare:contactShare
|
||||
linkPreview:linkPreview];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSReadTracking.h"
|
||||
|
@ -36,7 +36,8 @@ typedef NS_ENUM(NSInteger, TSInfoMessageType) {
|
|||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contact NS_UNAVAILABLE;
|
||||
contactShare:(nullable OWSContact *)contact
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSInfoMessage.h"
|
||||
|
@ -56,7 +56,8 @@ NSUInteger TSInfoMessageSchemaVersion = 1;
|
|||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSInteraction.h"
|
||||
|
@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*/
|
||||
|
||||
@class OWSContact;
|
||||
@class OWSLinkPreview;
|
||||
@class TSAttachment;
|
||||
@class TSAttachmentStream;
|
||||
@class TSQuotedMessage;
|
||||
|
@ -26,6 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property (nonatomic, readonly) BOOL isExpiringMessage;
|
||||
@property (nonatomic, readonly, nullable) TSQuotedMessage *quotedMessage;
|
||||
@property (nonatomic, readonly, nullable) OWSContact *contactShare;
|
||||
@property (nonatomic, readonly, nullable) OWSLinkPreview *linkPreview;
|
||||
|
||||
- (instancetype)initInteractionWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_UNAVAILABLE;
|
||||
|
||||
|
@ -36,7 +38,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_DESIGNATED_INITIALIZER;
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSMessage.h"
|
||||
|
@ -13,6 +13,7 @@
|
|||
#import "TSQuotedMessage.h"
|
||||
#import "TSThread.h"
|
||||
#import <SignalCoreKit/NSDate+OWS.h>
|
||||
#import <SignalServiceKit/SignalServiceKit-Swift.h>
|
||||
#import <YapDatabase/YapDatabase.h>
|
||||
#import <YapDatabase/YapDatabaseTransaction.h>
|
||||
|
||||
|
@ -61,6 +62,7 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview
|
||||
{
|
||||
self = [super initInteractionWithTimestamp:timestamp inThread:thread];
|
||||
|
||||
|
@ -77,6 +79,7 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
[self updateExpiresAt];
|
||||
_quotedMessage = quotedMessage;
|
||||
_contactShare = contactShare;
|
||||
_linkPreview = linkPreview;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -348,6 +351,10 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
[self.contactShare removeAvatarAttachmentWithTransaction:transaction];
|
||||
}
|
||||
|
||||
if (self.linkPreview.attachmentId) {
|
||||
[self.linkPreview removeAttachmentWithTransaction:transaction];
|
||||
}
|
||||
|
||||
// Updates inbox thread preview
|
||||
[self touchThreadWithTransaction:transaction];
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSMessage.h"
|
||||
|
@ -77,7 +77,8 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
|
|||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE;
|
||||
|
||||
// MJK TODO - Can we remove the sender timestamp param?
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
|
@ -89,7 +90,8 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
|
|||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_DESIGNATED_INITIALIZER;
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSOutgoingMessage.h"
|
||||
|
@ -267,7 +267,8 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
}
|
||||
|
||||
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
|
||||
|
@ -284,7 +285,8 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:groupMetaMessage
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
}
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
|
@ -297,6 +299,7 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
|
|||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview
|
||||
{
|
||||
self = [super initMessageWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
|
@ -305,7 +308,8 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
|
|||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:expireStartedAt
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare];
|
||||
contactShare:contactShare
|
||||
linkPreview:linkPreview];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -1287,6 +1287,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
thread:oldGroupThread
|
||||
transaction:transaction];
|
||||
|
||||
OWSLinkPreview *_Nullable linkPreview =
|
||||
[OWSLinkPreview buildValidatedLinkPreviewWithDataMessage:dataMessage
|
||||
body:body
|
||||
transaction:transaction];
|
||||
|
||||
OWSLogDebug(@"incoming message from: %@ for group: %@ with timestamp: %lu",
|
||||
envelopeAddress(envelope),
|
||||
groupId,
|
||||
|
@ -1303,6 +1308,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:dataMessage.expireTimer
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contact
|
||||
linkPreview:linkPreview
|
||||
serverTimestamp:serverTimestamp
|
||||
wasReceivedByUD:wasReceivedByUD];
|
||||
|
||||
|
@ -1349,6 +1355,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
thread:thread
|
||||
transaction:transaction];
|
||||
|
||||
OWSLinkPreview *_Nullable linkPreview =
|
||||
[OWSLinkPreview buildValidatedLinkPreviewWithDataMessage:dataMessage body:body transaction:transaction];
|
||||
|
||||
// Legit usage of senderTimestamp when creating incoming message from received envelope
|
||||
TSIncomingMessage *incomingMessage =
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithTimestamp:timestamp
|
||||
|
@ -1360,6 +1369,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:dataMessage.expireTimer
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contact
|
||||
linkPreview:linkPreview
|
||||
serverTimestamp:serverTimestamp
|
||||
wasReceivedByUD:wasReceivedByUD];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSOutgoingMessage.h"
|
||||
|
@ -27,7 +27,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithThread:(TSThread *)thread offerMessage:(SSKProtoCallMessageOffer *)offerMessage;
|
||||
- (instancetype)initWithThread:(TSThread *)thread answerMessage:(SSKProtoCallMessageAnswer *)answerMessage;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSOutgoingCallMessage.h"
|
||||
|
@ -25,7 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSOutgoingMessage.h"
|
||||
|
@ -20,7 +20,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithContactThread:(TSContactThread *)contactThread
|
||||
verificationStateSyncMessage:(OWSVerificationStateSyncMessage *)verificationStateSyncMessage;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSOutgoingNullMessage.h"
|
||||
|
@ -34,7 +34,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSOutgoingMessage.h"
|
||||
|
@ -17,7 +17,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContact *)contactShare NS_UNAVAILABLE;
|
||||
contactShare:(nullable OWSContact *)contactShare
|
||||
linkPreview:(nullable OWSLinkPreview *)linkPreview NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread NS_DESIGNATED_INITIALIZER;
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSProfileKeyMessage.h"
|
||||
|
@ -23,7 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
@ -30,7 +30,8 @@ public class TypingIndicatorMessage: TSOutgoingMessage {
|
|||
isVoiceMessage: false,
|
||||
groupMetaMessage: .unspecified,
|
||||
quotedMessage: nil,
|
||||
contactShare: nil)
|
||||
contactShare: nil,
|
||||
linkPreview: nil)
|
||||
}
|
||||
|
||||
@objc
|
||||
|
|
|
@ -137,7 +137,8 @@ public class OutgoingMessageFactory: NSObject, Factory {
|
|||
isVoiceMessage: isVoiceMessageBuilder(),
|
||||
groupMetaMessage: groupMetaMessageBuilder(),
|
||||
quotedMessage: quotedMessageBuilder(),
|
||||
contactShare: contactShareBuilder())
|
||||
contactShare: contactShareBuilder(),
|
||||
linkPreview: linkPreviewBuilder())
|
||||
|
||||
return item
|
||||
}
|
||||
|
@ -204,6 +205,11 @@ public class OutgoingMessageFactory: NSObject, Factory {
|
|||
return nil
|
||||
}
|
||||
|
||||
@objc
|
||||
public var linkPreviewBuilder: () -> OWSLinkPreview? = {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MARK: Delivery Receipts
|
||||
|
||||
@objc
|
||||
|
@ -244,6 +250,7 @@ class IncomingMessageFactory: NSObject, Factory {
|
|||
expiresInSeconds: expiresInSecondsBuilder(),
|
||||
quotedMessage: quotedMessageBuilder(),
|
||||
contactShare: contactShareBuilder(),
|
||||
linkPreview: linkPreviewBuilder(),
|
||||
serverTimestamp: serverTimestampBuilder(),
|
||||
wasReceivedByUD: wasReceivedByUDBuilder())
|
||||
|
||||
|
@ -301,6 +308,11 @@ class IncomingMessageFactory: NSObject, Factory {
|
|||
return nil
|
||||
}
|
||||
|
||||
@objc
|
||||
public var linkPreviewBuilder: () -> OWSLinkPreview? = {
|
||||
return nil
|
||||
}
|
||||
|
||||
@objc
|
||||
public var serverTimestampBuilder: () -> NSNumber? = {
|
||||
return nil
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSDevice.h"
|
||||
|
@ -49,6 +49,7 @@
|
|||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
serverTimestamp:nil
|
||||
wasReceivedByUD:NO];
|
||||
[incomingMessage save];
|
||||
|
@ -63,7 +64,8 @@
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
[outgoingMessage save];
|
||||
|
||||
XCTAssertEqual(2, [thread numberOfInteractions]);
|
||||
|
@ -100,6 +102,7 @@
|
|||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
serverTimestamp:nil
|
||||
wasReceivedByUD:NO];
|
||||
[incomingMessage save];
|
||||
|
@ -122,7 +125,8 @@
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
[outgoingMessage save];
|
||||
|
||||
// Sanity check
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSMessage.h"
|
||||
|
@ -37,7 +37,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:100
|
||||
expireStartedAt:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
|
||||
XCTAssertEqual(0, message.expiresAt);
|
||||
}
|
||||
|
@ -54,7 +55,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:expirationSeconds
|
||||
expireStartedAt:now
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
XCTAssertEqual(now + expirationMs, message.expiresAt);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSOutgoingMessage.h"
|
||||
|
@ -42,7 +42,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
[self readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
XCTAssertFalse([message shouldStartExpireTimerWithTransaction:transaction]);
|
||||
}];
|
||||
|
@ -60,7 +61,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
[self readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[message updateWithSentRecipient:self.contactId wasSentByUD:NO transaction:transaction];
|
||||
XCTAssertTrue([message shouldStartExpireTimerWithTransaction:transaction]);
|
||||
|
@ -79,7 +81,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
[self readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
XCTAssertFalse([message shouldStartExpireTimerWithTransaction:transaction]);
|
||||
}];
|
||||
|
@ -97,7 +100,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
[self readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[message updateWithMarkingAllUnsentRecipientsAsSendingWithTransaction:transaction];
|
||||
XCTAssertFalse([message shouldStartExpireTimerWithTransaction:transaction]);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MockSSKEnvironment.h"
|
||||
|
@ -70,7 +70,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:expireStartedAt
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
}
|
||||
|
||||
- (void)testExpiredMessages
|
||||
|
@ -82,7 +83,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:1
|
||||
expireStartedAt:self.now - 20000
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
[expiredMessage1 save];
|
||||
|
||||
TSMessage *expiredMessage2 =
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSDisappearingMessagesJob.h"
|
||||
|
@ -49,7 +49,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:expireStartedAt
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
}
|
||||
|
||||
#ifdef BROKEN_TESTS
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSDevice.h"
|
||||
|
@ -55,6 +55,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
linkPreview:nil
|
||||
serverTimestamp:nil
|
||||
wasReceivedByUD:NO];
|
||||
[incomingMessage save];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSMessageSender.h"
|
||||
|
@ -239,7 +239,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
[self.unexpiringMessage save];
|
||||
|
||||
self.expiringMessage = [[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:1
|
||||
|
@ -251,7 +252,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
[self.expiringMessage save];
|
||||
|
||||
OWSPrimaryStorage *storageManager = [OWSPrimaryStorage sharedManager];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSPrimaryStorage.h"
|
||||
|
@ -59,7 +59,8 @@
|
|||
attachmentIds:@[]
|
||||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
|
||||
[self readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[newMessage saveWithTransaction:transaction];
|
||||
|
@ -93,7 +94,8 @@
|
|||
attachmentIds:@[]
|
||||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
|
||||
[messages addObject:newMessage];
|
||||
[newMessage save];
|
||||
|
@ -147,7 +149,8 @@
|
|||
attachmentIds:@[]
|
||||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
contactShare:nil
|
||||
linkPreview:nil];
|
||||
[newMessage save];
|
||||
[messages addObject:newMessage];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue