2023-04-10 22:59:13 -07:00
|
|
|
using Hangfire;
|
2023-07-06 22:26:19 -07:00
|
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2023-04-10 22:59:13 -07:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.Extensions.Options;
|
2023-07-14 22:25:44 -07:00
|
|
|
using Newsbot.Collector.Api.Domain;
|
2023-04-10 22:59:13 -07:00
|
|
|
using Newsbot.Collector.Domain.Models.Config;
|
|
|
|
using Newsbot.Collector.Services.Jobs;
|
|
|
|
|
|
|
|
namespace Newsbot.Collector.Api.Controllers;
|
|
|
|
|
|
|
|
[ApiController]
|
|
|
|
[Route("api/codeprojects")]
|
2023-07-06 22:26:19 -07:00
|
|
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
2023-04-10 22:59:13 -07:00
|
|
|
public class CodeProjectController
|
|
|
|
{
|
|
|
|
private readonly ConfigSectionConnectionStrings _connectionStrings;
|
|
|
|
private readonly ILogger<CodeProjectController> _logger;
|
|
|
|
|
|
|
|
public CodeProjectController(ILogger<CodeProjectController> logger,
|
|
|
|
IOptions<ConfigSectionConnectionStrings> settings)
|
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
_connectionStrings = settings.Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
[HttpPost("check")]
|
2023-07-14 22:25:44 -07:00
|
|
|
[Authorize(Roles = AuthorizationRoles.Administrators)]
|
2023-04-10 22:59:13 -07:00
|
|
|
public void PullNow()
|
|
|
|
{
|
|
|
|
BackgroundJob.Enqueue<CodeProjectWatcherJob>(x => x.InitAndExecute(new CodeProjectWatcherJobOptions
|
|
|
|
{
|
|
|
|
ConnectionStrings = _connectionStrings,
|
|
|
|
FeaturePullReleases = true,
|
|
|
|
FeaturePullCommits = true
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|