Page MenuHomePhorge

D5056.1775284985.diff
No OneTemporary

Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None

D5056.1775284985.diff

diff --git a/src/app/Jobs/WalletCheck.php b/src/app/Jobs/WalletCheck.php
--- a/src/app/Jobs/WalletCheck.php
+++ b/src/app/Jobs/WalletCheck.php
@@ -10,9 +10,7 @@
{
public const THRESHOLD_DEGRADE = 'degrade';
public const THRESHOLD_DEGRADE_REMINDER = 'degrade-reminder';
- public const THRESHOLD_BEFORE_DEGRADE = 'before-degrade';
public const THRESHOLD_REMINDER = 'reminder';
- public const THRESHOLD_BEFORE_REMINDER = 'before-reminder';
public const THRESHOLD_INITIAL = 'initial';
/** @var int How many times retry the job if it fails. */
@@ -71,7 +69,7 @@
$this->wallet->chargeEntitlements();
try {
- $this->topUpWallet();
+ PaymentsController::topUpWallet($this->wallet);
} catch (\Exception $e) {
\Log::error("Failed to top-up wallet {$this->walletId}: " . $e->getMessage());
// Notification emails should be sent even if the top-up fails
@@ -86,17 +84,13 @@
$steps = [
// Send the initial reminder
self::THRESHOLD_INITIAL => 'initialReminderForDegrade',
- // Try to top-up the wallet before the second reminder
- self::THRESHOLD_BEFORE_REMINDER => 'topUpWallet',
// Send the second reminder
self::THRESHOLD_REMINDER => 'secondReminderForDegrade',
- // Try to top-up the wallet before the account degradation
- self::THRESHOLD_BEFORE_DEGRADE => 'topUpWallet',
// Degrade the account
self::THRESHOLD_DEGRADE => 'degradeAccount',
];
- if ($this->wallet->owner && $this->wallet->owner->isDegraded()) {
+ if ($this->wallet->owner->isDegraded()) {
$this->degradedReminder();
return self::THRESHOLD_DEGRADE_REMINDER;
}
@@ -120,7 +114,7 @@
return;
}
- if (!$this->wallet->owner || $this->wallet->owner->isDegraded()) {
+ if ($this->wallet->owner->isDegraded()) {
return;
}
@@ -141,7 +135,7 @@
return;
}
- if (!$this->wallet->owner || $this->wallet->owner->isDegraded()) {
+ if ($this->wallet->owner->isDegraded()) {
return;
}
@@ -159,7 +153,7 @@
protected function degradeAccount()
{
// The account may be already deleted, or degraded
- if (!$this->wallet->owner || $this->wallet->owner->isDegraded()) {
+ if ($this->wallet->owner->isDegraded()) {
return;
}
@@ -187,7 +181,7 @@
protected function degradedReminder()
{
// Sanity check
- if (!$this->wallet->owner || !$this->wallet->owner->isDegraded()) {
+ if (!$this->wallet->owner->isDegraded()) {
return;
}
@@ -266,12 +260,8 @@
}
$thresholds = [
- // A day before the second reminder
- self::THRESHOLD_BEFORE_REMINDER => 7 - 1,
// Second notification
self::THRESHOLD_REMINDER => 7,
- // Last chance to top-up the wallet
- self::THRESHOLD_BEFORE_DEGRADE => 13,
// Account degradation
self::THRESHOLD_DEGRADE => 14,
];
@@ -282,12 +272,4 @@
return null;
}
-
- /**
- * Try to automatically top-up the wallet
- */
- protected function topUpWallet(): void
- {
- PaymentsController::topUpWallet($this->wallet);
- }
}
diff --git a/src/tests/Feature/Jobs/WalletCheckTest.php b/src/tests/Feature/Jobs/WalletCheckTest.php
--- a/src/tests/Feature/Jobs/WalletCheckTest.php
+++ b/src/tests/Feature/Jobs/WalletCheckTest.php
@@ -135,34 +135,8 @@
$this->markTestIncomplete();
}
- /**
- * Test job handle, top-up before reminder notification
- *
- * @depends testHandleInitial
- */
- public function testHandleBeforeReminder(): void
- {
- Mail::fake();
-
- $user = $this->prepareTestUser($wallet);
- $now = Carbon::now();
-
- // Balance turned negative 7-1 days ago
- $wallet->setSetting('balance_negative_since', $now->subDays(7 - 1)->toDateTimeString());
-
- $job = new WalletCheck($wallet->id);
- $res = $job->handle();
-
- Mail::assertNothingSent();
-
- // TODO: Test that it actually executed the topUpWallet()
- $this->assertSame(WalletCheck::THRESHOLD_BEFORE_REMINDER, $res);
- }
-
/**
* Test job handle, reminder notification
- *
- * @depends testHandleBeforeReminder
*/
public function testHandleReminder(): void
{

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 6:43 AM (7 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18828406
Default Alt Text
D5056.1775284985.diff (4 KB)

Event Timeline