Skip to content

Commit

Permalink
fix: use message + player for ban hash (#1564)
Browse files Browse the repository at this point in the history
  • Loading branch information
iBotPeaches authored Jan 11, 2025
1 parent 08554cc commit ad4dc2b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Models/PlayerBan.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function fromDotApi(array $payload): ?self
// There is nothing unique about a ban message. So lets make a key of a slugged message with datetime of expiration.
$message = Arr::get($payload, 'message');
$endDate = Arr::get($payload, 'end_date');
$key = md5(Str::slug($message).$endDate);
$key = md5(Str::slug($message).$player->id);

/** @var PlayerBan $playerBan */
$playerBan = self::query()
Expand Down
28 changes: 28 additions & 0 deletions database/migrations/2025_01_11_140745_reprocess_hash_ban_keys.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

use App\Models\PlayerBan;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Str;

return new class extends Migration
{
public function up(): void
{
PlayerBan::query()
->with('player')
->whereNotNull('key')
->get()
->each(function (PlayerBan $ban) {
$ban->update([
'key' => md5(Str::slug($ban->message).$ban->player_id),
]);
});
}

public function down(): void
{
//
}
};

0 comments on commit ad4dc2b

Please sign in to comment.