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

@ -18,16 +18,12 @@ class SyncPushTokensJob: NSObject {
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)
return AnyPromise(job.run())
job.run()
}
@objc func run() -> AnyPromise {
return AnyPromise(run())
}
func run() -> Promise<Void> {
func run() {
Logger.debug("\(TAG) Starting.")
// Required to potentially prompt user for notifications settings
@ -43,11 +39,14 @@ class SyncPushTokensJob: NSObject {
return self.accountManager.updatePushTokens(pushToken:pushToken, voipToken:voipToken).then {
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)> {

@ -10,7 +10,6 @@
#import "Signal-Swift.h"
#import "TSAccountManager.h"
#import "Pastelog.h"
#import <PromiseKit/AnyPromise.h>
NS_ASSUME_NONNULL_BEGIN
@ -130,22 +129,9 @@ typedef NS_ENUM(NSInteger, AdvancedSettingsTableViewControllerSection) {
[DDLog flushLog];
[Pastelog submitLogs];
} else if ([tableView cellForRowAtIndexPath:indexPath] == self.registerPushCell) {
OWSSyncPushTokensJob *syncJob =
[[OWSSyncPushTokensJob alloc] initWithPushManager:[PushManager sharedManager]
accountManager:[Environment getCurrent].accountManager
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.")];
});
[OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager]
accountManager:[Environment getCurrent].accountManager
preferences:[Environment preferences]];
} else {
DDLogDebug(@"%@ Ignoring cell selection at indexPath: %@", self.tag, indexPath);
}

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

Loading…
Cancel
Save