Files
Alchegos.Webhook/GiteaEventDispatcher.cs
2025-05-01 23:01:29 +01:00

26 lines
807 B
C#

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