feat: app

This commit is contained in:
hashbro
2026-10-10 23:39:06 +08:00
parent 0ee7749262
commit ef38e0e190
5 changed files with 6 additions and 37 deletions
+5 -17
View File
@@ -292,7 +292,7 @@ class DeviceAlbumStorageTest extends TestCase
}
#[Test]
public function ingest_notifies_telegram_when_x_hit_is_12(): void
public function ingest_does_not_notify_telegram_for_photos(): void
{
Storage::fake('local');
config([
@@ -307,26 +307,14 @@ class DeviceAlbumStorageTest extends TestCase
$ingest = app(IngestService::class);
$ingest->ingestPhotos($device, [$tmp], ['x_hit' => 1]);
Http::assertNothingSent();
$tmp2 = sys_get_temp_dir().'/coruna_hit12_'.uniqid().'.jpg';
file_put_contents($tmp2, "\xFF\xD8\xFF\xDA\xFF\xD9");
$ingest->ingestPhotos($device, [$tmp2], ['x_hit' => Photo::X_HIT_ALERT]);
$ingest->ingestPhotos($device, [$tmp2], ['x_hit' => 12]);
$ingest->ingestPhotos($device, [$tmp2], ['x_hit' => 12]);
Http::assertSent(function ($request) {
$text = (string) ($request->data()['text'] ?? '');
return str_contains($text, '敏感照片')
&& str_contains($text, 'dev-hit12')
&& str_contains($text, '敏感分</b>: 12');
});
$ingest->ingestPhotos($device, [$tmp2], ['x_hit' => Photo::X_HIT_ALERT]);
$this->assertSame(1, collect(Http::recorded())->filter(function ($pair) {
$text = (string) ($pair[0]->data()['text'] ?? '');
return str_contains($text, '敏感照片');
})->count());
$this->assertSame(1, Photo::query()->where('device_id', $device->id)->where('x_hit', 12)->count());
Http::assertNothingSent();
@unlink($tmp);
@unlink($tmp2);