From af59aaf2361fbd57987caf9a3693ffaa97b5804a Mon Sep 17 00:00:00 2001 From: dev Date: Mon, 27 Sep 2021 19:46:08 -0700 Subject: [PATCH] Fix issue with multiple payments If someone sent multiple Monero transactions in 1 tx, it was only getting the first one. Monero GUI wallet and Cake Wallet support this feature but xmrmemes did not. This should be fixed now. All past multi-payments that were not counted will be counted and the meme creators will recieve the XMR. --- app/Jobs/ProcessPayments.php | 5 ++- .../2021_09_27_233956_edit_tips_table.php | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2021_09_27_233956_edit_tips_table.php diff --git a/app/Jobs/ProcessPayments.php b/app/Jobs/ProcessPayments.php index 3662a42..fe4deda 100644 --- a/app/Jobs/ProcessPayments.php +++ b/app/Jobs/ProcessPayments.php @@ -71,7 +71,10 @@ class ProcessPayments implements ShouldQueue if (isset($get_transfers['in'])) { foreach ($get_transfers['in'] as $transfer) { $meme = Meme::where('address', $transfer['address'])->first(); - $tip_exists = Tip::where('txid', $transfer['txid'])->first(); + $tip_exists = Tip::where([ + 'meme_id' => $meme->id, + 'txid' => $transfer['txid'], + ])->first(); if ($meme && !$tip_exists) { $tip = new Tip(); $tip->meme_id = $meme->id; diff --git a/database/migrations/2021_09_27_233956_edit_tips_table.php b/database/migrations/2021_09_27_233956_edit_tips_table.php new file mode 100644 index 0000000..5a8a420 --- /dev/null +++ b/database/migrations/2021_09_27_233956_edit_tips_table.php @@ -0,0 +1,34 @@ +dropUnique(['txid']); + $table->unique(['meme_id', 'txid']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('tips', function (Blueprint $table) { + $table->dropUnique(['meme_id', 'txid']); + $table->unique(['txid']); + }); + } +}