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

use EasyChat\Library\Voice\VoiceMediaService;

class VoiceMediaFetchJob {
    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))->fetch($attachment_id);
    }
}
