Made LKAddressMessage a subclass of LKEphemeralMessage.

This is because we can't send a body with a nil message :(
pull/20/head
Mikunj 6 years ago
parent bf1c2f4327
commit 4412ec8f15

@ -82,6 +82,7 @@ import PromiseKit
var p2pPromise: Promise<Set<Promise<RawResponse>>> = Promise(error: Error.internalError) var p2pPromise: Promise<Set<Promise<RawResponse>>> = Promise(error: Error.internalError)
// TODO: probably only send to p2p if user is online or we are pinging them // TODO: probably only send to p2p if user is online or we are pinging them
// p2pDetails && (isPing || peerIsOnline) // p2pDetails && (isPing || peerIsOnline)
if let p2pDetails = contactP2PDetails[destination] { if let p2pDetails = contactP2PDetails[destination] {
p2pPromise = sendMessage(message, targets: [p2pDetails]) p2pPromise = sendMessage(message, targets: [p2pDetails])
} }

@ -1,13 +1,10 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import <SignalServiceKit/SignalServiceKit.h> #import "LKEphemeralMessage.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
NS_SWIFT_NAME(LokiAddressMessage) NS_SWIFT_NAME(LokiAddressMessage)
@interface LKAddressMessage : TSOutgoingMessage @interface LKAddressMessage : LKEphemeralMessage
- (instancetype)initInThread:(nullable TSThread *)thread - (instancetype)initInThread:(nullable TSThread *)thread
address:(NSString *)address address:(NSString *)address

@ -12,12 +12,11 @@
@implementation LKAddressMessage @implementation LKAddressMessage
- (instancetype)initAddressMessageInThread:(nullable TSThread *)thread - (instancetype)initInThread:(nullable TSThread *)thread
address:(NSString *)address address:(NSString *)address
port:(uint)port port:(uint)port
{ {
self = [super initOutgoingMessageWithTimestamp:NSDate.ows_millisecondTimeStamp inThread:thread messageBody:nil attachmentIds:[NSMutableArray<NSString *> new] self = [super initInThread:thread];
expiresInSeconds:0 expireStartedAt:0 isVoiceMessage:NO groupMetaMessage:TSGroupMetaMessageUnspecified quotedMessage:nil contactShare:nil linkPreview:nil];
if (!self) { if (!self) {
return self; return self;
} }
@ -47,13 +46,6 @@
return contentBuilder; return contentBuilder;
} }
// We don't need to send any data message in this address message
- (nullable SSKProtoDataMessage *)buildDataMessage:(NSString *_Nullable)recipientId {
return nil;
}
- (BOOL)shouldBeSaved { return false; }
- (uint)ttl { - (uint)ttl {
// Address messages should only last 1 minute // Address messages should only last 1 minute
return 1 * kMinuteInterval; return 1 * kMinuteInterval;

@ -8,6 +8,8 @@ NS_SWIFT_NAME(EphemeralMessage)
/// Used to establish sessions. /// Used to establish sessions.
+ (LKEphemeralMessage *)createEmptyOutgoingMessageInThread:(TSThread *)thread; + (LKEphemeralMessage *)createEmptyOutgoingMessageInThread:(TSThread *)thread;
- (instancetype)initInThread:(nullable TSThread *)thread;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -4,8 +4,12 @@
@implementation LKEphemeralMessage @implementation LKEphemeralMessage
+ (LKEphemeralMessage *)createEmptyOutgoingMessageInThread:(TSThread *)thread { + (LKEphemeralMessage *)createEmptyOutgoingMessageInThread:(TSThread *)thread {
return [[LKEphemeralMessage alloc] initOutgoingMessageWithTimestamp:NSDate.ows_millisecondTimeStamp inThread:thread messageBody:@"" attachmentIds:[NSMutableArray<NSString *> new] return [[LKEphemeralMessage alloc] initInThread:thread];
expiresInSeconds:0 expireStartedAt:0 isVoiceMessage:NO groupMetaMessage:TSGroupMetaMessageUnspecified quotedMessage:nil contactShare:nil linkPreview:nil]; }
- (instancetype)initInThread:(nullable TSThread *)thread {
return [self initOutgoingMessageWithTimestamp:NSDate.ows_millisecondTimeStamp inThread:thread messageBody:@"" attachmentIds:[NSMutableArray<NSString *> new]
expiresInSeconds:0 expireStartedAt:0 isVoiceMessage:NO groupMetaMessage:TSGroupMetaMessageUnspecified quotedMessage:nil contactShare:nil linkPreview:nil];
} }
- (BOOL)shouldBeSaved { return NO; } - (BOOL)shouldBeSaved { return NO; }

Loading…
Cancel
Save