<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class BrowseRSSPostJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $timeout = 20;

    protected $hours;

    /**
     * Create a new job instance.
     */
    public function __construct($hours)
    {
        $this->hours = $hours;
    }

    /**
     * Execute the job.
     */
    public function handle(): void
    {
        $rss_urls = config('platform.global.rss');

        foreach ($rss_urls as $rss_url) {
            BrowseSingleRSSJob::dispatch($rss_url, $this->hours)->onQueue('default')->onConnection('default');
        }
    }
}
