using System.Text.Json.Nodes; using Alchegos.Core.Services.RabbitMQ; using Alchegos.Webhook.Handlers; using Alchegos.Webhook.Handlers.GiteaEventHandlers; namespace Alchegos.Webhook; public class GiteaEventDispatcher { private Dictionary 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); } } }