<?php
namespace EasyChat\Library\Queue\Jobs;

use EasyChat\Library\Voice\VoiceMediaService;

class VoiceTranscriptionJob {
    private $registry;

    public function __construct($registry) {
        $this->registry = $registry;
    }

    public function handle(array $payload): void {
        $attachment_id = (int)($payload['attachment_id'] ?? 0);
        if ($attachment_id <= 0) {
            throw new \InvalidArgumentException('voice_attachment_id_required');
        }
        (new VoiceMediaService($this->registry))->transcribe($attachment_id);
    }
}
