Made LKAddressMessage a subclass of LKEphemeralMessage.

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

@ -82,6 +82,7 @@ import PromiseKit
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
// p2pDetails && (isPing || peerIsOnline)
if let p2pDetails = contactP2PDetails[destination] {
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_SWIFT_NAME(LokiAddressMessage)
@interface LKAddressMessage : TSOutgoingMessage
@interface LKAddressMessage : LKEphemeralMessage
- (instancetype)initInThread:(nullable TSThread *)thread
address:(NSString *)address

@ -12,12 +12,11 @@
@implementation LKAddressMessage
- (instancetype)initAddressMessageInThread:(nullable TSThread *)thread
address:(NSString *)address
port:(uint)port
- (instancetype)initInThread:(nullable TSThread *)thread
address:(NSString *)address
port:(uint)port
{
self = [super initOutgoingMessageWithTimestamp:NSDate.ows_millisecondTimeStamp inThread:thread messageBody:nil attachmentIds:[NSMutableArray<NSString *> new]
expiresInSeconds:0 expireStartedAt:0 isVoiceMessage:NO groupMetaMessage:TSGroupMetaMessageUnspecified quotedMessage:nil contactShare:nil linkPreview:nil];
self = [super initInThread:thread];
if (!self) {
return self;
}
@ -47,13 +46,6 @@
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 {
// Address messages should only last 1 minute
return 1 * kMinuteInterval;

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

@ -4,8 +4,12 @@
@implementation LKEphemeralMessage
+ (LKEphemeralMessage *)createEmptyOutgoingMessageInThread:(TSThread *)thread {
return [[LKEphemeralMessage alloc] 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];
return [[LKEphemeralMessage alloc] initInThread:thread];
}
- (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; }

Loading…
Cancel
Save