func dispatch(h hash.Hash, evt webhook.EventEnum, payload map[string]interface{}) error {
	logrus.Debugf("dispatching for %s (%s)", h, evt)

	// Nothing to dispatch, as we haven't enabled webhook dispatching
	if dispatcher == nil {
		return nil
	}

	repo := container.Instance.GetWebhookRepo()
	webhooks, err := repo.FetchByHash(h)
	if err != nil {
		return err
	}

	for _, wh := range webhooks {
		// Enabled webhooks only
		if !wh.Enabled {
			continue
		}

		// Make sure we match either the event or webhook acts on "all"
		if wh.Event != evt && wh.Event != webhook.EventAll {
			continue
		}

		// Add meta data to payload
		payload["meta"] = map[string]string{
			"id":      wh.ID,
			"account": wh.Account.String(),
			"event":   evt.String(), // We need to use the event, otherwise we might end up with event "all"
		}

		wh := wh
		_ = dispatcher.Dispatch(func() {
			logrus.Tracef("dispatching webhook %s", wh.ID)
			Work(wh, payload)
		})
	}

	return nil
}
// dispatch dispatches all active webhooks for the given account and event, with the given payload
dispatch dispatches all active webhooks for the given account and event, with the given payload
// dispatch dispatches all active webhooks for the given account and event with the given payload
func dispatch(h hash.Hash, evt webhook.EventEnum, payload map[string]interface{}) error {
	logrus.Debugf("dispatching for %s (%s)", h, evt)
	if dispatcher == nil {
		return nil
	}
	repo := container.Instance.GetWebhookRepo()
	webhooks, err := repo.FetchByHash(h)
	if err != nil {
		return err
	}
	for _, wh := range webhooks {
		if !wh.Enabled {
			continue
		}
		if wh.Event != evt && wh.Event != webhook.EventAll {
			continue
		}
		payload["meta"] = map[string]string{
			"id":      wh.ID,
			"account": wh.Account.String(),
			"event":   evt.String(), 
		}
		wh := wh
		_ = dispatcher.Dispatch(func() {
			logrus.Tracef("dispatching webhook %s", wh.ID)
			Work(wh, payload)
		})
	}
	return nil
}
func dispatch ( h hash . Hash , evt webhook . EventEnum , payload map [ string ] interface { } ) error { logrus . Debugf ( " " , h , evt ) if dispatcher == nil { return nil } repo := container . Instance . GetWebhookRepo ( ) webhooks , err := repo . FetchByHash ( h ) if err != nil { return err } for _ , wh := range webhooks { if ! wh . Enabled { continue } if wh . Event != evt && wh . Event != webhook . EventAll { continue } payload [ " " ] = map [ string ] string { " " : wh . ID , " " : wh . Account . String ( ) , " " : evt . String ( ) , } wh := wh _ = dispatcher . Dispatch ( func ( ) { logrus . Tracef ( " " , wh . ID ) Work ( wh , payload ) } ) } return nil }
dispatch dispatches all active webhooks for the given account and event, with the given payload
dispatch dispatches all active webhooks for the given account and event with the given payload
// Nothing to dispatch, as we haven't enabled webhook dispatching // Enabled webhooks only // Make sure we match either the event or webhook acts on "all" // Add meta data to payload // We need to use the event, otherwise we might end up with event "all"