Files
Alchegos.Webhook/GiteaEventDispatcher.cs
2025-03-13 11:00:11 +00:00

25 lines
767 B
C#

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);
}
}
}