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.
79 lines
2.3 KiB
Matlab
79 lines
2.3 KiB
Matlab
9 years ago
|
// Created by Michael Kirk on 9/25/16.
|
||
|
// Copyright © 2016 Open Whisper Systems. All rights reserved.
|
||
|
|
||
|
#import "OWSNotifyRemoteOfUpdatedDisappearingConfigurationJob.h"
|
||
|
#import "OWSDisappearingMessagesConfigurationMessage.h"
|
||
9 years ago
|
#import "OWSMessageSender.h"
|
||
9 years ago
|
|
||
|
NS_ASSUME_NONNULL_BEGIN
|
||
|
|
||
|
@interface OWSNotifyRemoteOfUpdatedDisappearingConfigurationJob ()
|
||
|
|
||
|
@property (nonatomic, readonly) OWSDisappearingMessagesConfiguration *configuration;
|
||
9 years ago
|
@property (nonatomic, readonly) OWSMessageSender *messageSender;
|
||
9 years ago
|
@property (nonatomic, readonly) TSThread *thread;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation OWSNotifyRemoteOfUpdatedDisappearingConfigurationJob
|
||
|
|
||
|
- (instancetype)initWithConfiguration:(OWSDisappearingMessagesConfiguration *)configuration
|
||
|
thread:(TSThread *)thread
|
||
9 years ago
|
messageSender:(OWSMessageSender *)messageSender
|
||
9 years ago
|
{
|
||
|
self = [super init];
|
||
|
if (!self) {
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
_thread = thread;
|
||
|
_configuration = configuration;
|
||
9 years ago
|
_messageSender = messageSender;
|
||
9 years ago
|
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
+ (void)runWithConfiguration:(OWSDisappearingMessagesConfiguration *)configuration
|
||
|
thread:(TSThread *)thread
|
||
9 years ago
|
messageSender:(OWSMessageSender *)messageSender
|
||
9 years ago
|
{
|
||
|
OWSNotifyRemoteOfUpdatedDisappearingConfigurationJob *job =
|
||
9 years ago
|
[[self alloc] initWithConfiguration:configuration thread:thread messageSender:messageSender];
|
||
9 years ago
|
[job run];
|
||
|
}
|
||
|
|
||
|
- (void)run
|
||
|
{
|
||
|
OWSDisappearingMessagesConfigurationMessage *message =
|
||
|
[[OWSDisappearingMessagesConfigurationMessage alloc] initWithConfiguration:self.configuration
|
||
|
thread:self.thread];
|
||
|
|
||
9 years ago
|
[self.messageSender sendMessage:message
|
||
9 years ago
|
success:^{
|
||
|
DDLogDebug(
|
||
|
@"%@ Successfully notified %@ of new disappearing messages configuration", self.tag, self.thread);
|
||
|
}
|
||
9 years ago
|
failure:^(NSError *error) {
|
||
|
DDLogError(@"%@ Failed to notify %@ of new disappearing messages configuration with error: %@",
|
||
|
self.tag,
|
||
|
self.thread,
|
||
|
error);
|
||
9 years ago
|
}];
|
||
|
}
|
||
|
|
||
|
#pragma mark - Logging
|
||
|
|
||
|
+ (NSString *)tag
|
||
|
{
|
||
|
return [NSString stringWithFormat:@"[%@]", self.class];
|
||
|
}
|
||
|
|
||
|
- (NSString *)tag
|
||
|
{
|
||
|
return self.class.tag;
|
||
|
}
|
||
|
|
||
|
@end
|
||
|
|
||
|
NS_ASSUME_NONNULL_END
|