James Tombleson
09fe274752
* New single const file for all config info * seed was updated to reflect route params * Adjusting config loads to make it easier to follow * test updates for config loading
48 lines
1.5 KiB
C#
48 lines
1.5 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/jobs")]
|
|
public class JobsController
|
|
{
|
|
private readonly ConfigSectionConnectionStrings _connectionStrings;
|
|
private readonly ConfigSectionRssModel _rssConfig;
|
|
private readonly ILogger<SourcesController> _logger;
|
|
private readonly ISourcesRepository _sources;
|
|
|
|
public JobsController(ILogger<SourcesController> logger, IOptions<ConfigSectionConnectionStrings> connectionStrings,
|
|
IOptions<ConfigSectionRssModel> rss)
|
|
{
|
|
_logger = logger;
|
|
_connectionStrings = connectionStrings.Value;
|
|
_rssConfig = rss.Value;
|
|
_sources = new SourcesTable(connectionStrings.Value.Database ?? "");
|
|
}
|
|
|
|
[HttpPost("check/rss")]
|
|
public void CheckReddit()
|
|
{
|
|
BackgroundJob.Enqueue<RssWatcherJob>(x => x.InitAndExecute(new RssWatcherJobOptions
|
|
{
|
|
ConnectionString = _connectionStrings.Database,
|
|
OpenTelemetry = _connectionStrings.OpenTelemetry,
|
|
IsEnabled = _rssConfig.IsEnabled
|
|
}));
|
|
}
|
|
|
|
[HttpPost("check/youtube")]
|
|
public void CheckYoutube()
|
|
{
|
|
BackgroundJob.Enqueue<YoutubeWatcherJob>(x => x.InitAndExecute(new YoutubeWatcherJobOptions
|
|
{
|
|
ConnectionStrings = _connectionStrings
|
|
}));
|
|
}
|
|
} |