Show notification if payment requires fee acceptance

This commit is contained in:
Daniel Granhão
2024-12-30 11:17:06 +00:00
parent b120e707cd
commit 0a371e087b
4 changed files with 83 additions and 4 deletions

View File

@@ -43,6 +43,13 @@ class SwapUpdatedTask : TaskProtocol {
self.notifySuccess(payment: payment)
}
break
case .paymentWaitingFeeAcceptance(details: let payment):
let swapId = self.getSwapId(details: payment.details)
if swapIdHash == swapId?.sha256() {
self.logger.log(tag: TAG, line: "Received payment event: \(swapIdHash) \(payment.status)", level: "INFO")
self.notifyPaymentWaitingFeeAcceptance(payment: payment)
}
break
default:
break
}
@@ -81,4 +88,18 @@ class SwapUpdatedTask : TaskProtocol {
self.displayPushNotification(title: String(format: notificationTitle, payment.amountSat), logger: self.logger, threadIdentifier: Constants.NOTIFICATION_THREAD_SWAP_UPDATED)
}
}
func notifyPaymentWaitingFeeAcceptance(payment: Payment) {
if !self.notified {
self.logger.log(tag: TAG, line: "Payment \(payment.txId ?? "") requires fee acceptance", level: "INFO")
let notificationTitle = ResourceHelper.shared.getString(
key: Constants.PAYMENT_WAITING_FEE_ACCEPTANCE_TITLE,
fallback: Constants.DEFAULT_PAYMENT_WAITING_FEE_ACCEPTANCE_TITLE)
let notificationBody = ResourceHelper.shared.getString(
key: Constants.PAYMENT_WAITING_FEE_ACCEPTANCE_TEXT,
fallback: Constants.DEFAULT_PAYMENT_WAITING_FEE_ACCEPTANCE_TEXT)
self.notified = true
self.displayPushNotification(title: notificationTitle, body: notificationBody, logger: self.logger, threadIdentifier: Constants.NOTIFICATION_THREAD_SWAP_UPDATED)
}
}
}