From cb5b39a4503e84c6f02646516d86910a33ab87ae Mon Sep 17 00:00:00 2001 From: Andrei Mihu Date: Mon, 19 Oct 2020 15:44:46 +0100 Subject: [PATCH] Add user information to external event contexts. --- CHANGELOG.md | 3 +++ server/api_event.go | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bdb04913..82f2b3948 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project are documented below. The format is based on [keep a changelog](http://keepachangelog.com) and this project uses [semantic versioning](http://semver.org). ## [Unreleased] +### Added +- Event contexts now contain user information for external events. + ### Fixed - Add missing 'rank' field from the Lua runtime `tournament_records_haystack` function results. diff --git a/server/api_event.go b/server/api_event.go index 12d4d1e59..981443371 100644 --- a/server/api_event.go +++ b/server/api_event.go @@ -53,7 +53,9 @@ func (s *ApiServer) Event(ctx context.Context, in *api.Event) (*empty.Empty, err // Add event to processing queue if there are any event handlers registered. if fn := s.runtime.Event(); fn != nil { - fn(ctx, in) + clientIP, clientPort := extractClientAddressFromContext(s.logger, ctx) + evtCtx := NewRuntimeGoContext(ctx, s.config.GetName(), s.config.GetRuntime().Environment, RuntimeExecutionModeEvent, nil, ctx.Value(ctxExpiryKey{}).(int64), ctx.Value(ctxUserIDKey{}).(uuid.UUID).String(), ctx.Value(ctxUsernameKey{}).(string), ctx.Value(ctxVarsKey{}).(map[string]string), "", clientIP, clientPort) + fn(evtCtx, in) } // After hook. -- GitLab