/// <inheritdoc />
        public void HandleWebhookPayload(ActivityPayload payload, Guid deliveryId)
        {
            if (_registeredHandlers.TryGetValue(payload.GetType(), out var handlers))
            {
                // Figure out the execution context for this event
                var tenantId = _tenantMapper.GetTenantFor(payload.Installation);
                _executionContextManager.CurrentFor(tenantId, deliveryId);

                // Schedule the event for processing
                var scheduler = _schedulerFactory();
                foreach (var handler in handlers)
                {
                    scheduler.QueueWebhookEventForHandling(handler.Type, handler.Method, payload);
                }
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public void HandleWebhookPayload(ActivityPayload payload, Guid deliveryId)
        {
            IEnumerable <HandlerMethod> handlerMethods = _handlerRegistry.GetHandlersFor(payload.GetType());

            if (handlerMethods.Any())
            {
                // Figure out the execution context for this event
                var tenantId = _tenantMapper.GetTenantFor(payload.Installation.Id);

                if (tenantId == TenantId.Unknown)
                {
                    _logger.Warning($"GitHub installation '{payload.Installation.Id}' is not mapped to a tenant. The webhook will be ignored.");
                    return;
                }

                _executionContextManager.CurrentFor(tenantId, deliveryId);

                // Schedule the event for processing
                var scheduler = _schedulerFactory();
                foreach (var handler in handlerMethods)
                {
                    scheduler.QueueWebhookEventForHandling(new Webhook(handler, payload));
                }
            }
        }