mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
initial impl of CloseUrlValidationIssue
This commit is contained in:
parent
b51039d6f1
commit
db25be46ec
1 changed files with 22 additions and 2 deletions
|
|
@ -1,7 +1,9 @@
|
|||
using System.Threading;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Agent.Infrastructure.Clients;
|
||||
using MediatR;
|
||||
using Octokit;
|
||||
|
||||
namespace FilterLists.Agent.Features.Urls
|
||||
{
|
||||
|
|
@ -14,7 +16,6 @@ public class Command : IRequest
|
|||
public class Handler : AsyncRequestHandler<Command>
|
||||
{
|
||||
private const string AgentBotLabel = "agent bot";
|
||||
private const string IssueTitle = "Url Validation Errors";
|
||||
private readonly IAgentGitHubClient _gitHubClient;
|
||||
|
||||
public Handler(IAgentGitHubClient agentGitHubClient)
|
||||
|
|
@ -24,6 +25,25 @@ public Handler(IAgentGitHubClient agentGitHubClient)
|
|||
|
||||
protected override async Task Handle(Command request, CancellationToken cancellationToken)
|
||||
{
|
||||
var issue = await GetOpenIssueOrNull();
|
||||
if (issue is null)
|
||||
return;
|
||||
var updateIssue = issue.ToUpdate();
|
||||
updateIssue.State = ItemState.Closed;
|
||||
updateIssue.Body = issue.Body +
|
||||
"<h1>Update:</h1>This issue is being closed since all URLs seem to now be valid.";
|
||||
await _gitHubClient.UpdateIssue(issue.Number, updateIssue);
|
||||
}
|
||||
|
||||
private async Task<Issue> GetOpenIssueOrNull()
|
||||
{
|
||||
var issueRequest = new RepositoryIssueRequest
|
||||
{
|
||||
Filter = IssueFilter.All,
|
||||
State = ItemStateFilter.Open,
|
||||
Labels = {AgentBotLabel}
|
||||
};
|
||||
return (await _gitHubClient.GetAllIssues(issueRequest)).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue