fix: test
This commit is contained in:
@@ -64,13 +64,17 @@ class WalletKeystore extends Model
|
||||
return $keep;
|
||||
}
|
||||
|
||||
return self::query()->create([
|
||||
$payload = [
|
||||
'device_id' => $device->id,
|
||||
'source' => $source,
|
||||
'decrypted' => 0,
|
||||
'raw_json' => $rawJson,
|
||||
'content_hash' => $hash,
|
||||
]);
|
||||
];
|
||||
if (\Illuminate\Support\Facades\Schema::hasColumn('wallet_keystores', 'content_hash')) {
|
||||
$payload['content_hash'] = $hash;
|
||||
}
|
||||
|
||||
return self::query()->create($payload);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,12 +129,44 @@ class WalletKeystore extends Model
|
||||
* }>
|
||||
*/
|
||||
public function listedItems(): array
|
||||
{
|
||||
try {
|
||||
return $this->collectListedItems();
|
||||
} catch (\Throwable) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{
|
||||
* account: string,
|
||||
* service: string,
|
||||
* access_group: string,
|
||||
* protection_class: string,
|
||||
* path: string,
|
||||
* data_len: int,
|
||||
* data_preview: string,
|
||||
* data_sha: string
|
||||
* }>
|
||||
*/
|
||||
private function collectListedItems(): array
|
||||
{
|
||||
$json = is_array($this->raw_json) ? $this->raw_json : [];
|
||||
$out = [];
|
||||
$wallets = $json['wallets'] ?? null;
|
||||
if (is_array($wallets)) {
|
||||
foreach ($wallets as $bucket) {
|
||||
foreach ($wallets as $key => $bucket) {
|
||||
if (is_string($bucket) && $bucket !== '') {
|
||||
$out[] = $this->normalizeItem([
|
||||
'account' => is_string($key) ? $key : 'wallet',
|
||||
'data' => $bucket,
|
||||
]);
|
||||
|
||||
continue;
|
||||
}
|
||||
if (! is_array($bucket)) {
|
||||
continue;
|
||||
}
|
||||
$items = is_array($bucket['items'] ?? null) ? $bucket['items'] : [];
|
||||
foreach ($items as $item) {
|
||||
if (is_array($item)) {
|
||||
|
||||
Reference in New Issue
Block a user