2023-03-31 23:00:15 -07:00
|
|
|
using Hangfire;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
using Newsbot.Collector.Domain.Models.Config;
|
|
|
|
using Newsbot.Collector.Services.Jobs;
|
|
|
|
|
|
|
|
namespace Newsbot.Collector.Api.Controllers;
|
|
|
|
|
|
|
|
[ApiController]
|
2023-04-08 09:30:59 -07:00
|
|
|
[Route("api/rss")]
|
|
|
|
public class RssController
|
2023-03-31 23:00:15 -07:00
|
|
|
{
|
|
|
|
private readonly ConfigSectionConnectionStrings _connectionStrings;
|
2023-04-10 22:59:13 -07:00
|
|
|
private readonly ILogger<RssController> _logger;
|
2023-03-31 23:00:15 -07:00
|
|
|
private readonly ConfigSectionRssModel _rssConfig;
|
|
|
|
|
2023-04-10 22:59:13 -07:00
|
|
|
public RssController(ILogger<RssController> logger, IOptions<ConfigSectionConnectionStrings> connectionStrings,
|
2023-03-31 23:00:15 -07:00
|
|
|
IOptions<ConfigSectionRssModel> rss)
|
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
_connectionStrings = connectionStrings.Value;
|
|
|
|
_rssConfig = rss.Value;
|
|
|
|
}
|
|
|
|
|
2023-04-08 09:30:59 -07:00
|
|
|
[HttpPost("check")]
|
2023-03-31 23:00:15 -07:00
|
|
|
public void CheckReddit()
|
|
|
|
{
|
|
|
|
BackgroundJob.Enqueue<RssWatcherJob>(x => x.InitAndExecute(new RssWatcherJobOptions
|
|
|
|
{
|
2023-04-01 08:53:34 -07:00
|
|
|
ConnectionString = _connectionStrings.Database,
|
|
|
|
OpenTelemetry = _connectionStrings.OpenTelemetry,
|
|
|
|
IsEnabled = _rssConfig.IsEnabled
|
2023-03-31 23:00:15 -07:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|