Added some more links to the chat messages list to easer go to the message users profile, inbox, bans etc.

This commit is contained in:
Vari 2024-07-27 18:59:16 +02:00
parent 45cb45b8cc
commit b483513064
6 changed files with 65 additions and 22 deletions

View File

@ -21,18 +21,24 @@ public function checkUsername(CheckUsernameRequest $request): mixed
public function checkChatMessage(CheckChatMessageRequest $request): mixed
{
// Lobby Host that send the request to check the message. We log him too since only the lobby host checks the messages in teh backend.
$hostUser = Auth::user();
// User that send the chat message
$messageUser = User::find($request->userId);
$checker = Builder::blocker($request->message);
if($checker->clean())
return response('{}');
$this->logBadMessage(Auth::user(), $request->message);
$this->logBadMessage($hostUser, $messageUser, $request->message);
return response('Bad Message >:(');
}
public function logBadMessage(User $user, string $message): void {
public function logBadMessage(User $hostUser, User $messageUser, string $message): void {
$badMessage = new BadChatMessage();
$badMessage->user()->associate($user);
$badMessage->hostUser()->associate($hostUser);
$badMessage->user()->associate($messageUser);
$badMessage->message = $message;
$badMessage->save();
}

View File

@ -20,7 +20,7 @@ class ChatMessageController extends AdminToolController
public function index()
{
$badMessages = BadChatMessage::orderBy('handled', 'desc')
$badMessages = BadChatMessage::orderBy('handled')
->paginate();
return view('admin.tools.chat-messages', ['messages' => $badMessages]);

View File

@ -24,4 +24,9 @@ public function handledBy(): BelongsTo
{
return $this->belongsTo(User::class, 'handled_by_id');
}
public function hostUser(): BelongsTo
{
return $this->belongsTo(User::class, 'host_user_id');
}
}

View File

@ -13,6 +13,7 @@ public function up(): void
{
Schema::create('bad_chat_messages', function (Blueprint $table) {
$table->id();
$table->foreignUuid('host_user_id')->constrained('users');
$table->foreignUuid('user_id')->constrained();
$table->text('message');
$table->boolean('handled')->default(false);

View File

@ -21,10 +21,11 @@
@endif
@if(count($unhandledMessages) > 0)
<h1 class="text-2xl font-bold">Unhandled</h1>
<h1 class="text-2xl font-bold my-6">Unhandled</h1>
<table class="border-spacing-3">
<thead>
<th>Lobby Host</th>
<th>User</th>
<th>Message</th>
<th>Handled</th>
@ -38,10 +39,11 @@
</table>
@endif
@if(count($handledMessages) > 0)
<h1 class="text-2xl font-bold">Handled</h1>
<h1 class="text-2xl font-bold my-6">Handled</h1>
<table class="border-spacing-3">
<thead>
<th>Lobby Host</th>
<th>User</th>
<th>Message</th>
<th>Handled</th>
@ -55,5 +57,8 @@
</tbody>
</table>
@endif
<div class="mt-4">
{{ $messages->links() }}
</div>
</div>
</x-layouts.admin>

View File

@ -5,13 +5,26 @@
@csrf
<tr>
<td class="px-8">
<div class="col-start-1 flex gap-2 justify-center items-center">
<img src="{{ $message->user->avatar_small }}"
alt="Profile Picture of {{ $message->user->last_known_username }}">
<span>
<a href="{{ route('user.details', ['user' => $message->hostUser->id]) }}" target="_blank">
<div class="col-start-1 flex gap-2 justify-center items-center">
<img src="{{ $message->hostUser->avatar_small }}"
alt="Profile Picture of {{ $message->hostUser->last_known_username }}">
<span>
{{ $message->hostUser->last_known_username ?? $message->hostUser->id }}
</span>
</div>
</a>
</td>
<td class="px-8">
<a href="{{ route('user.details', ['user' => $message->user->id]) }}" target="_blank">
<div class="col-start-1 flex gap-2 justify-center items-center">
<img src="{{ $message->user->avatar_small }}"
alt="Profile Picture of {{ $message->user->last_known_username }}">
<span>
{{ $message->user->last_known_username ?? $message->user->id }}
</span>
</div>
</div>
</a>
</td>
<td>
<div class="bg-slate-700 border border-slate-500 p-2 rounded-md">
@ -33,9 +46,7 @@
</td>
@if($message->handled)
<td>
<div class="bg-slate-700 border border-slate-500 p-2 rounded-md">
{{ $message->consequences ?? '---' }}
</div>
<div class="bg-slate-700 border border-slate-500 p-2 rounded-md whitespace-pre">{{ $message->consequences ?? '---' }}</div>
</td>
<td>
@if($message->handledBy === null)
@ -53,14 +64,29 @@
@endif
@if(!$message->handled)
<td>
<x-inputs.button
type="button"
class="save"
href="#{{ $message->id }}handle-modal"
rel="modal:open"
>
Handle
</x-inputs.button>
<div class="flex items-center justify-center gap-2">
<x-inputs.button
type="button"
class="save"
href="#{{ $message->id }}handle-modal"
rel="modal:open"
>
<span class="size-6">
Handle
</span>
</x-inputs.button>
<a href="{{ route('user.bans', ['user' => $message->user->id]) }}" target="_blank">
<x-inputs.button type="button" class="px-2 py-1 !text-sm delete" title="Bans">
<x-icons.hammer class="size-6"/>
</x-inputs.button>
</a>
<a href="{{ route('user.inbox', ['user' => $message->user->id]) }}" target="_blank">
<x-inputs.button type="button" class="px-2 py-1 !text-sm" title="Inbox">
<x-icons.mail class="size-6"/>
</x-inputs.button>
</a>
</div>
<div id="{{ $message->id }}handle-modal" class="modal">
<div class="flex flex-col items-center gap-5">
<label for="{{ $message->id }}consequences">