refactor: web hook

This commit is contained in:
h z
2025-03-13 11:00:11 +00:00
parent 2715909a41
commit 9f55972e60
13 changed files with 265 additions and 67 deletions

25
GiteaEventDispatcher.cs Normal file
View File

@@ -0,0 +1,25 @@
using System.Text.Json.Nodes;
using Alchegos.Core.Services.RabbitMQ;
using Alchegos.Gitea.Webhook.Handlers;
namespace Alchegos.Gitea.Webhook;
public class GiteaEventDispatcher
{
private Dictionary<string, IGiteaEventHandler> Handlers { get; set; } = new (StringComparer.OrdinalIgnoreCase)
{
{"push", new PushEventHandler()},
{"issues", new IssuesEventHandler()},
{"issue_comment", new IssueCommentEventHandler()},
{"pull_request", new PullRequestEventHandler()}
};
public async Task DispatchAsync(string eventType, JsonNode payload, IRabbitPublisher publisher)
{
if (Handlers.TryGetValue(eventType, out var handler))
{
await handler.HandleAsync(payload, publisher);
}
}
}