Pull logging into SyncPushTokensJob.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 716aa772f6
commit dd3d63623a

@ -24,7 +24,6 @@
#import "VersionMigrations.h" #import "VersionMigrations.h"
#import "ViewControllerUtils.h" #import "ViewControllerUtils.h"
#import <AxolotlKit/SessionCipher.h> #import <AxolotlKit/SessionCipher.h>
#import <PromiseKit/AnyPromise.h>
#import <SignalServiceKit/OWSDisappearingMessagesJob.h> #import <SignalServiceKit/OWSDisappearingMessagesJob.h>
#import <SignalServiceKit/OWSFailedAttachmentDownloadsJob.h> #import <SignalServiceKit/OWSFailedAttachmentDownloadsJob.h>
#import <SignalServiceKit/OWSFailedMessagesJob.h> #import <SignalServiceKit/OWSFailedMessagesJob.h>
@ -151,13 +150,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager] [OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager]
accountManager:[Environment getCurrent].accountManager accountManager:[Environment getCurrent].accountManager
preferences:[Environment preferences]] preferences:[Environment preferences]];
.then(^{
DDLogDebug(@"%@ Successfully ran syncPushTokensJob.", self.tag);
})
.catch(^(NSError *_Nonnull error) {
DDLogError(@"%@ Failed to run syncPushTokensJob with error: %@", self.tag, error);
});
// Clean up any messages that expired since last launch. // Clean up any messages that expired since last launch.
[[[OWSDisappearingMessagesJob alloc] initWithStorageManager:[TSStorageManager sharedManager]] run]; [[[OWSDisappearingMessagesJob alloc] initWithStorageManager:[TSStorageManager sharedManager]] run];

@ -18,16 +18,12 @@ class SyncPushTokensJob: NSObject {
self.preferences = preferences self.preferences = preferences
} }
@objc class func run(pushManager: PushManager, accountManager: AccountManager, preferences: PropertyListPreferences) -> AnyPromise { @objc class func run(pushManager: PushManager, accountManager: AccountManager, preferences: PropertyListPreferences) {
let job = self.init(pushManager: pushManager, accountManager: accountManager, preferences: preferences) let job = self.init(pushManager: pushManager, accountManager: accountManager, preferences: preferences)
return AnyPromise(job.run()) job.run()
} }
@objc func run() -> AnyPromise { func run() {
return AnyPromise(run())
}
func run() -> Promise<Void> {
Logger.debug("\(TAG) Starting.") Logger.debug("\(TAG) Starting.")
// Required to potentially prompt user for notifications settings // Required to potentially prompt user for notifications settings
@ -44,10 +40,13 @@ class SyncPushTokensJob: NSObject {
return self.accountManager.updatePushTokens(pushToken:pushToken, voipToken:voipToken).then { return self.accountManager.updatePushTokens(pushToken:pushToken, voipToken:voipToken).then {
return self.recordNewPushTokens(pushToken:pushToken, voipToken:voipToken) return self.recordNewPushTokens(pushToken:pushToken, voipToken:voipToken)
} }
}.then {
Logger.debug("\(self.TAG) Successfully ran syncPushTokensJob.")
}.catch { error in
Logger.error("\(self.TAG) Failed to run syncPushTokensJob with error: \(error).")
} }
runPromise.retainUntilComplete()
return runPromise runPromise.retainUntilComplete()
} }
private func requestPushTokens() -> Promise<(pushToken: String, voipToken: String)> { private func requestPushTokens() -> Promise<(pushToken: String, voipToken: String)> {

@ -10,7 +10,6 @@
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import "TSAccountManager.h" #import "TSAccountManager.h"
#import "Pastelog.h" #import "Pastelog.h"
#import <PromiseKit/AnyPromise.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -130,22 +129,9 @@ typedef NS_ENUM(NSInteger, AdvancedSettingsTableViewControllerSection) {
[DDLog flushLog]; [DDLog flushLog];
[Pastelog submitLogs]; [Pastelog submitLogs];
} else if ([tableView cellForRowAtIndexPath:indexPath] == self.registerPushCell) { } else if ([tableView cellForRowAtIndexPath:indexPath] == self.registerPushCell) {
OWSSyncPushTokensJob *syncJob = [OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager]
[[OWSSyncPushTokensJob alloc] initWithPushManager:[PushManager sharedManager]
accountManager:[Environment getCurrent].accountManager accountManager:[Environment getCurrent].accountManager
preferences:[Environment preferences]]; preferences:[Environment preferences]];
[syncJob run]
.then(^{
DDLogDebug(@"%@ Successfully ran syncPushTokensJob.", self.tag);
[OWSAlerts showAlertWithTitle:NSLocalizedString(@"PUSH_REGISTER_SUCCESS",
@"Title of alert shown when push tokens sync job succeeds.")];
})
.catch(^(NSError *error) {
DDLogError(@"%@ Failed to run syncPushTokensJob with error: %@", self.tag, error);
[OWSAlerts showAlertWithTitle:NSLocalizedString(@"REGISTRATION_BODY",
@"Title of alert shown when push tokens sync job fails.")];
});
} else { } else {
DDLogDebug(@"%@ Ignoring cell selection at indexPath: %@", self.tag, indexPath); DDLogDebug(@"%@ Ignoring cell selection at indexPath: %@", self.tag, indexPath);
} }

@ -18,7 +18,6 @@
#import "TSStorageManager.h" #import "TSStorageManager.h"
#import "UIUtil.h" #import "UIUtil.h"
#import "VersionMigrations.h" #import "VersionMigrations.h"
#import <PromiseKit/AnyPromise.h>
#import <SignalServiceKit/OWSBlockingManager.h> #import <SignalServiceKit/OWSBlockingManager.h>
#import <SignalServiceKit/OWSMessageSender.h> #import <SignalServiceKit/OWSMessageSender.h>
#import <SignalServiceKit/TSMessagesManager.h> #import <SignalServiceKit/TSMessagesManager.h>
@ -339,13 +338,7 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
{ {
[OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager] [OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager]
accountManager:self.accountManager accountManager:self.accountManager
preferences:[Environment preferences]] preferences:[Environment preferences]];
.then(^{
DDLogDebug(@"%@ Successfully ran syncPushTokensJob.", self.tag);
})
.catch(^(NSError *_Nonnull error) {
DDLogError(@"%@ Failed to run syncPushTokensJob with error: %@", self.tag, error);
});
} }
- (void)tableViewSetUp { - (void)tableViewSetUp {

Loading…
Cancel
Save