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.
73 lines
2.1 KiB
Objective-C
73 lines
2.1 KiB
Objective-C
//
|
|
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import "OWSDisappearingMessagesConfigurationMessage.h"
|
|
#import "OWSDisappearingMessagesConfiguration.h"
|
|
#import <SessionProtocolKit/NSDate+OWS.h>
|
|
#import <SignalUtilitiesKit/SignalUtilitiesKit-Swift.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@interface OWSDisappearingMessagesConfigurationMessage ()
|
|
|
|
@property (nonatomic, readonly) OWSDisappearingMessagesConfiguration *configuration;
|
|
|
|
@end
|
|
|
|
#pragma mark -
|
|
|
|
@implementation OWSDisappearingMessagesConfigurationMessage
|
|
|
|
- (BOOL)shouldBeSaved
|
|
{
|
|
return NO;
|
|
}
|
|
|
|
- (uint)ttl { return (uint)[LKTTLUtilities getTTLFor:LKMessageTypeDisappearingMessagesConfiguration]; }
|
|
|
|
- (instancetype)initWithConfiguration:(OWSDisappearingMessagesConfiguration *)configuration thread:(TSThread *)thread
|
|
{
|
|
// MJK TODO - remove sender timestamp
|
|
self = [super initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
|
inThread:thread
|
|
messageBody:nil
|
|
attachmentIds:[NSMutableArray new]
|
|
expiresInSeconds:0
|
|
expireStartedAt:0
|
|
isVoiceMessage:NO
|
|
groupMetaMessage:TSGroupMetaMessageUnspecified
|
|
quotedMessage:nil
|
|
contactShare:nil
|
|
linkPreview:nil];
|
|
if (!self) {
|
|
return self;
|
|
}
|
|
|
|
_configuration = configuration;
|
|
|
|
return self;
|
|
}
|
|
|
|
|
|
- (nullable id)dataMessageBuilder
|
|
{
|
|
SSKProtoDataMessageBuilder *_Nullable dataMessageBuilder = [super dataMessageBuilder];
|
|
if (!dataMessageBuilder) {
|
|
return nil;
|
|
}
|
|
[dataMessageBuilder setTimestamp:self.timestamp];
|
|
[dataMessageBuilder setFlags:SSKProtoDataMessageFlagsExpirationTimerUpdate];
|
|
if (self.configuration.isEnabled) {
|
|
[dataMessageBuilder setExpireTimer:self.configuration.durationSeconds];
|
|
} else {
|
|
[dataMessageBuilder setExpireTimer:0];
|
|
}
|
|
|
|
return dataMessageBuilder;
|
|
}
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|