forked from corowne/lorekeeper
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add strike expiry, cleanups, some configs
- Loading branch information
1 parent
66fc5aa
commit 373c944
Showing
30 changed files
with
465 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use App\Facades\Settings; | ||
use App\Models\Mail\ModMail; | ||
use App\Services\UserService; | ||
|
||
class RemoveExpiredStrikes extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'remove-expired-strikes'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Removes expired strikes from mod mail.'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
// | ||
$mails = ModMail::where('has_expired', 0)->where('issue_strike', 1)->where('strike_expiry', '<', now())->get(); | ||
foreach ($mails as $mail) { | ||
$mail->update(['has_expired' => 1]); | ||
$newStrikeCount = $mail->user->settings->strike_count - $mail->strike_count; | ||
$mail->user->settings->update(['strike_count' => $newStrikeCount > 0 ? $newStrikeCount : 0]); | ||
|
||
if (config('lorekeeper.mod_mail.unban_on_strike_expiry') && $newStrikeCount < Settings::get('max_strike_count')) { | ||
$service = new UserService; | ||
$service->unban($mail->user); | ||
|
||
$this->info('Unbanned user ' . $mail->recipient->username . ' due to expired strike.'); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.