Merge pull request #807 from shocknet/deb-offer

delete default offer
This commit is contained in:
Justin (shocknet) 2025-05-21 12:25:18 -04:00 committed by GitHub
commit 3d65749269
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -199,6 +199,14 @@ export class OfferManager {
if (!userOffer) { if (!userOffer) {
return this.HandleDefaultUserOffer(offerReq, appId, remote) return this.HandleDefaultUserOffer(offerReq, appId, remote)
} }
if (userOffer.app_user_id === userOffer.offer_id) {
if (userOffer.price_sats !== 0 || userOffer.expected_data) {
this.logger("default offer has custom price or expected data, resetting")
await this.storage.offerStorage.UpdateUserOffer(userOffer.app_user_id, userOffer.offer_id, { price_sats: 0, expected_data: null })
userOffer.price_sats = 0
userOffer.expected_data = null
}
}
let amt = userOffer.price_sats let amt = userOffer.price_sats
if (userOffer.price_sats === 0) { if (userOffer.price_sats === 0) {
if (!amount || isNaN(amount) || amount < 10 || amount > remote) { if (!amount || isNaN(amount) || amount < 10 || amount > remote) {
@ -208,6 +216,7 @@ export class OfferManager {
} }
const { passed, validated } = this.ValidateExpectedData(userOffer, offerReq.payer_data) const { passed, validated } = this.ValidateExpectedData(userOffer, offerReq.payer_data)
if (!passed) { if (!passed) {
console.log("Invalid expected data", validated)
return { success: false, code: 1, max: remote } return { success: false, code: 1, max: remote }
} }
const res = await this.applicationManager.AddAppUserInvoice(appId, { const res = await this.applicationManager.AddAppUserInvoice(appId, {