diff --git a/app/Livewire/Ui/Nx/Mail/QuarantineList.php b/app/Livewire/Ui/Nx/Mail/QuarantineList.php index 21c4fd3..f9419f2 100644 --- a/app/Livewire/Ui/Nx/Mail/QuarantineList.php +++ b/app/Livewire/Ui/Nx/Mail/QuarantineList.php @@ -29,26 +29,46 @@ class QuarantineList extends Component #[On('quarantine:updated')] public function refresh(): void {} - public function clearHistory(): void - { - $password = env('RSPAMD_PASSWORD', ''); - $opts = [ - 'http' => [ - 'method' => 'POST', - 'timeout' => 5, - 'ignore_errors' => true, - 'content' => '', - 'header' => "Content-Type: application/json\r\n" . - ($password !== '' ? "Password: {$password}\r\n" : ''), - ], - ]; - $ctx = stream_context_create($opts); - @file_get_contents('http://127.0.0.1:11334/historyreset', false, $ctx); + // ── Löschen (lokal via Cache, RSpamd hat keine per-entry API) ──────────── - $this->dispatch('toast', type: 'done', badge: 'Quarantäne', - title: 'Verlauf geleert', - text: 'RSpamd-History wurde zurückgesetzt.', - duration: 3000); + private function hiddenKey(): string + { + return 'quarantine.hidden.' . session()->getId(); + } + + private function getHidden(): array + { + return \Cache::get($this->hiddenKey(), []); + } + + private function saveHidden(array $ids): void + { + \Cache::put($this->hiddenKey(), array_values(array_unique($ids)), now()->addDays(7)); + } + + public function deleteEntry(string $id): void + { + $hidden = $this->getHidden(); + $hidden[] = $id; + $this->saveHidden($hidden); + } + + public function deleteCurrentTab(): void + { + $all = $this->fetchHistory(); + $hidden = $this->getHidden(); + + $toHide = match($this->filter) { + 'suspicious' => array_filter($all, fn($m) => $m['action'] !== 'no action'), + 'all' => $all, + default => array_filter($all, fn($m) => $m['action'] === $this->filter), + }; + + foreach ($toHide as $m) { + $hidden[] = $m['id']; + } + $this->saveHidden($hidden); + $this->resetPage(); } public function updatedFilter(): void { $this->resetPage(); } @@ -65,7 +85,11 @@ class QuarantineList extends Component public function render() { - $all = $this->fetchHistory(); + $hidden = $this->getHidden(); + $all = array_values(array_filter( + $this->fetchHistory(), + fn($m) => !in_array($m['id'], $hidden, true) + )); $suspicious = array_values(array_filter($all, fn($m) => $m['action'] !== 'no action')); diff --git a/resources/views/livewire/ui/nx/mail/quarantine-list.blade.php b/resources/views/livewire/ui/nx/mail/quarantine-list.blade.php index a4afa65..c423f00 100644 --- a/resources/views/livewire/ui/nx/mail/quarantine-list.blade.php +++ b/resources/views/livewire/ui/nx/mail/quarantine-list.blade.php @@ -20,14 +20,14 @@ 50 / Seite 100 / Seite - @if($counts['all'] > 0) - + @if($messages->total() > 0) + - Verlauf leeren + Tab leeren @endif @@ -104,10 +104,16 @@ @endif {{ $msg['time'] > 0 ? date('d.m H:i', $msg['time']) : '—' }} - + + + + + + @endforeach