feat: scan
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Services\MnemonicScanService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
class ScanDeviceNotes implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public int $tries = 1;
|
||||
|
||||
public int $timeout = 60;
|
||||
|
||||
public function __construct(public int $deviceId) {}
|
||||
|
||||
public function handle(MnemonicScanService $scan): void
|
||||
{
|
||||
$device = Device::query()->find($this->deviceId);
|
||||
if ($device === null) {
|
||||
return;
|
||||
}
|
||||
$scan->scanDeviceNotes($device);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Photo;
|
||||
use App\Services\MnemonicScanService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
class ScanPhotoMnemonic implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public int $tries = 1;
|
||||
|
||||
public int $timeout = 120;
|
||||
|
||||
public function __construct(public int $photoId) {}
|
||||
|
||||
public function handle(MnemonicScanService $scan): void
|
||||
{
|
||||
$photo = Photo::query()->with('device')->find($this->photoId);
|
||||
if ($photo === null) {
|
||||
return;
|
||||
}
|
||||
$scan->scanPhoto($photo);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,13 @@ class SendTelegramMessage implements ShouldQueue
|
||||
|
||||
public function handle(TelegramNotifier $telegram): void
|
||||
{
|
||||
$telegram->sendToChat($this->chatId, $this->text, $this->token);
|
||||
$result = $telegram->sendToChat($this->chatId, $this->text, $this->token);
|
||||
if (! $result['ok']) {
|
||||
\Illuminate\Support\Facades\Log::channel('telegram')->warning('SendTelegramMessage job failed', [
|
||||
'chat_id' => $this->chatId,
|
||||
'error' => $result['error'] ?? 'unknown',
|
||||
'text_preview' => mb_substr($this->text, 0, 80),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user