Merge branch 'charlesmchen/paymentsKillSwitch'
This commit is contained in:
commit
2cfceffa8a
@ -64,10 +64,6 @@ public class PaymentsImpl: NSObject, PaymentsSwift {
|
||||
}
|
||||
|
||||
private func getOrBuildCurrentApi(paymentsEntropy: Data) -> Promise<MobileCoinAPI> {
|
||||
guard !isKillSwitchActive else {
|
||||
return Promise(error: PaymentsError.killSwitch)
|
||||
}
|
||||
|
||||
func getCurrentApi() -> MobileCoinAPI? {
|
||||
return Self.unfairLock.withLock { () -> MobileCoinAPI? in
|
||||
if let handle = self.currentApiHandle,
|
||||
@ -115,6 +111,9 @@ public class PaymentsImpl: NSObject, PaymentsSwift {
|
||||
guard FeatureFlags.paymentsEnabled else {
|
||||
return false
|
||||
}
|
||||
guard !isKillSwitchActive else {
|
||||
return false
|
||||
}
|
||||
return hasValidPhoneNumberForPayments
|
||||
}
|
||||
|
||||
@ -246,7 +245,7 @@ public class PaymentsImpl: NSObject, PaymentsSwift {
|
||||
transaction: SDSAnyWriteTransaction) {
|
||||
let oldPaymentsState = self.paymentsState
|
||||
|
||||
guard oldPaymentsState.isEnabled || canEnablePayments else {
|
||||
guard !newPaymentsState.isEnabled || canEnablePayments else {
|
||||
owsFailDebug("Payments cannot be enabled.")
|
||||
return
|
||||
}
|
||||
@ -550,7 +549,10 @@ public extension PaymentsImpl {
|
||||
receipt: MobileCoin.Receipt,
|
||||
paymentRequestModel: TSPaymentRequestModel?,
|
||||
isOutgoingTransfer: Bool) -> Promise<TSPaymentModel> {
|
||||
firstly(on: .global()) {
|
||||
guard !isKillSwitchActive else {
|
||||
return Promise(error: PaymentsError.killSwitch)
|
||||
}
|
||||
return firstly(on: .global()) {
|
||||
var addressUuidString: String?
|
||||
if let recipientAddress = recipientAddress {
|
||||
guard recipientAddress.isValid else {
|
||||
@ -720,6 +722,9 @@ public extension PaymentsImpl {
|
||||
isOutgoingTransfer: Bool,
|
||||
canDefragment: Bool) -> Promise<PreparedPayment> {
|
||||
|
||||
guard !isKillSwitchActive else {
|
||||
return Promise(error: PaymentsError.killSwitch)
|
||||
}
|
||||
guard let recipient = recipient as? SendPaymentRecipientImpl else {
|
||||
return Promise(error: OWSAssertionError("Invalid recipient."))
|
||||
}
|
||||
@ -761,6 +766,9 @@ public extension PaymentsImpl {
|
||||
isOutgoingTransfer: Bool,
|
||||
canDefragment: Bool) -> Promise<PreparedPayment> {
|
||||
|
||||
guard !isKillSwitchActive else {
|
||||
return Promise(error: PaymentsError.killSwitch)
|
||||
}
|
||||
guard paymentAmount.currency == .mobileCoin else {
|
||||
return Promise(error: OWSAssertionError("Invalid currency."))
|
||||
}
|
||||
@ -880,7 +888,10 @@ public extension PaymentsImpl {
|
||||
}
|
||||
|
||||
func initiateOutgoingPayment(preparedPayment: PreparedPayment) -> Promise<TSPaymentModel> {
|
||||
firstly(on: .global()) { () -> Promise<TSPaymentModel> in
|
||||
guard !isKillSwitchActive else {
|
||||
return Promise(error: PaymentsError.killSwitch)
|
||||
}
|
||||
return firstly(on: .global()) { () -> Promise<TSPaymentModel> in
|
||||
guard let preparedPayment = preparedPayment as? PreparedPaymentImpl else {
|
||||
throw OWSAssertionError("Invalid preparedPayment.")
|
||||
}
|
||||
|
||||
@ -674,6 +674,19 @@ private class PaymentProcessingOperation: OWSOperation {
|
||||
|
||||
Logger.verbose("")
|
||||
|
||||
guard !payments.isKillSwitchActive else {
|
||||
do {
|
||||
try Self.databaseStorage.write { transaction in
|
||||
try paymentModel.updatePaymentModelState(fromState: .outgoingUnsubmitted,
|
||||
toState: .outgoingUnverified,
|
||||
transaction: transaction)
|
||||
}
|
||||
} catch {
|
||||
owsFailDebug("Error: \(error)")
|
||||
}
|
||||
return Promise(error: PaymentsError.killSwitch)
|
||||
}
|
||||
|
||||
if DebugFlags.paymentsSkipSubmissionAndOutgoingVerification.get() {
|
||||
return Self.updatePaymentStatePromise(paymentModel: paymentModel,
|
||||
fromState: .outgoingUnsubmitted,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user