Skip to content

Commit abc923b

Browse files
alexp8Sneer-ra2TF338
authored
Fix: Cooldown Bans Starting Immediately (#463)
* add more logs and update secondsInQueue (#456) Co-authored-by: Sneer-ra2 <116219243+Sneer-ra2@users.noreply.github.com> * set AutoSaveInterval to 0 * update secondsInQueue to use updated_at * fix secondsInQueue bug * update player name fix * account-settings updates * Fix: Cooldown should start on connect (#452) (#461) * Fix: Cooldown should start on connect (#452) * Fix: Cooldown should start on connect * Fix: Cooldown should start on connect * housekeeping --------- Co-authored-by: TF338 <211804947+TF338@users.noreply.github.com> * fix cooldown --------- Co-authored-by: Sneer-ra2 <116219243+Sneer-ra2@users.noreply.github.com> Co-authored-by: TF338 <211804947+TF338@users.noreply.github.com>
1 parent 4a773e5 commit abc923b

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

cncnet-api/app/Http/Controllers/AdminController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ public function editUserBan(Request $request, $ladderId = null, $playerId = null
13121312

13131313
$user = $player->user;
13141314

1315-
$expires = $ban->expires->eq(\App\Models\Ban::unstartedBanTime()) ? null : $ban->expires;
1315+
$expires = $ban->started() ? $ban->expires : null;
13161316

13171317
return view(
13181318
"admin.edit-ban",

cncnet-api/app/Models/Ban.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function started()
116116
*/
117117
public function checkStartBan($startBanStraightAway = false)
118118
{
119-
// Log::debug("checkStartBan: ban_id=" . $this->id . ", startBanStraightAway=" . $startBanStraightAway . ", ban_type=" . $this->ban_type . ", desc=" . Ban::typeToDescription($this->ban_type) . ", expires=" . $this->expires);
119+
// Log::debug("checkStartBan: ban_id=" . ($this->id ?? 'NULL') . ", startBanStraightAway=" . ($startBanStraightAway ? 'true' : 'false') . ", ban_type=" . $this->ban_type . ", expires=" . ($this->expires ?? 'NULL') . ", started=" . ($this->started() ? 'true' : 'false'));
120120

121121
$banned = false;
122122
$cooldown = false;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('bans', function (Blueprint $table) {
15+
// Allow NULL for expires column so cooldown bans can remain unstarted
16+
$table->timestamp('expires')->nullable()->default(null)->change();
17+
});
18+
}
19+
20+
/**
21+
* Reverse the migrations.
22+
*/
23+
public function down(): void
24+
{
25+
Schema::table('bans', function (Blueprint $table) {
26+
// Revert to NOT NULL with default '0000-00-00 00:00:00'
27+
$table->timestamp('expires')->nullable(false)->default('0000-00-00 00:00:00')->change();
28+
});
29+
}
30+
};

cncnet-api/resources/views/admin/moderate-player.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
@endif
155155
</td>
156156

157-
@if ($ban->expires === null || $ban->expires->eq(\App\Models\Ban::unstartedBanTime()))
157+
@if (!$ban->started())
158158
<td>Not Started</td>
159159
<td>
160160
<form method="POST"

0 commit comments

Comments
 (0)