session-ios/SignalServiceKit/src/Messages/OWSNotifyRemoteOfUpdatedDisappearingConfigurationJob.m
Matthew Chen 19ba564f80 Respond to CR.
// FREEBIE
2017-11-15 13:21:31 -05:00

68 lines
2.1 KiB
Objective-C

//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSNotifyRemoteOfUpdatedDisappearingConfigurationJob.h"
#import "OWSDisappearingMessagesConfigurationMessage.h"
#import "OWSMessageSender.h"
NS_ASSUME_NONNULL_BEGIN
@interface OWSNotifyRemoteOfUpdatedDisappearingConfigurationJob ()
@property (nonatomic, readonly) OWSDisappearingMessagesConfiguration *configuration;
@property (nonatomic, readonly) OWSMessageSender *messageSender;
@property (nonatomic, readonly) TSThread *thread;
@end
@implementation OWSNotifyRemoteOfUpdatedDisappearingConfigurationJob
- (instancetype)initWithConfiguration:(OWSDisappearingMessagesConfiguration *)configuration
thread:(TSThread *)thread
messageSender:(OWSMessageSender *)messageSender
{
self = [super init];
if (!self) {
return self;
}
_thread = thread;
_configuration = configuration;
_messageSender = messageSender;
return self;
}
+ (void)runWithConfiguration:(OWSDisappearingMessagesConfiguration *)configuration
thread:(TSThread *)thread
messageSender:(OWSMessageSender *)messageSender
{
OWSNotifyRemoteOfUpdatedDisappearingConfigurationJob *job =
[[self alloc] initWithConfiguration:configuration thread:thread messageSender:messageSender];
[job run];
}
- (void)run
{
OWSDisappearingMessagesConfigurationMessage *message =
[[OWSDisappearingMessagesConfigurationMessage alloc] initWithConfiguration:self.configuration
thread:self.thread];
[self.messageSender enqueueMessage:message
success:^{
DDLogDebug(
@"%@ Successfully notified %@ of new disappearing messages configuration", self.logTag, self.thread);
}
failure:^(NSError *error) {
DDLogError(@"%@ Failed to notify %@ of new disappearing messages configuration with error: %@",
self.logTag,
self.thread,
error);
}];
}
@end
NS_ASSUME_NONNULL_END