Make TSInteraction.thread non-nil.

This commit is contained in:
Matthew Chen 2019-07-18 11:53:11 -03:00
parent 9115a0320f
commit ad49533e33
71 changed files with 446 additions and 195 deletions

View File

@ -64,8 +64,11 @@ class ConversationConfigurationSyncOperation: OWSOperation {
// The current implementation works, but seems wasteful.
// Does desktop handle single group sync correctly?
// What does Android do?
let syncMessage: OWSSyncGroupsMessage = OWSSyncGroupsMessage()
guard let thread = TSAccountManager.getOrCreateLocalThreadWithSneakyTransaction() else {
owsFailDebug("Missing thread.")
return
}
let syncMessage = OWSSyncGroupsMessage(thread: thread)
var dataSource: DataSource?
self.dbConnection.read { transaction in
guard let messageData: Data = syncMessage.buildPlainTextAttachmentData(with: transaction.asAnyRead) else {

View File

@ -522,7 +522,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol {
}
}
public func notifyUser(forThreadlessErrorMessage errorMessage: TSErrorMessage, transaction: SDSAnyWriteTransaction) {
public func notifyUser(for errorMessage: ThreadlessErrorMessage, transaction: SDSAnyWriteTransaction) {
let notificationBody = errorMessage.previewText(with: transaction)
transaction.addCompletion {

View File

@ -135,6 +135,14 @@ protocol ColorPickerViewDelegate: class {
class ColorPickerView: UIView, ColorViewDelegate {
// MARK: - Dependencies
private var databaseStorage: SDSDatabaseStorage {
return SDSDatabaseStorage.shared
}
// MARK: -
private let colorViews: [ColorView]
let conversationStyle: ConversationStyle
var outgoingMessageView = OWSMessageBubbleView(forAutoLayout: ())
@ -219,19 +227,31 @@ class ColorPickerView: UIView, ColorViewDelegate {
return headerView
}
private var outgoingViewItem: MockConversationViewItem {
let thread = MockThread(contactAddress: SignalServiceAddress(phoneNumber: "+fake-id"))
let outgoingText = NSLocalizedString("COLOR_PICKER_DEMO_MESSAGE_1", comment: "The first of two messages demonstrating the chosen conversation color, by rendering this message in an outgoing message bubble.")
let outgoingItem = MockConversationViewItem(interaction: MockOutgoingMessage(messageBody: outgoingText, thread: thread))
outgoingItem.displayableBodyText = DisplayableText.displayableText(outgoingText)
outgoingItem.interactionType = .outgoingMessage
return outgoingItem
}
private var incomingViewItem: MockConversationViewItem {
let thread = MockThread(contactAddress: SignalServiceAddress(phoneNumber: "+fake-id"))
let incomingText = NSLocalizedString("COLOR_PICKER_DEMO_MESSAGE_2", comment: "The second of two messages demonstrating the chosen conversation color, by rendering this message in an incoming message bubble.")
let incomingItem = MockConversationViewItem(interaction: MockIncomingMessage(messageBody: incomingText, thread: thread))
incomingItem.displayableBodyText = DisplayableText.displayableText(incomingText)
incomingItem.interactionType = .incomingMessage
return incomingItem
}
private func updateMockConversationView() {
conversationStyle.viewWidth = max(bounds.size.width, kMinimumConversationWidth)
mockConversationView.subviews.forEach { $0.removeFromSuperview() }
// outgoing
outgoingMessageView = OWSMessageBubbleView(forAutoLayout: ())
let outgoingItem = MockConversationViewItem()
let outgoingText = NSLocalizedString("COLOR_PICKER_DEMO_MESSAGE_1", comment: "The first of two messages demonstrating the chosen conversation color, by rendering this message in an outgoing message bubble.")
outgoingItem.interaction = MockOutgoingMessage(messageBody: outgoingText)
outgoingItem.displayableBodyText = DisplayableText.displayableText(outgoingText)
outgoingItem.interactionType = .outgoingMessage
outgoingMessageView.viewItem = outgoingItem
outgoingMessageView.viewItem = outgoingViewItem
outgoingMessageView.cellMediaCache = NSCache()
outgoingMessageView.conversationStyle = conversationStyle
outgoingMessageView.configureViews()
@ -244,13 +264,7 @@ class ColorPickerView: UIView, ColorViewDelegate {
// incoming
incomingMessageView = OWSMessageBubbleView(forAutoLayout: ())
let incomingItem = MockConversationViewItem()
let incomingText = NSLocalizedString("COLOR_PICKER_DEMO_MESSAGE_2", comment: "The second of two messages demonstrating the chosen conversation color, by rendering this message in an incoming message bubble.")
incomingItem.interaction = MockIncomingMessage(messageBody: incomingText)
incomingItem.displayableBodyText = DisplayableText.displayableText(incomingText)
incomingItem.interactionType = .incomingMessage
incomingMessageView.viewItem = incomingItem
incomingMessageView.viewItem = incomingViewItem
incomingMessageView.cellMediaCache = NSCache()
incomingMessageView.conversationStyle = conversationStyle
incomingMessageView.configureViews()
@ -295,9 +309,21 @@ class ColorPickerView: UIView, ColorViewDelegate {
// MARK: Mock Classes for rendering demo conversation
@objc
private class MockThread: TSContactThread {
public override var shouldBeSaved: Bool {
return false
}
override func anyWillInsert(with transaction: SDSAnyWriteTransaction) {
// no - op
owsFailDebug("shouldn't save mock thread")
}
}
@objc
private class MockConversationViewItem: NSObject, ConversationViewItem {
var interaction: TSInteraction = TSMessage()
var interaction: TSInteraction
var interactionType: OWSInteractionType = OWSInteractionType.unknown
var quotedReply: OWSQuotedReplyModel?
var isGroupThread: Bool = false
@ -341,7 +367,9 @@ private class MockConversationViewItem: NSObject, ConversationViewItem {
var isFailedSticker: Bool = false
var perMessageExpirationState: PerMessageExpirationState = .incomingExpired
override init() {
init(interaction: TSInteraction) {
self.interaction = interaction
super.init()
}
@ -441,9 +469,9 @@ private class MockConversationViewItem: NSObject, ConversationViewItem {
}
private class MockIncomingMessage: TSIncomingMessage {
init(messageBody: String) {
init(messageBody: String, thread: TSThread) {
super.init(incomingMessageWithTimestamp: NSDate.ows_millisecondTimeStamp(),
in: TSThread(),
in: thread,
authorAddress: SignalServiceAddress(phoneNumber: "+fake-id"),
sourceDeviceId: 1,
messageBody: messageBody,
@ -476,9 +504,9 @@ private class MockIncomingMessage: TSIncomingMessage {
}
private class MockOutgoingMessage: TSOutgoingMessage {
init(messageBody: String) {
init(messageBody: String, thread: TSThread) {
super.init(outgoingMessageWithTimestamp: NSDate.ows_millisecondTimeStamp(),
in: nil,
in: thread,
messageBody: messageBody,
attachmentIds: [],
expiresInSeconds: 0,

View File

@ -1862,7 +1862,7 @@ typedef enum : NSUInteger {
[self.attachmentDownloads downloadAllAttachmentsForMessage:message
transaction:transaction
success:^(NSArray<TSAttachmentStream *> *attachmentStreams) {
OWSLogInfo(@"Successfully redownloaded attachment in thread: %@", message.thread);
OWSLogInfo(@"Successfully redownloaded attachment in thread: %@", message.threadWithSneakyTransaction);
}
failure:^(NSError *error) {
OWSLogWarn(@"Failed to redownload message with error: %@", error);

View File

@ -194,9 +194,8 @@ class DebugUINotifications: DebugUIPage {
func notifyUserForThreadlessErrorMessage() -> Guarantee<Void> {
return delayedNotificationDispatch {
self.databaseStorage.write { transaction in
let errorMessage = TSErrorMessage.corruptedMessageInUnknownThread()
self.notificationPresenter.notifyUser(forThreadlessErrorMessage: errorMessage,
let errorMessage = ThreadlessErrorMessage.corruptedMessageInUnknownThread()
self.notificationPresenter.notifyUser(for: errorMessage,
transaction: transaction)
}
}

View File

@ -45,6 +45,10 @@ class DebugUIProfile: DebugUIPage {
},
OWSTableItem(title: "Send Profile Key Message") { [weak self] in
guard let strongSelf = self else { return }
guard let aThread = aThread else {
owsFailDebug("Missing thread.")
return
}
// MJK TODO - should be safe to remove this senderTimestamp
let message = OWSProfileKeyMessage(timestamp: NSDate.ows_millisecondTimeStamp(), in: aThread)

View File

@ -108,7 +108,14 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)sendGroupSyncMessage
{
OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] init];
TSThread *_Nullable thread = [TSAccountManager getOrCreateLocalThreadWithSneakyTransaction];
if (thread == nil) {
OWSFailDebug(@"Missing thread.");
return;
}
OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] initWithThread:thread];
__block DataSource *dataSource;
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
dataSource = [DataSourceValue
@ -116,6 +123,10 @@ NS_ASSUME_NONNULL_BEGIN
buildPlainTextAttachmentDataWithTransaction:transaction.asAnyRead]];
}];
if (syncGroupsMessage == nil || dataSource == nil) {
return;
}
[self.messageSenderJobQueue addMediaMessage:syncGroupsMessage
dataSource:dataSource
contentType:OWSMimeTypeApplicationOctetStream

View File

@ -12,6 +12,7 @@
#import <SignalServiceKit/AppReadiness.h>
#import <SignalServiceKit/DataSource.h>
#import <SignalServiceKit/MIMETypeUtil.h>
#import <SignalServiceKit/OWSError.h>
#import <SignalServiceKit/OWSMessageSender.h>
#import <SignalServiceKit/OWSPrimaryStorage.h>
#import <SignalServiceKit/OWSSyncConfigurationMessage.h>
@ -154,11 +155,17 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
return;
}
OWSSyncContactsMessage *syncContactsMessage =
[[OWSSyncContactsMessage alloc] initWithSignalAccounts:self.contactsManager.signalAccounts
identityManager:self.identityManager
profileManager:self.profileManager];
TSThread *_Nullable thread = [TSAccountManager getOrCreateLocalThreadWithSneakyTransaction];
if (thread == nil) {
OWSFailDebug(@"Missing thread.");
return;
}
OWSSyncContactsMessage *syncContactsMessage =
[[OWSSyncContactsMessage alloc] initWithThread:thread
signalAccounts:self.contactsManager.signalAccounts
identityManager:self.identityManager
profileManager:self.profileManager];
__block NSData *_Nullable messageData;
__block NSData *_Nullable lastMessageData;
[self.readDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
@ -242,14 +249,21 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
BOOL showUnidentifiedDeliveryIndicators = Environment.shared.preferences.shouldShowUnidentifiedDeliveryIndicators;
BOOL showTypingIndicators = self.typingIndicators.areTypingIndicatorsEnabled;
[self.editingDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.editingDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
TSThread *_Nullable thread = [TSAccountManager getOrCreateLocalThreadWithTransaction:transaction.asAnyWrite];
if (thread == nil) {
OWSFailDebug(@"Missing thread.");
return;
}
BOOL sendLinkPreviews = [SSKPreferences areLinkPreviewsEnabledWithTransaction:transaction.asAnyRead];
OWSSyncConfigurationMessage *syncConfigurationMessage =
[[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled
showUnidentifiedDeliveryIndicators:showUnidentifiedDeliveryIndicators
showTypingIndicators:showTypingIndicators
sendLinkPreviews:sendLinkPreviews];
[[OWSSyncConfigurationMessage alloc] initWithThread:thread
readReceiptsEnabled:areReadReceiptsEnabled
showUnidentifiedDeliveryIndicators:showUnidentifiedDeliveryIndicators
showTypingIndicators:showTypingIndicators
sendLinkPreviews:sendLinkPreviews];
[self.messageSenderJobQueue addMessage:syncConfigurationMessage transaction:transaction.asAnyWrite];
}];
@ -273,10 +287,18 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
- (AnyPromise *)syncContactsForSignalAccounts:(NSArray<SignalAccount *> *)signalAccounts
{
OWSSyncContactsMessage *syncContactsMessage =
[[OWSSyncContactsMessage alloc] initWithSignalAccounts:signalAccounts
identityManager:self.identityManager
profileManager:self.profileManager];
TSThread *_Nullable thread = [TSAccountManager getOrCreateLocalThreadWithSneakyTransaction];
if (thread == nil) {
OWSFailDebug(@"Missing thread.");
NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeMissingLocalThread, @"Missing local thread.");
return [AnyPromise promiseWithValue:error];
}
OWSSyncContactsMessage *syncContactsMessage = [[OWSSyncContactsMessage alloc] initWithThread:thread
signalAccounts:signalAccounts
identityManager:self.identityManager
profileManager:self.profileManager];
__block DataSource *dataSource;
[self.readDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
dataSource = [DataSourceValue

View File

@ -0,0 +1,33 @@
//
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
import Foundation
@objc
public extension TSAccountManager {
// MARK: - Dependencies
class var databaseStorage: SDSDatabaseStorage {
return SDSDatabaseStorage.shared
}
// MARK: -
class func getOrCreateLocalThread(transaction: SDSAnyWriteTransaction) -> TSThread? {
guard let localAddress = self.localAddress else {
owsFailDebug("Missing localAddress.")
return nil
}
return TSContactThread.getOrCreateThread(withContactAddress: localAddress, transaction: transaction)
}
class func getOrCreateLocalThreadWithSneakyTransaction() -> TSThread? {
var thread: TSThread?
databaseStorage.write { transaction in
thread = getOrCreateLocalThread(transaction: transaction)
}
return thread
}
}

View File

@ -42,6 +42,9 @@ extern ConversationColorName const kConversationColorName_Default;
@property (nonatomic, readonly) BOOL isArchivedByLegacyTimestampForSorting;
@property (nonatomic, readonly) int64_t rowId;
// GRDB TODO: Promote this to BaseModel/TSYapDatabaseObject.
- (instancetype)init NS_UNAVAILABLE;
// --- CODE GENERATION MARKER
// This snippet is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run `sds_codegen.sh`.

View File

@ -10,9 +10,10 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithPhoneNumbers:(NSArray<NSString *> *)phoneNumbers
uuids:(NSArray<NSString *> *)uuids
groupIds:(NSArray<NSData *> *)groupIds NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithThread:(TSThread *)thread
phoneNumbers:(NSArray<NSString *> *)phoneNumbers
uuids:(NSArray<NSString *> *)uuids
groupIds:(NSArray<NSData *> *)groupIds NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
@end

View File

@ -22,11 +22,12 @@ NS_ASSUME_NONNULL_BEGIN
return [super initWithCoder:coder];
}
- (instancetype)initWithPhoneNumbers:(NSArray<NSString *> *)phoneNumbers
uuids:(NSArray<NSString *> *)uuids
groupIds:(NSArray<NSData *> *)groupIds
- (instancetype)initWithThread:(TSThread *)thread
phoneNumbers:(NSArray<NSString *> *)phoneNumbers
uuids:(NSArray<NSString *> *)uuids
groupIds:(NSArray<NSData *> *)groupIds
{
self = [super init];
self = [super initWithThread:thread];
if (!self) {
return self;
}

View File

@ -17,9 +17,10 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithTimestamp:(uint64_t)timestamp NS_UNAVAILABLE;
- (instancetype)initWithSenderAddress:(SignalServiceAddress *)senderAddress
messageIdTimestamp:(uint64_t)messageIdtimestamp
readTimestamp:(uint64_t)readTimestamp NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithThread:(TSThread *)thread
senderAddress:(SignalServiceAddress *)senderAddress
messageIdTimestamp:(uint64_t)messageIdtimestamp
readTimestamp:(uint64_t)readTimestamp NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;

View File

@ -9,13 +9,14 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSPerMessageExpirationReadSyncMessage
- (instancetype)initWithSenderAddress:(SignalServiceAddress *)senderAddress
messageIdTimestamp:(uint64_t)messageIdTimestamp
readTimestamp:(uint64_t)readTimestamp
- (instancetype)initWithThread:(TSThread *)thread
senderAddress:(SignalServiceAddress *)senderAddress
messageIdTimestamp:(uint64_t)messageIdTimestamp
readTimestamp:(uint64_t)readTimestamp
{
OWSAssertDebug(senderAddress.isValid && messageIdTimestamp > 0);
self = [super initWithTimestamp:readTimestamp];
self = [super initWithTimestamp:readTimestamp thread:thread];
if (!self) {
return self;
}

View File

@ -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"
@ -12,7 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithReadReceipts:(NSArray<OWSLinkedDeviceReadReceipt *> *)readReceipts NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithThread:(TSThread *)thread
readReceipts:(NSArray<OWSLinkedDeviceReadReceipt *> *)readReceipts NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
@end

View File

@ -16,9 +16,9 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSReadReceiptsForLinkedDevicesMessage
- (instancetype)initWithReadReceipts:(NSArray<OWSLinkedDeviceReadReceipt *> *)readReceipts
- (instancetype)initWithThread:(TSThread *)thread readReceipts:(NSArray<OWSLinkedDeviceReadReceipt *> *)readReceipts
{
self = [super init];
self = [super initWithThread:thread];
if (!self) {
return self;
}

View File

@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSReceiptsForSenderMessage : TSOutgoingMessage
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
@ -23,10 +23,10 @@ NS_ASSUME_NONNULL_BEGIN
linkPreview:(nullable OWSLinkPreview *)linkPreview
messageSticker:(nullable MessageSticker *)messageSticker NS_UNAVAILABLE;
+ (OWSReceiptsForSenderMessage *)deliveryReceiptsForSenderMessageWithThread:(nullable TSThread *)thread
+ (OWSReceiptsForSenderMessage *)deliveryReceiptsForSenderMessageWithThread:(TSThread *)thread
messageTimestamps:(NSArray<NSNumber *> *)messageTimestamps;
+ (OWSReceiptsForSenderMessage *)readReceiptsForSenderMessageWithThread:(nullable TSThread *)thread
+ (OWSReceiptsForSenderMessage *)readReceiptsForSenderMessageWithThread:(TSThread *)thread
messageTimestamps:(NSArray<NSNumber *> *)messageTimestamps;
@end

View File

@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSReceiptsForSenderMessage
+ (OWSReceiptsForSenderMessage *)deliveryReceiptsForSenderMessageWithThread:(nullable TSThread *)thread
+ (OWSReceiptsForSenderMessage *)deliveryReceiptsForSenderMessageWithThread:(TSThread *)thread
messageTimestamps:(NSArray<NSNumber *> *)messageTimestamps
{
return [[OWSReceiptsForSenderMessage alloc] initWithThread:thread
@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
receiptType:SSKProtoReceiptMessageTypeDelivery];
}
+ (OWSReceiptsForSenderMessage *)readReceiptsForSenderMessageWithThread:(nullable TSThread *)thread
+ (OWSReceiptsForSenderMessage *)readReceiptsForSenderMessageWithThread:(TSThread *)thread
messageTimestamps:(NSArray<NSNumber *> *)messageTimestamps
{
return [[OWSReceiptsForSenderMessage alloc] initWithThread:thread
@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
receiptType:SSKProtoReceiptMessageTypeRead];
}
- (instancetype)initWithThread:(nullable TSThread *)thread
- (instancetype)initWithThread:(TSThread *)thread
messageTimestamps:(NSArray<NSNumber *> *)messageTimestamps
receiptType:(SSKProtoReceiptMessageType)receiptType
{

View File

@ -16,7 +16,9 @@ typedef NS_ENUM(NSUInteger, StickerPackOperationType) {
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithPacks:(NSArray<StickerPackInfo *> *)packs operationType:(StickerPackOperationType)operationType;
- (instancetype)initWithThread:(TSThread *)thread
packs:(NSArray<StickerPackInfo *> *)packs
operationType:(StickerPackOperationType)operationType;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
@end

View File

@ -23,9 +23,11 @@ NS_ASSUME_NONNULL_BEGIN
return [super initWithCoder:coder];
}
- (instancetype)initWithPacks:(NSArray<StickerPackInfo *> *)packs operationType:(StickerPackOperationType)operationType
- (instancetype)initWithThread:(TSThread *)thread
packs:(NSArray<StickerPackInfo *> *)packs
operationType:(StickerPackOperationType)operationType
{
self = [super init];
self = [super initWithThread:thread];
if (!self) {
return self;
}

View File

@ -13,9 +13,10 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithVerificationState:(OWSVerificationState)verificationState
identityKey:(NSData *)identityKey
verificationForRecipientAddress:(SignalServiceAddress *)address NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithThread:(TSThread *)thread
verificationState:(OWSVerificationState)verificationState
identityKey:(NSData *)identityKey
verificationForRecipientAddress:(SignalServiceAddress *)address NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
// This is a clunky name, but we want to differentiate it from `recipientIdentifier` inherited from `TSOutgoingMessage`

View File

@ -22,9 +22,10 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSVerificationStateSyncMessage
- (instancetype)initWithVerificationState:(OWSVerificationState)verificationState
identityKey:(NSData *)identityKey
verificationForRecipientAddress:(SignalServiceAddress *)address
- (instancetype)initWithThread:(TSThread *)thread
verificationState:(OWSVerificationState)verificationState
identityKey:(NSData *)identityKey
verificationForRecipientAddress:(SignalServiceAddress *)address
{
OWSAssertDebug(identityKey.length == kIdentityKeyLength);
OWSAssertDebug(address.isValid);
@ -33,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
// will figure that out on it's own.
OWSAssertDebug(verificationState != OWSVerificationStateNoLongerVerified);
self = [super init];
self = [super initWithThread:thread];
if (!self) {
return self;
}

View File

@ -17,8 +17,9 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithTimestamp:(uint64_t)timestamp NS_UNAVAILABLE;
- (instancetype)initWithOutgoingMessage:(TSOutgoingMessage *)message
isRecipientUpdate:(BOOL)isRecipientUpdate NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithThread:(TSThread *)thread
outgoingMessage:(TSOutgoingMessage *)message
isRecipientUpdate:(BOOL)isRecipientUpdate NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
@end

View File

@ -40,12 +40,14 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSOutgoingSentMessageTranscript
- (instancetype)initWithOutgoingMessage:(TSOutgoingMessage *)message isRecipientUpdate:(BOOL)isRecipientUpdate
- (instancetype)initWithThread:(TSThread *)thread
outgoingMessage:(TSOutgoingMessage *)message
isRecipientUpdate:(BOOL)isRecipientUpdate
{
OWSAssertDebug(message);
// The sync message's timestamp must match the original outgoing message's timestamp.
self = [super initWithTimestamp:message.timestamp];
self = [super initWithTimestamp:message.timestamp thread:thread];
if (!self) {
return self;
@ -54,8 +56,9 @@ NS_ASSUME_NONNULL_BEGIN
_message = message;
_isRecipientUpdate = isRecipientUpdate;
if ([message.thread isKindOfClass:[TSContactThread class]]) {
TSContactThread *contactThread = (TSContactThread *)message.thread;
TSThread *_Nullable messageThread = message.threadWithSneakyTransaction;
if ([messageThread isKindOfClass:[TSContactThread class]]) {
TSContactThread *contactThread = (TSContactThread *)messageThread;
_sentRecipientAddress = contactThread.contactAddress;
}

View File

@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSOutgoingSyncMessage : TSOutgoingMessage
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
@ -26,8 +26,9 @@ NS_ASSUME_NONNULL_BEGIN
linkPreview:(nullable OWSLinkPreview *)linkPreview
messageSticker:(nullable MessageSticker *)messageSticker NS_UNAVAILABLE;
- (instancetype)init NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithTimestamp:(uint64_t)timestamp NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithThread:(TSThread *)thread NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithTimestamp:(uint64_t)timestamp thread:(TSThread *)thread NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
@end

View File

@ -17,11 +17,11 @@ NS_ASSUME_NONNULL_BEGIN
return [super initWithCoder:coder];
}
- (instancetype)init
- (instancetype)initWithThread:(TSThread *)thread
{
// MJK TODO - remove SenderTimestamp
self = [super initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:nil
inThread:thread
messageBody:nil
attachmentIds:[NSMutableArray new]
expiresInSeconds:0
@ -41,10 +41,10 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (instancetype)initWithTimestamp:(uint64_t)timestamp
- (instancetype)initWithTimestamp:(uint64_t)timestamp thread:(TSThread *)thread
{
self = [super initOutgoingMessageWithTimestamp:timestamp
inThread:nil
inThread:thread
messageBody:nil
attachmentIds:[NSMutableArray new]
expiresInSeconds:0

View File

@ -10,10 +10,11 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithReadReceiptsEnabled:(BOOL)readReceiptsEnabled
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators
showTypingIndicators:(BOOL)showTypingIndicators
sendLinkPreviews:(BOOL)sendLinkPreviews NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithThread:(TSThread *)thread
readReceiptsEnabled:(BOOL)readReceiptsEnabled
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators
showTypingIndicators:(BOOL)showTypingIndicators
sendLinkPreviews:(BOOL)sendLinkPreviews NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;

View File

@ -18,12 +18,13 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSSyncConfigurationMessage
- (instancetype)initWithReadReceiptsEnabled:(BOOL)areReadReceiptsEnabled
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators
showTypingIndicators:(BOOL)showTypingIndicators
sendLinkPreviews:(BOOL)sendLinkPreviews
- (instancetype)initWithThread:(TSThread *)thread
readReceiptsEnabled:(BOOL)areReadReceiptsEnabled
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators
showTypingIndicators:(BOOL)showTypingIndicators
sendLinkPreviews:(BOOL)sendLinkPreviews
{
self = [super init];
self = [super initWithThread:thread];
if (!self) {
return nil;
}

View File

@ -16,9 +16,10 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithSignalAccounts:(NSArray<SignalAccount *> *)signalAccounts
identityManager:(OWSIdentityManager *)identityManager
profileManager:(id<ProfileManagerProtocol>)profileManager NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithThread:(TSThread *)thread
signalAccounts:(NSArray<SignalAccount *> *)signalAccounts
identityManager:(OWSIdentityManager *)identityManager
profileManager:(id<ProfileManagerProtocol>)profileManager NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;

View File

@ -30,11 +30,12 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSSyncContactsMessage
- (instancetype)initWithSignalAccounts:(NSArray<SignalAccount *> *)signalAccounts
identityManager:(OWSIdentityManager *)identityManager
profileManager:(id<ProfileManagerProtocol>)profileManager
- (instancetype)initWithThread:(TSThread *)thread
signalAccounts:(NSArray<SignalAccount *> *)signalAccounts
identityManager:(OWSIdentityManager *)identityManager
profileManager:(id<ProfileManagerProtocol>)profileManager
{
self = [super init];
self = [super initWithThread:thread];
if (!self) {
return self;
}

View File

@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSSyncGroupsMessage : OWSOutgoingSyncMessage
- (instancetype)init NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithThread:(TSThread *)thread NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
- (nullable NSData *)buildPlainTextAttachmentDataWithTransaction:(SDSAnyReadTransaction *)transaction;

View File

@ -16,9 +16,9 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSSyncGroupsMessage
- (instancetype)init
- (instancetype)initWithThread:(TSThread *)thread
{
return [super init];
return [super initWithThread:thread];
}
- (nullable instancetype)initWithCoder:(NSCoder *)coder

View File

@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSSyncGroupsRequestMessage : TSOutgoingMessage
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
linkPreview:(nullable OWSLinkPreview *)linkPreview
messageSticker:(nullable MessageSticker *)messageSticker NS_UNAVAILABLE;
- (instancetype)initWithThread:(nullable TSThread *)thread groupId:(NSData *)groupId;
- (instancetype)initWithThread:(TSThread *)thread groupId:(NSData *)groupId;
@end

View File

@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSSyncGroupsRequestMessage
- (instancetype)initWithThread:(nullable TSThread *)thread groupId:(NSData *)groupId
- (instancetype)initWithThread:(TSThread *)thread groupId:(NSData *)groupId
{
// MJK TODO - remove senderTimestamp
self = [super initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]

View File

@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
// MJK TODO - remove senderTimestamp
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds

View File

@ -15,7 +15,7 @@ typedef NSData *_Nonnull (^DynamicOutgoingMessageBlock)(SignalRecipient *);
@interface OWSDynamicOutgoingMessage : TSOutgoingMessage
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
@ -27,10 +27,10 @@ typedef NSData *_Nonnull (^DynamicOutgoingMessageBlock)(SignalRecipient *);
linkPreview:(nullable OWSLinkPreview *)linkPreview
messageSticker:(nullable MessageSticker *)messageSticker NS_UNAVAILABLE;
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block thread:(nullable TSThread *)thread;
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block thread:(TSThread *)thread;
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block
timestamp:(uint64_t)timestamp
thread:(nullable TSThread *)thread;
thread:(TSThread *)thread;
@end

View File

@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSDynamicOutgoingMessage
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block thread:(nullable TSThread *)thread
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block thread:(TSThread *)thread
{
return [self initWithPlainTextDataBlock:block timestamp:[NSDate ows_millisecondTimeStamp] thread:thread];
}
@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
// MJK TODO can we remove sender timestamp?
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block
timestamp:(uint64_t)timestamp
thread:(nullable TSThread *)thread
thread:(TSThread *)thread
{
self = [super initOutgoingMessageWithTimestamp:timestamp
inThread:thread

View File

@ -10,7 +10,7 @@ NS_SWIFT_NAME(EndSessionMessage)
@interface OWSEndSessionMessage : TSOutgoingMessage
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
@ -23,7 +23,7 @@ NS_SWIFT_NAME(EndSessionMessage)
messageSticker:(nullable MessageSticker *)messageSticker NS_UNAVAILABLE;
// MJK TODO can we remove the sender timestamp?
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
@end

View File

@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
return [super initWithCoder:coder];
}
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread
{
return [super initOutgoingMessageWithTimestamp:timestamp
inThread:thread

View File

@ -27,10 +27,18 @@ typedef NS_ENUM(int32_t, TSErrorMessageType) {
TSErrorMessageGroupCreationFailed,
};
@interface ThreadlessErrorMessage : NSObject <OWSPreviewText>
+ (ThreadlessErrorMessage *)corruptedMessageInUnknownThread;
@end
#pragma mark -
@interface TSErrorMessage : TSMessage <OWSReadTracking>
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
@ -41,7 +49,7 @@ typedef NS_ENUM(int32_t, TSErrorMessageType) {
messageSticker:(nullable MessageSticker *)messageSticker NS_UNAVAILABLE;
- (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
@ -50,7 +58,7 @@ typedef NS_ENUM(int32_t, TSErrorMessageType) {
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
failedMessageType:(TSErrorMessageType)errorMessageType
address:(nullable SignalServiceAddress *)address NS_DESIGNATED_INITIALIZER;
@ -91,8 +99,6 @@ NS_SWIFT_NAME(init(uniqueId:receivedAtTimestamp:sortId:timestamp:uniqueThreadId:
+ (instancetype)corruptedMessageWithEnvelope:(SSKProtoEnvelope *)envelope
withTransaction:(YapDatabaseReadWriteTransaction *)transaction;
+ (instancetype)corruptedMessageInUnknownThread;
+ (instancetype)invalidVersionWithEnvelope:(SSKProtoEnvelope *)envelope
withTransaction:(YapDatabaseReadWriteTransaction *)transaction;

View File

@ -16,6 +16,48 @@ NS_ASSUME_NONNULL_BEGIN
NSUInteger TSErrorMessageSchemaVersion = 2;
@interface ThreadlessErrorMessage ()
@property (nonatomic, readonly) TSErrorMessageType errorType;
@end
#pragma mark -
@implementation ThreadlessErrorMessage
- (instancetype)initWithErrorType:(TSErrorMessageType)errorType
{
self = [super init];
if (!self) {
return self;
}
_errorType = errorType;
return self;
}
+ (ThreadlessErrorMessage *)corruptedMessageInUnknownThread
{
return [[self alloc] initWithErrorType:TSErrorMessageInvalidMessage];
}
- (NSString *)previewTextWithTransaction:(SDSAnyReadTransaction *)transaction
{
switch (_errorType) {
case TSErrorMessageInvalidMessage:
return NSLocalizedString(@"ERROR_MESSAGE_INVALID_MESSAGE", @"");
default:
OWSFailDebug(@"Unknown error type.");
return NSLocalizedString(@"ERROR_MESSAGE_UNKNOWN_ERROR", @"");
}
}
@end
#pragma mark -
@interface TSErrorMessage ()
@property (nonatomic, getter=wasRead) BOOL read;
@ -57,7 +99,7 @@ NSUInteger TSErrorMessageSchemaVersion = 2;
}
- (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
failedMessageType:(TSErrorMessageType)errorMessageType
address:(nullable SignalServiceAddress *)address
{
@ -89,7 +131,7 @@ NSUInteger TSErrorMessageSchemaVersion = 2;
}
- (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
failedMessageType:(TSErrorMessageType)errorMessageType
{
return [self initWithTimestamp:timestamp inThread:thread failedMessageType:errorMessageType address:nil];
@ -229,14 +271,6 @@ perMessageExpirationDurationSeconds:perMessageExpirationDurationSeconds
failedMessageType:TSErrorMessageInvalidMessage];
}
+ (instancetype)corruptedMessageInUnknownThread
{
// MJK TODO - Seems like we could safely remove this timestamp
return [[self alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:nil
failedMessageType:TSErrorMessageInvalidMessage];
}
+ (instancetype)invalidVersionWithEnvelope:(SSKProtoEnvelope *)envelope
withTransaction:(YapDatabaseReadWriteTransaction *)transaction
{

View File

@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface TSErrorMessage ()
- (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
failedMessageType:(TSErrorMessageType)errorMessageType NS_DESIGNATED_INITIALIZER;
@end

View File

@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) BOOL wasReceivedByUD;
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds

View File

@ -34,7 +34,7 @@ typedef NS_ENUM(NSInteger, TSInfoMessageType) {
@property (atomic, readonly, nullable) SignalServiceAddress *unregisteredAddress;
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
@ -96,7 +96,7 @@ NS_SWIFT_NAME(init(uniqueId:receivedAtTimestamp:sortId:timestamp:uniqueThreadId:
unregisteredAddress:(SignalServiceAddress *)unregisteredAddress;
- (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds

View File

@ -22,7 +22,7 @@ typedef NS_ENUM(NSInteger, OWSInteractionType) {
NSString *NSStringFromOWSInteractionType(OWSInteractionType value);
@protocol OWSPreviewText
@protocol OWSPreviewText <NSObject>
- (NSString *)previewTextWithTransaction:(SDSAnyReadTransaction *)transaction;
@ -32,6 +32,8 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value);
@interface TSInteraction : BaseModel
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithUniqueId:(NSString *)uniqueId timestamp:(uint64_t)timestamp inThread:(TSThread *)thread;
- (instancetype)initInteractionWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread;
@ -55,9 +57,6 @@ NS_SWIFT_NAME(init(uniqueId:receivedAtTimestamp:sortId:timestamp:uniqueThreadId:
@property (nonatomic, readonly) NSString *uniqueThreadId;
// GRDB TODO: Remove.
@property (nonatomic, readonly) TSThread *thread;
@property (nonatomic, readonly) uint64_t timestamp;
@property (nonatomic, readonly) uint64_t sortId;
@property (nonatomic, readonly) uint64_t receivedAtTimestamp;
@ -66,6 +65,8 @@ NS_SWIFT_NAME(init(uniqueId:receivedAtTimestamp:sortId:timestamp:uniqueThreadId:
- (OWSInteractionType)interactionType;
- (TSThread *)threadWithSneakyTransaction;
- (TSThread *)threadWithTransaction:(SDSAnyReadTransaction *)transaction NS_SWIFT_NAME(thread(transaction:));
/**

View File

@ -86,6 +86,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
inThread:(TSThread *)thread
{
OWSAssertDebug(timestamp > 0);
OWSAssertDebug(thread);
self = [super initWithUniqueId:uniqueId];
@ -178,8 +179,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
#pragma mark Thread
// GRDB TODO: Remove.
- (TSThread *)thread
- (TSThread *)threadWithSneakyTransaction
{
__block TSThread *thread;
[self.databaseStorage readWithBlock:^(SDSAnyReadTransaction *transaction) {

View File

@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initInteractionWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_UNAVAILABLE;
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds

View File

@ -66,7 +66,7 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
@implementation TSMessage
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds

View File

@ -80,7 +80,7 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
@interface TSOutgoingMessage : TSMessage
- (instancetype)initMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
@ -92,7 +92,7 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
// MJK TODO - Can we remove the sender timestamp param?
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
@ -151,16 +151,16 @@ NS_SWIFT_NAME(init(uniqueId:receivedAtTimestamp:sortId:timestamp:uniqueThreadId:
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
+ (instancetype)outgoingMessageInThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentId:(nullable NSString *)attachmentId;
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
+ (instancetype)outgoingMessageInThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentId:(nullable NSString *)attachmentId
expiresInSeconds:(uint32_t)expiresInSeconds;
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
+ (instancetype)outgoingMessageInThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentId:(nullable NSString *)attachmentId
expiresInSeconds:(uint32_t)expiresInSeconds
@ -168,7 +168,7 @@ NS_SWIFT_NAME(init(uniqueId:receivedAtTimestamp:sortId:timestamp:uniqueThreadId:
linkPreview:(nullable OWSLinkPreview *)linkPreview
messageSticker:(nullable MessageSticker *)messageSticker;
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
+ (instancetype)outgoingMessageInThread:(TSThread *)thread
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
expiresInSeconds:(uint32_t)expiresInSeconds;

View File

@ -358,7 +358,7 @@ perMessageExpirationDurationSeconds:perMessageExpirationDurationSeconds
return SSKEnvironment.shared.migrationDBConnection;
}
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
+ (instancetype)outgoingMessageInThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentId:(nullable NSString *)attachmentId
{
@ -371,7 +371,7 @@ perMessageExpirationDurationSeconds:perMessageExpirationDurationSeconds
messageSticker:nil];
}
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
+ (instancetype)outgoingMessageInThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentId:(nullable NSString *)attachmentId
expiresInSeconds:(uint32_t)expiresInSeconds
@ -385,7 +385,7 @@ perMessageExpirationDurationSeconds:perMessageExpirationDurationSeconds
messageSticker:nil];
}
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
+ (instancetype)outgoingMessageInThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentId:(nullable NSString *)attachmentId
expiresInSeconds:(uint32_t)expiresInSeconds
@ -414,7 +414,7 @@ perMessageExpirationDurationSeconds:perMessageExpirationDurationSeconds
perMessageExpirationDurationSeconds:0];
}
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
+ (instancetype)outgoingMessageInThread:(TSThread *)thread
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
expiresInSeconds:(uint32_t)expiresInSeconds
{
@ -435,7 +435,7 @@ perMessageExpirationDurationSeconds:perMessageExpirationDurationSeconds
}
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
@ -1062,7 +1062,7 @@ perMessageExpirationDurationSeconds:perMessageExpirationDurationSeconds
- (nullable SSKProtoDataMessageBuilder *)dataMessageBuilder
{
TSThread *thread = self.thread;
TSThread *thread = self.threadWithSneakyTransaction;
OWSAssertDebug(thread);
SSKProtoDataMessageBuilder *builder = [SSKProtoDataMessage builder];
@ -1311,14 +1311,16 @@ perMessageExpirationDurationSeconds:perMessageExpirationDurationSeconds
// recipientId is nil when building "sent" sync messages for messages sent to groups.
- (nullable SSKProtoDataMessage *)buildDataMessage:(SignalServiceAddress *_Nullable)address
{
OWSAssertDebug(self.thread);
OWSAssertDebug(self.threadWithSneakyTransaction);
SSKProtoDataMessageBuilder *_Nullable builder = [self dataMessageBuilder];
if (!builder) {
OWSFailDebug(@"could not build protobuf.");
return nil;
}
[ProtoUtils addLocalProfileKeyIfNecessary:self.thread address:address dataMessageBuilder:builder];
[ProtoUtils addLocalProfileKeyIfNecessary:self.threadWithSneakyTransaction
address:address
dataMessageBuilder:builder];
NSError *error;
SSKProtoDataMessage *_Nullable dataProto = [builder buildAndReturnError:&error];

View File

@ -175,7 +175,7 @@ perMessageExpirationDurationSeconds:perMessageExpirationDurationSeconds
// Decrypt this and any old messages for the newly accepted key
NSArray<TSInvalidIdentityKeyReceivingErrorMessage *> *messagesToDecrypt =
[self.thread receivedMessagesForInvalidKey:newKey];
[self.threadWithSneakyTransaction receivedMessagesForInvalidKey:newKey];
for (TSInvalidIdentityKeyReceivingErrorMessage *errorMessage in messagesToDecrypt) {
[SSKEnvironment.shared.messageReceiver handleReceivedEnvelopeData:errorMessage.envelopeData];

View File

@ -300,7 +300,7 @@ NS_ASSUME_NONNULL_BEGIN
void (^reportFailure)(SDSAnyWriteTransaction *transaction) = ^(SDSAnyWriteTransaction *transaction) {
// TODO: Add analytics.
TSErrorMessage *errorMessage = [TSErrorMessage corruptedMessageInUnknownThread];
ThreadlessErrorMessage *errorMessage = [ThreadlessErrorMessage corruptedMessageInUnknownThread];
[SSKEnvironment.shared.notificationsManager notifyUserForThreadlessErrorMessage:errorMessage
transaction:transaction];
};

View File

@ -48,6 +48,15 @@ NSString *const kOWSBlockingManager_SyncedBlockedGroupIdsKey = @"kOWSBlockingMan
@implementation OWSBlockingManager
#pragma mark - Dependencies
- (SDSDatabaseStorage *)databaseStorage
{
return SDSDatabaseStorage.shared;
}
#pragma mark -
+ (instancetype)sharedManager
{
OWSAssertDebug(SSKEnvironment.shared.blockingManager);
@ -437,10 +446,19 @@ NSString *const kOWSBlockingManager_SyncedBlockedGroupIdsKey = @"kOWSBlockingMan
OWSAssertDebug(blockedUUIDs);
OWSAssertDebug(blockedGroupIds);
OWSBlockedPhoneNumbersMessage *message =
[[OWSBlockedPhoneNumbersMessage alloc] initWithPhoneNumbers:blockedPhoneNumbers
uuids:blockedUUIDs
groupIds:blockedGroupIds];
__block TSThread *_Nullable thread;
[self.databaseStorage writeWithBlock:^(SDSAnyWriteTransaction *transaction) {
thread = [TSAccountManager getOrCreateLocalThreadWithTransaction:transaction];
}];
if (thread == nil) {
OWSFailDebug(@"Missing thread.");
return;
}
OWSBlockedPhoneNumbersMessage *message = [[OWSBlockedPhoneNumbersMessage alloc] initWithThread:thread
phoneNumbers:blockedPhoneNumbers
uuids:blockedUUIDs
groupIds:blockedGroupIds];
[self.messageSender sendMessage:message
success:^{

View File

@ -597,6 +597,11 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
- (void)syncQueuedVerificationStates
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
TSThread *_Nullable thread = [TSAccountManager getOrCreateLocalThreadWithSneakyTransaction];
if (thread == nil) {
OWSFailDebug(@"Missing thread.");
return;
}
NSMutableArray<OWSVerificationStateSyncMessage *> *messages = [NSMutableArray new];
[self.databaseQueue readWithBlock:^(SDSAnyReadTransaction *transaction) {
[self.queuedVerificationStateSyncMessagesKeyValueStore
@ -645,7 +650,8 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
}
OWSVerificationStateSyncMessage *message =
[[OWSVerificationStateSyncMessage alloc]
initWithVerificationState:recipientIdentity
initWithThread:thread
verificationState:recipientIdentity
.verificationState
identityKey:identityKey
verificationForRecipientAddress:address];

View File

@ -304,7 +304,7 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
OWSProdFail([OWSAnalyticsEvents messageManagerErrorInvalidProtocolMessage]);
[self.databaseStorage writeWithBlock:^(SDSAnyWriteTransaction *transaction) {
TSErrorMessage *errorMessage = [TSErrorMessage corruptedMessageInUnknownThread];
ThreadlessErrorMessage *errorMessage = [ThreadlessErrorMessage corruptedMessageInUnknownThread];
[SSKEnvironment.shared.notificationsManager notifyUserForThreadlessErrorMessage:errorMessage
transaction:transaction];
}];
@ -604,7 +604,7 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
TSErrorMessage *errorMessage;
if (!envelope.sourceAddress.isValid) {
TSErrorMessage *errorMessage = [TSErrorMessage corruptedMessageInUnknownThread];
ThreadlessErrorMessage *errorMessage = [ThreadlessErrorMessage corruptedMessageInUnknownThread];
[SSKEnvironment.shared.notificationsManager notifyUserForThreadlessErrorMessage:errorMessage
transaction:transaction];
return;

View File

@ -971,7 +971,12 @@ NS_ASSUME_NONNULL_BEGIN
[[self.syncManager syncAllContacts] retainUntilComplete];
});
} else if (syncMessage.request.unwrappedType == SSKProtoSyncMessageRequestTypeGroups) {
OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] init];
TSThread *_Nullable thread = [TSAccountManager getOrCreateLocalThreadWithTransaction:transaction];
if (thread == nil) {
OWSFailDebug(@"Missing thread.");
return;
}
OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] initWithThread:thread];
NSData *_Nullable syncData = [syncGroupsMessage buildPlainTextAttachmentDataWithTransaction:transaction];
if (!syncData) {
OWSFailDebug(@"Failed to serialize groups sync message.");

View File

@ -417,7 +417,7 @@ NSString *const OWSMessageDecryptJobFinderExtensionGroup = @"OWSMessageProcessin
// TODO: Add analytics.
[self.databaseStorage writeWithBlock:^(SDSAnyWriteTransaction *transaction) {
TSErrorMessage *errorMessage = [TSErrorMessage corruptedMessageInUnknownThread];
ThreadlessErrorMessage *errorMessage = [ThreadlessErrorMessage corruptedMessageInUnknownThread];
[SSKEnvironment.shared.notificationsManager notifyUserForThreadlessErrorMessage:errorMessage
transaction:transaction];
}];

View File

@ -210,7 +210,7 @@ void AssertIsOnSendingQueue()
{
if (SSKAppExpiry.isExpired) {
OWSLogWarn(@"Unable to send because the application has expired.");
NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeAppExired,
NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeAppExpired,
NSLocalizedString(
@"ERROR_SENDING_EXPIRED", @"Error indicating a send failure due to an expired application."));
error.isRetryable = NO;
@ -706,7 +706,9 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
failureHandlerParam(error);
};
TSThread *_Nullable thread = message.thread;
// GRDB TODO: Make this non-nil.
TSThread *_Nullable thread = [self threadForMessageWithSneakyTransaction:message];
OWSAssertDebug(thread != nil);
BOOL isSyncMessage = [message isKindOfClass:[OWSOutgoingSyncMessage class]];
if (!thread && !isSyncMessage) {
@ -843,6 +845,28 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
[sendPromise retainUntilComplete];
}
- (nullable TSThread *)threadForMessageWithSneakyTransaction:(TSMessage *)message
{
__block TSThread *_Nullable thread = nil;
[self.databaseStorage writeWithBlock:^(SDSAnyWriteTransaction *transaction) {
thread = [message threadWithTransaction:transaction];
OWSAssertDebug(thread != nil);
// For some legacy sync messages, thread may be nil.
// In this case, we should use the "local" thread.
BOOL isSyncMessage = [message isKindOfClass:[OWSOutgoingSyncMessage class]];
if (thread == nil && isSyncMessage) {
thread = [TSAccountManager getOrCreateLocalThreadWithTransaction:transaction];
if (thread == nil) {
OWSFailDebug(@"Could not restore thread for sync message.");
} else {
OWSLogInfo(@"Thread restored for sync message.");
}
}
}];
return thread;
}
- (void)unregisteredRecipient:(SignalRecipient *)recipient
message:(TSOutgoingMessage *)message
thread:(TSThread *)thread
@ -1429,7 +1453,9 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
failure:(RetryableFailureHandler)failure
{
dispatch_block_t success = ^{
TSThread *_Nullable thread = message.thread;
// GRDB TODO: Make this non-nil.
TSThread *_Nullable thread = [self threadForMessageWithSneakyTransaction:message];
OWSAssertDebug(thread != nil);
TSContactThread *_Nullable contactThread;
if ([thread isKindOfClass:[TSContactThread class]]) {
@ -1459,7 +1485,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
return;
}
TSOutgoingMessage *latestMessage = (TSOutgoingMessage *)latestCopy;
[[OWSDisappearingMessagesJob sharedJob] startAnyExpirationForMessage:message
[[OWSDisappearingMessagesJob sharedJob] startAnyExpirationForMessage:latestMessage
expirationStartedAt:[NSDate ows_millisecondTimeStamp]
transaction:transaction];
@ -1493,17 +1519,26 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
success:(void (^)(void))success
failure:(RetryableFailureHandler)failure
{
OWSOutgoingSentMessageTranscript *sentMessageTranscript =
[[OWSOutgoingSentMessageTranscript alloc] initWithOutgoingMessage:message isRecipientUpdate:isRecipientUpdate];
SignalServiceAddress *localAddress = self.tsAccountManager.localAddress;
__block TSThread *_Nullable thread;
__block SignalRecipient *recipient;
[self.databaseStorage writeWithBlock:^(SDSAnyWriteTransaction *transaction) {
thread = [TSAccountManager getOrCreateLocalThreadWithTransaction:transaction];
recipient = [SignalRecipient markRecipientAsRegisteredAndGet:localAddress transaction:transaction];
}];
if (thread == nil) {
OWSFailDebug(@"Missing thread.");
return;
}
OWSOutgoingSentMessageTranscript *sentMessageTranscript =
[[OWSOutgoingSentMessageTranscript alloc] initWithThread:thread
outgoingMessage:message
isRecipientUpdate:isRecipientUpdate];
OWSMessageSend *messageSend = [[OWSMessageSend alloc] initWithMessage:sentMessageTranscript
thread:message.thread
thread:message.threadWithSneakyTransaction
recipient:recipient
senderCertificate:nil
udAccess:nil

View File

@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSOutgoingCallMessage : TSOutgoingMessage
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds

View File

@ -151,7 +151,9 @@ NS_ASSUME_NONNULL_BEGIN
[builder setBusy:self.busyMessage];
}
[ProtoUtils addLocalProfileKeyIfNecessary:self.thread address:address callMessageBuilder:builder];
[ProtoUtils addLocalProfileKeyIfNecessary:self.threadWithSneakyTransaction
address:address
callMessageBuilder:builder];
NSError *error;
SSKProtoCallMessage *_Nullable result = [builder buildAndReturnError:&error];

View File

@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSOutgoingNullMessage : TSOutgoingMessage
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds

View File

@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSProfileKeyMessage : TSOutgoingMessage
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread
inThread:(TSThread *)thread
messageBody:(nullable NSString *)body
attachmentIds:(NSMutableArray<NSString *> *)attachmentIds
expiresInSeconds:(uint32_t)expiresInSeconds
@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
linkPreview:(nullable OWSLinkPreview *)linkPreview
messageSticker:(nullable MessageSticker *)messageSticker NS_UNAVAILABLE;
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
@end

View File

@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSProfileKeyMessage
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(nullable TSThread *)thread
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread
{
return [super initOutgoingMessageWithTimestamp:timestamp
inThread:thread
@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable SSKProtoDataMessage *)buildDataMessage:(SignalServiceAddress *_Nullable)address
{
OWSAssertDebug(self.thread);
OWSAssertDebug(self.threadWithSneakyTransaction != nil);
SSKProtoDataMessageBuilder *_Nullable builder = [self dataMessageBuilder];
if (!builder) {

View File

@ -282,10 +282,17 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
[self.toLinkedDevicesReadReceiptMap allValues];
[self.toLinkedDevicesReadReceiptMap removeAllObjects];
if (readReceiptsForLinkedDevices.count > 0) {
OWSReadReceiptsForLinkedDevicesMessage *message =
[[OWSReadReceiptsForLinkedDevicesMessage alloc] initWithReadReceipts:readReceiptsForLinkedDevices];
[self.databaseStorage writeWithBlock:^(SDSAnyWriteTransaction *transaction) {
TSThread *_Nullable thread = [TSAccountManager getOrCreateLocalThreadWithTransaction:transaction];
if (thread == nil) {
OWSFailDebug(@"Missing thread.");
return;
}
OWSReadReceiptsForLinkedDevicesMessage *message =
[[OWSReadReceiptsForLinkedDevicesMessage alloc] initWithThread:thread
readReceipts:readReceiptsForLinkedDevices];
[self.messageSenderJobQueue addMessage:message transaction:transaction];
}];
}

View File

@ -1057,8 +1057,12 @@ public class StickerManager: NSObject {
guard tsAccountManager.isRegisteredAndReady else {
return
}
guard let thread = TSAccountManager.getOrCreateLocalThread(transaction: transaction) else {
owsFailDebug("Missing thread.")
return
}
let message = OWSStickerPackSyncMessage(packs: packs, operationType: operationType)
let message = OWSStickerPackSyncMessage(thread: thread, packs: packs, operationType: operationType)
self.messageSenderJobQueue.add(message: message, transaction: transaction)
}

View File

@ -798,7 +798,7 @@ NSString *const kNSNotification_OWSWebSocketStateDidChange = @"kNSNotification_O
if (!success) {
[self.databaseStorage writeWithBlock:^(SDSAnyWriteTransaction *transaction) {
TSErrorMessage *errorMessage = [TSErrorMessage corruptedMessageInUnknownThread];
ThreadlessErrorMessage *errorMessage = [ThreadlessErrorMessage corruptedMessageInUnknownThread];
[self.notificationsManager notifyUserForThreadlessErrorMessage:errorMessage
transaction:transaction];
}];

View File

@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
@class TSIncomingMessage;
@class TSInfoMessage;
@class TSThread;
@class ThreadlessErrorMessage;
@protocol ContactsManagerProtocol;
@ -28,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
wantsSound:(BOOL)wantsSound
transaction:(SDSAnyWriteTransaction *)transaction;
- (void)notifyUserForThreadlessErrorMessage:(TSErrorMessage *)errorMessage
- (void)notifyUserForThreadlessErrorMessage:(ThreadlessErrorMessage *)errorMessage
transaction:(SDSAnyWriteTransaction *)transaction;
- (void)clearAllNotifications;

View File

@ -35,6 +35,7 @@
#import <SignalServiceKit/SignalAccount.h>
#import <SignalServiceKit/SignalRecipient.h>
#import <SignalServiceKit/StickerPack.h>
#import <SignalServiceKit/TSAccountManager.h>
#import <SignalServiceKit/TSAttachment.h>
#import <SignalServiceKit/TSAttachmentPointer.h>
#import <SignalServiceKit/TSAttachmentStream.h>

View File

@ -17,7 +17,7 @@ public class NoopNotificationsManager: NSObject, NotificationsProtocol {
Logger.warn("skipping notification for: \(infoMessage.description)")
}
public func notifyUser(forThreadlessErrorMessage errorMessage: TSErrorMessage, transaction: SDSAnyWriteTransaction) {
public func notifyUser(for errorMessage: ThreadlessErrorMessage, transaction: SDSAnyWriteTransaction) {
Logger.warn("skipping notification for: \(errorMessage.description)")
}

View File

@ -57,7 +57,8 @@ typedef NS_ENUM(NSInteger, OWSErrorCode) {
OWSErrorCodeUploadFailed,
OWSErrorCodeInvalidStickerData,
OWSErrorCodeAttachmentDownloadFailed,
OWSErrorCodeAppExired,
OWSErrorCodeAppExpired,
OWSErrorCodeMissingLocalThread,
};
extern NSString *const OWSErrorRecipientAddressKey;

View File

@ -240,10 +240,15 @@ public class PerMessageExpiration: NSObject {
owsFailDebug("Could not send sync message; no local number.")
return
}
guard let thread = TSAccountManager.getOrCreateLocalThread(transaction: transaction) else {
owsFailDebug("Missing thread.")
return
}
let messageIdTimestamp: UInt64 = message.timestamp
let readTimestamp: UInt64 = nowMs()
let syncMessage = OWSPerMessageExpirationReadSyncMessage(senderAddress: senderAddress,
let syncMessage = OWSPerMessageExpirationReadSyncMessage(thread: thread,
senderAddress: senderAddress,
messageIdTimestamp: messageIdTimestamp,
readTimestamp: readTimestamp)
messageSenderJobQueue.add(message: syncMessage, transaction: transaction)