feat: scan

This commit is contained in:
hashbro
2026-09-13 02:12:06 +08:00
parent d7bd4d1b03
commit 1746e7b485
13 changed files with 266 additions and 40 deletions
+16 -1
View File
@@ -97,7 +97,10 @@ class MnemonicScanService
return;
}
$text = trim((string) ($item['title'] ?? '')."\n".(string) ($item['body'] ?? ''));
$text = $this->noteScanText(
trim((string) ($item['title'] ?? '')),
trim((string) ($item['body'] ?? '')),
);
$this->applyTextHit($device, MnemonicFinding::SOURCE_NOTE, $text, null, $note, $key);
$row->content_hash = $hash;
$row->scan_status = $this->noteStatus($note, $key);
@@ -377,4 +380,16 @@ class MnemonicScanService
default => MnemonicScanStatus::EMPTY,
};
}
private function noteScanText(string $title, string $body): string
{
if ($title === '') {
return $body;
}
if ($body === '' || $title === $body || str_starts_with($body, $title)) {
return $body !== '' ? $body : $title;
}
return $title."\n".$body;
}
}