Skip to content

Commit 6262c04

Browse files
committed
Cache translations in EndVulnsScanListener and refine user notifications in RunScheduledTasks.
1 parent 430cddf commit 6262c04

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

app/Jobs/RunScheduledTasks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function handle()
9494
$response = $this->ask($user, $threadId, $tsk);
9595
$answer = $response['html'] ?? '';
9696
$summary = LlmsProvider::provide("Summarize this text in about 10 words :\n\n{$answer}");
97-
$user->notify(new Notification($answer, "Cywise : {$summary}"));
97+
$user->notify(new Notification($answer));
9898
Log::debug("[RunScheduledTasks] Emailed result for task {$task->id} to {$user->email}");
9999
$task->last_email_sent_at = Carbon::now();
100100
$ran = true;

app/Listeners/EndVulnsScanListener.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,22 +194,21 @@ private function setAlerts(Port $port, array $task): void
194194
'flarum_slug' => null, // TODO : remove?
195195
]);
196196

197+
// Cache translations
198+
$a->translated('title');
199+
$a->translated('vulnerability');
200+
$a->translated('remediation');
201+
197202
if ($a->isHigh()) {
198203

199204
/** @var Asset $asset */
200205
$asset = $port->scan->asset;
201206
$users = User::where('tenant_id', $asset->createdBy->tenant_id)->get();
202207

203208
foreach ($users as $u) {
204-
$u->notify(new Notification($a->vulnerability, "{$asset->asset} > {$a->title}"));
209+
$u->notify(new Notification("{$asset->asset} ({$port->ip}) - {$a->translated('title')}"));
205210
}
206211
}
207-
208-
// Cache translations
209-
$a->translated('title');
210-
$a->translated('vulnerability');
211-
$a->translated('remediation');
212-
213212
} catch (\Exception $exception) {
214213
Log::error($exception);
215214
Log::error($alert);

0 commit comments

Comments
 (0)