Skip to content

Commit 3f5a2a2

Browse files
committed
Notify users of document import progress and errors in IngestFileListener.
1 parent 87f81af commit 3f5a2a2

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

app/Listeners/IngestFileListener.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use App\Models\Collection;
1111
use App\Models\File;
1212
use App\Models\Vector;
13+
use App\Notifications\Notification;
1314
use App\Rules\IsValidCollectionName;
1415
use Illuminate\Support\Facades\Log;
1516
use Illuminate\Support\Facades\Storage;
@@ -47,6 +48,8 @@ protected function handle2($event)
4748
throw new \Exception("Invalid file id : {$event->fileId}");
4849
}
4950

51+
$event->user->notify(new Notification(__("Import of document :document started.", ['document' => $file->name])));
52+
5053
// webm to mp3
5154
if ($file->mime_type === 'audio/webm') {
5255

@@ -396,8 +399,16 @@ protected function handle2($event)
396399
$file->is_embedded = true;
397400
$file->save();
398401
}
402+
403+
$event->user->notify(new Notification(__("Import of document :document finished successfully.", ['document' => $file->name])));
404+
399405
} catch (\Exception $exception) {
406+
400407
Log::error($exception->getMessage());
408+
409+
if (isset($file)) {
410+
$event->user->notify(new Notification(__("Import of document :document failed: :error", ['document' => $file->name, 'error' => $exception->getMessage()])));
411+
}
401412
}
402413
}
403414

lang/fr.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"Import of table :table started.": "L'importation de la table :table a commencé.",
55
"Import of table :table finished successfully.": "L'importation de la table :table s'est terminée avec succès.",
66
"Import of table :table failed: :error": "L'importation de la table :table a échoué : :error",
7+
"Import of document :document started.": "L'importation du document :document a commencé.",
8+
"Import of document :document finished successfully.": "L'importation du document :document s'est terminée avec succès.",
9+
"Import of document :document failed: :error": "L'importation du document :document a échoué : :error",
710
"2.2 What are the credentials for your AWS S3 Bucket?": "2.2 Quels sont les identifiants de votre bucket S3 AWS ?",
811
"2.2 What are the credentials for your Azure Blob Storage?": "2.2 Quels sont les identifiants de votre Blob Storage Azure ?",
912
"3. Which table would you like to import?": "3. Quelle table souhaitez-vous importer ?",

0 commit comments

Comments
 (0)