38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using Hangfire;
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Options;
|
|
using Newsbot.Collector.Api.Domain;
|
|
using Newsbot.Collector.Domain.Models.Config;
|
|
using Newsbot.Collector.Services.Jobs;
|
|
|
|
namespace Newsbot.Collector.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/codeprojects")]
|
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
|
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")]
|
|
[Authorize(Roles = Authorization.AdministratorsRole)]
|
|
public void PullNow()
|
|
{
|
|
BackgroundJob.Enqueue<CodeProjectWatcherJob>(x => x.InitAndExecute(new CodeProjectWatcherJobOptions
|
|
{
|
|
ConnectionStrings = _connectionStrings,
|
|
FeaturePullReleases = true,
|
|
FeaturePullCommits = true
|
|
}));
|
|
}
|
|
} |