Newsbot.Collector/Newsbot.Collector.Api/Controllers/RssController.cs
James Tombleson bacc04ad7d
Features/enabling youtube (#24)
* Adding a youtube controller to trigger the job

* Renamed jobs controller to rss

* cleaned up background jobs and added youtube to the startup.

* Handled merge issues and validated things are still working.
2023-04-08 09:30:59 -07:00

37 lines
1.2 KiB
C#

using Hangfire;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Newsbot.Collector.Database.Repositories;
using Newsbot.Collector.Domain.Interfaces;
using Newsbot.Collector.Domain.Models.Config;
using Newsbot.Collector.Services.Jobs;
namespace Newsbot.Collector.Api.Controllers;
[ApiController]
[Route("api/rss")]
public class RssController
{
private readonly ConfigSectionConnectionStrings _connectionStrings;
private readonly ConfigSectionRssModel _rssConfig;
private readonly ILogger<SourcesController> _logger;
public RssController(ILogger<SourcesController> logger, IOptions<ConfigSectionConnectionStrings> connectionStrings,
IOptions<ConfigSectionRssModel> rss)
{
_logger = logger;
_connectionStrings = connectionStrings.Value;
_rssConfig = rss.Value;
}
[HttpPost("check")]
public void CheckReddit()
{
BackgroundJob.Enqueue<RssWatcherJob>(x => x.InitAndExecute(new RssWatcherJobOptions
{
ConnectionString = _connectionStrings.Database,
OpenTelemetry = _connectionStrings.OpenTelemetry,
IsEnabled = _rssConfig.IsEnabled
}));
}
}