feat: app
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user