mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge branch 'charlesmchen/registrationEdgeCases'
This commit is contained in:
commit
f65708c36f
|
@ -19,8 +19,7 @@ public class AccountManager: NSObject {
|
|||
}
|
||||
|
||||
@objc
|
||||
public override init()
|
||||
{
|
||||
public override init() {
|
||||
super.init()
|
||||
|
||||
SwiftSingletons.register(self)
|
||||
|
@ -72,7 +71,9 @@ public class AccountManager: NSObject {
|
|||
default:
|
||||
throw error
|
||||
}
|
||||
}.done {
|
||||
}.then { (_) in
|
||||
self.tsAccountManager.performUpdateAccountAttributes()
|
||||
}.done { (_) in
|
||||
self.completeRegistration()
|
||||
}
|
||||
|
||||
|
|
|
@ -226,6 +226,10 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
|
|||
- (void)sendConfigurationSyncMessage_AppReady {
|
||||
DDLogInfo(@"");
|
||||
|
||||
if (![TSAccountManager sharedInstance].isRegistered) {
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL areReadReceiptsEnabled = SSKEnvironment.shared.readReceiptManager.areReadReceiptsEnabled;
|
||||
BOOL showUnidentifiedDeliveryIndicators = Environment.shared.preferences.shouldShowUnidentifiedDeliveryIndicators;
|
||||
BOOL showTypingIndicators = self.typingIndicators.areTypingIndicatorsEnabled;
|
||||
|
|
|
@ -144,6 +144,9 @@ extern NSString *const kNSNotificationName_LocalNumberDidChange;
|
|||
|
||||
- (AnyPromise *)updateAccountAttributes;
|
||||
|
||||
// This should only be used during the registration process.
|
||||
- (AnyPromise *)performUpdateAccountAttributes;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -659,8 +659,7 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
|
|||
if (!updateRequestDate) {
|
||||
return [AnyPromise promiseWithValue:@(1)];
|
||||
}
|
||||
|
||||
AnyPromise *promise = [[SignalServiceRestClient new] updateAccountAttributesObjC];
|
||||
AnyPromise *promise = [self performUpdateAccountAttributes];
|
||||
promise = promise.then(^(id value) {
|
||||
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
// Clear the update request unless a new update has been requested
|
||||
|
@ -673,7 +672,14 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
|
|||
inCollection:TSAccountManager_UserAccountCollection];
|
||||
}
|
||||
}];
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
||||
- (AnyPromise *)performUpdateAccountAttributes
|
||||
{
|
||||
AnyPromise *promise = [[SignalServiceRestClient new] updateAccountAttributesObjC];
|
||||
promise = promise.then(^(id value) {
|
||||
// Fetch the local profile, as we may have changed its
|
||||
// account attributes. Specifically, we need to determine
|
||||
// if all devices for our account now support UD for sync
|
||||
|
|
|
@ -688,6 +688,18 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|||
|
||||
TSThread *_Nullable thread = message.thread;
|
||||
|
||||
BOOL isSyncMessage = [message isKindOfClass:[OWSOutgoingSyncMessage class]];
|
||||
if (!thread && !isSyncMessage) {
|
||||
OWSFailDebug(@"Missing thread for non-sync message.");
|
||||
|
||||
// This thread has been deleted since the message was enqueued.
|
||||
NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeMessageSendNoValidRecipients,
|
||||
NSLocalizedString(@"ERROR_DESCRIPTION_NO_VALID_RECIPIENTS",
|
||||
@"Error indicating that an outgoing message had no valid recipients."));
|
||||
[error setIsRetryable:NO];
|
||||
return failureHandler(error);
|
||||
}
|
||||
|
||||
// In the "self-send" special case, we ony need to send a sync message with a delivery receipt.
|
||||
if ([thread isKindOfClass:[TSContactThread class]] &&
|
||||
[((TSContactThread *)thread).contactIdentifier isEqualToString:[TSAccountManager localNumber]]) {
|
||||
|
|
Loading…
Reference in a new issue