mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.8 KiB
Objective-C
65 lines
1.8 KiB
Objective-C
//
|
|
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import "OWSDynamicOutgoingMessage.h"
|
|
#import <SessionProtocolKit/NSDate+OWS.h>
|
|
#import <SignalUtilitiesKit/SignalUtilitiesKit-Swift.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@interface OWSDynamicOutgoingMessage ()
|
|
|
|
@property (nonatomic, readonly) DynamicOutgoingMessageBlock block;
|
|
|
|
@end
|
|
|
|
#pragma mark -
|
|
|
|
@implementation OWSDynamicOutgoingMessage
|
|
|
|
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block thread:(nullable TSThread *)thread
|
|
{
|
|
return [self initWithPlainTextDataBlock:block timestamp:[NSDate ows_millisecondTimeStamp] thread:thread];
|
|
}
|
|
|
|
// MJK TODO can we remove sender timestamp?
|
|
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block
|
|
timestamp:(uint64_t)timestamp
|
|
thread:(nullable TSThread *)thread
|
|
{
|
|
self = [super initOutgoingMessageWithTimestamp:timestamp
|
|
inThread:thread
|
|
messageBody:nil
|
|
attachmentIds:[NSMutableArray new]
|
|
expiresInSeconds:0
|
|
expireStartedAt:0
|
|
isVoiceMessage:NO
|
|
groupMetaMessage:TSGroupMetaMessageUnspecified
|
|
quotedMessage:nil
|
|
contactShare:nil
|
|
linkPreview:nil];
|
|
|
|
if (self) {
|
|
_block = block;
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
- (BOOL)shouldBeSaved
|
|
{
|
|
return NO;
|
|
}
|
|
|
|
- (nullable NSData *)buildPlainTextData:(SignalRecipient *)recipient
|
|
{
|
|
NSData *plainTextData = self.block(recipient);
|
|
OWSAssertDebug(plainTextData);
|
|
return plainTextData;
|
|
}
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|