James Tombleson
bacc04ad7d
* 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.
35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using Hangfire;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Options;
|
|
using Newsbot.Collector.Domain.Models.Config;
|
|
using Newsbot.Collector.Services.Jobs;
|
|
using ILogger = Grpc.Core.Logging.ILogger;
|
|
|
|
namespace Newsbot.Collector.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/youtube")]
|
|
public class YoutubeController
|
|
{
|
|
private readonly ILogger<YoutubeController> _logger;
|
|
private readonly ConfigSectionConnectionStrings _connectionStrings;
|
|
private readonly ConfigSectionYoutubeModel _config;
|
|
|
|
public YoutubeController(ILogger<YoutubeController> logger, IOptions<ConfigSectionYoutubeModel> config, IOptions<ConfigSectionConnectionStrings> connectionStrings)
|
|
{
|
|
_logger = logger;
|
|
_connectionStrings = connectionStrings.Value;
|
|
_config = config.Value;
|
|
}
|
|
|
|
[HttpPost("check")]
|
|
public void CheckYoutube()
|
|
{
|
|
BackgroundJob.Enqueue<YoutubeWatcherJob>(x => x.InitAndExecute(new YoutubeWatcherJobOptions
|
|
{
|
|
DatabaseConnectionString = _connectionStrings.Database,
|
|
OpenTelemetryConnectionString = _connectionStrings.OpenTelemetry,
|
|
IsEnabled = _config.IsEnabled
|
|
}));
|
|
}
|
|
} |