Merge branch 'jon/multiple_rate_limit_status_codes_IOS-2217'
This commit is contained in:
commit
5857c4b985
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2022 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
@ -598,7 +598,7 @@ public class RegistrationPhoneNumberViewController: OnboardingBaseViewController
|
||||
guard !willDismiss else { return }
|
||||
self.phoneNumberTextField.becomeFirstResponder()
|
||||
|
||||
if let error = error, error.httpStatusCode == 413 {
|
||||
if let error = error, error.httpStatusCode == 413 || error.httpStatusCode == 429 {
|
||||
// If we're not handed a retry-after date directly from the server, either
|
||||
// use the existing date we already have or construct a new date 5 min from now
|
||||
let retryAfterDate = error.httpRetryAfterDate ?? {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2022 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@ -127,7 +127,7 @@ public class RegistrationHelper: Dependencies {
|
||||
title: NSLocalizedString("REGISTRATION_ERROR", comment: ""),
|
||||
message: NSLocalizedString("REGISTRATION_NON_VALID_NUMBER", comment: ""))
|
||||
|
||||
case let error where error.httpStatusCode == 413:
|
||||
case let error where error.httpStatusCode == 413 || error.httpStatusCode == 429:
|
||||
completion?(false, error)
|
||||
OWSActionSheets.showActionSheet(
|
||||
title: nil,
|
||||
|
||||
@ -319,7 +319,7 @@ extension TSAccountManager {
|
||||
return OWSError(error: .registrationTransferAvailable,
|
||||
description: message,
|
||||
isRetryable: false)
|
||||
case 413:
|
||||
case 413, 429:
|
||||
// In the case of the "rate limiting" error, we want to show the
|
||||
// "recovery suggestion", not the error's "description."
|
||||
let recoverySuggestion = NSLocalizedString("REGISTER_RATE_LIMITING_BODY", comment: "")
|
||||
|
||||
@ -239,7 +239,7 @@ public extension MessageSender {
|
||||
if httpStatusCode == 404 {
|
||||
self.hadMissingDeviceError(recipientAddress: recipientAddress, deviceId: deviceId)
|
||||
return failure(MessageSenderError.missingDevice)
|
||||
} else if httpStatusCode == 413 {
|
||||
} else if httpStatusCode == 413 || httpStatusCode == 429 {
|
||||
return failure(MessageSenderError.prekeyRateLimit)
|
||||
} else if httpStatusCode == 428 {
|
||||
// SPAM TODO: Only retry messages with -hasRenderableContent
|
||||
|
||||
@ -138,7 +138,7 @@ public class RequestMaker: NSObject {
|
||||
}.recover(on: .global()) { (error: Error) -> Promise<RequestMakerResult> in
|
||||
let statusCode = error.httpStatusCode ?? 0
|
||||
|
||||
if statusCode == 413 {
|
||||
if statusCode == 413 || statusCode == 429 {
|
||||
// We've hit rate limit; don't retry.
|
||||
throw error
|
||||
}
|
||||
@ -192,7 +192,7 @@ public class RequestMaker: NSObject {
|
||||
wasSentByUD: isUDRequest,
|
||||
wasSentByWebsocket: false)
|
||||
}.recover(on: .global()) { (error: Error) -> Promise<RequestMakerResult> in
|
||||
if error.httpStatusCode == 413 {
|
||||
if error.httpStatusCode == 413 || error.httpStatusCode == 429 {
|
||||
// We've hit rate limit; don't retry.
|
||||
throw error
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ extension HTTPUtils {
|
||||
let error = buildServiceResponseError(description: description,
|
||||
recoverySuggestion: recoverySuggestion)
|
||||
return error
|
||||
case 413:
|
||||
case 413, 429:
|
||||
Logger.warn("Rate limit exceeded: \(request.httpMethod) \(requestUrl.absoluteString)")
|
||||
let description = NSLocalizedString("REGISTER_RATE_LIMITING_ERROR", comment: "")
|
||||
let recoverySuggestion = NSLocalizedString("REGISTER_RATE_LIMITING_BODY", comment: "")
|
||||
|
||||
@ -228,7 +228,7 @@ public class BulkProfileFetch: NSObject {
|
||||
if error.isNetworkConnectivityFailure {
|
||||
Logger.warn("Error: \(error)")
|
||||
self.lastOutcomeMap[uuid] = UpdateOutcome(.networkFailure)
|
||||
} else if error.httpStatusCode == 413 {
|
||||
} else if error.httpStatusCode == 413 || error.httpStatusCode == 429 {
|
||||
Logger.error("Error: \(error)")
|
||||
self.lastOutcomeMap[uuid] = UpdateOutcome(.retryLimit)
|
||||
self.lastRateLimitErrorDate = Date()
|
||||
|
||||
@ -256,7 +256,7 @@ public class ProfileFetcherJob: NSObject {
|
||||
if error.httpStatusCode == 404 {
|
||||
return future.reject(ProfileFetchError.missing)
|
||||
}
|
||||
if error.httpStatusCode == 413 {
|
||||
if error.httpStatusCode == 413 || error.httpStatusCode == 429 {
|
||||
return future.reject(ProfileFetchError.rateLimit)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user