From 1f7483687fdcd82c472cfdecf983ef5b8c9c3472 Mon Sep 17 00:00:00 2001 From: softsimon Date: Thu, 8 Oct 2020 00:20:42 +0700 Subject: [PATCH] Don't allow invoices lower than 0.001 and require 0.01 for sponsorship. refs #122 --- backend/src/api/donations.ts | 37 +++++++++++-------- backend/src/routes.ts | 4 +- .../app/components/about/about.component.html | 14 +++++-- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/backend/src/api/donations.ts b/backend/src/api/donations.ts index 1c13f7a79..fde21940f 100644 --- a/backend/src/api/donations.ts +++ b/backend/src/api/donations.ts @@ -48,23 +48,30 @@ class Donations { if (!data || !data.id) { return; } + const response = await this.getStatus(data.id); - if (response.status === 'complete') { - if (this.notifyDonationStatusCallback) { - this.notifyDonationStatusCallback(data.id); - } - - let imageUrl = ''; - if (response.orderId !== '') { - try { - imageUrl = await this.$getTwitterImageUrl(response.orderId); - } catch (e) { - console.log('Error fetching twitter image from Hive', e.message); - } - } - - this.$addDonationToDatabase(response, imageUrl); + if (response.status !== 'complete') { + return; } + + if (this.notifyDonationStatusCallback) { + this.notifyDonationStatusCallback(data.id); + } + + if (parseFloat(response.btcPaid) < 0.001) { + return; + } + + let imageUrl = ''; + if (response.orderId !== '') { + try { + imageUrl = await this.$getTwitterImageUrl(response.orderId); + } catch (e) { + console.log('Error fetching twitter image', e.message); + } + } + + this.$addDonationToDatabase(response, imageUrl); } private getStatus(id: string): Promise { diff --git a/backend/src/routes.ts b/backend/src/routes.ts index 0442fcb7a..cde97e39c 100644 --- a/backend/src/routes.ts +++ b/backend/src/routes.ts @@ -117,8 +117,8 @@ class Routes { return; } - if (p.amount < 0.01) { - res.status(400).send('Amount needs to be at least 0.01'); + if (p.amount < 0.001) { + res.status(400).send('Amount needs to be at least 0.001'); return; } diff --git a/frontend/src/app/components/about/about.component.html b/frontend/src/app/components/about/about.component.html index a7a289b20..f84270ca1 100644 --- a/frontend/src/app/components/about/about.component.html +++ b/frontend/src/app/components/about/about.component.html @@ -27,9 +27,9 @@
- + -
+
@
@@ -41,12 +41,20 @@
+ +
+ If you donate 0.01 BTC or more, your profile photo will be added to the list of sponsors above :) +
+
+
-
+

{{ donationObj.address }}

+

{{ donationObj.amount }} BTC

+

Waiting for transaction...