diff --git a/api/config.go b/api/config.go index a10642f..9bc0ea6 100644 --- a/api/config.go +++ b/api/config.go @@ -44,9 +44,10 @@ type ConfigDatabase struct { // ConfigScoring represents the Daemon part of the Askgod configuration. type ConfigScoring struct { - EventName string `json:"event_name" yaml:"event_name"` - HideOthers bool `json:"hide_others" yaml:"hide_others"` - ReadOnly bool `json:"read_only" yaml:"read_only"` + EventName string `json:"event_name" yaml:"event_name"` + HideOthers bool `json:"hide_others" yaml:"hide_others"` + ReadOnly bool `json:"read_only" yaml:"read_only"` + PublicTags []string `json:"public_tags" yaml:"public_tags"` } // ConfigTeams represents the Daemon part of the Askgod configuration. diff --git a/api/timeline.go b/api/timeline.go index 3da5b78..ac8d9b2 100644 --- a/api/timeline.go +++ b/api/timeline.go @@ -15,7 +15,8 @@ type TimelineEntry struct { // TimelineEntryScore represents a score entry for a team. type TimelineEntryScore struct { - SubmitTime time.Time `json:"submit_time" yaml:"submit_time"` - Value int64 `json:"value" yaml:"value"` - Total int64 `json:"total" yaml:"total"` + SubmitTime time.Time `json:"submit_time" yaml:"submit_time"` + Value int64 `json:"value" yaml:"value"` + Total int64 `json:"total" yaml:"total"` + Tags map[string]string `json:"tags" yaml:"tags"` } diff --git a/askgod.yaml.example b/askgod.yaml.example index 7652923..ea2ccce 100644 --- a/askgod.yaml.example +++ b/askgod.yaml.example @@ -61,6 +61,9 @@ scoring: # Disable the submission of new flags read_only: false + # List of public tags to be sent to the scoreboard/timeline + public_tags: + # Team configuration teams: # The team can select its initial details (but not update afterwards) diff --git a/internal/database/db_config.go b/internal/database/db_config.go index 81290d6..c510191 100644 --- a/internal/database/db_config.go +++ b/internal/database/db_config.go @@ -46,6 +46,7 @@ func (db *DB) GetConfig() (*api.ConfigPut, error) { EventName: dbConfig["scoring.event_name"], HideOthers: dbConfig["scoring.hide_others"] == "true", ReadOnly: dbConfig["scoring.read_only"] == "true", + PublicTags: strings.Split(dbConfig["scoring.public_tags"], ","), }, Teams: api.ConfigTeams{ SelfRegister: dbConfig["teams.self_register"] == "true", @@ -92,6 +93,7 @@ func (db *DB) UpdateConfig(config api.ConfigPut) error { "scoring.event_name": config.Scoring.EventName, "scoring.hide_others": strconv.FormatBool(config.Scoring.HideOthers), "scoring.read_only": strconv.FormatBool(config.Scoring.ReadOnly), + "scoring.public_tags": strings.Join(config.Scoring.PublicTags, ","), "teams.self_register": strconv.FormatBool(config.Teams.SelfRegister), "teams.self_update": strconv.FormatBool(config.Teams.SelfUpdate), "teams.hidden": strings.Join(config.Teams.Hidden, ","), diff --git a/internal/rest/api_flags.go b/internal/rest/api_flags.go index 4882e91..621b971 100644 --- a/internal/rest/api_flags.go +++ b/internal/rest/api_flags.go @@ -7,6 +7,7 @@ import ( "fmt" "net/http" "os" + "slices" "strconv" "time" @@ -260,10 +261,19 @@ func (r *rest) submitTeamFlag(writer http.ResponseWriter, request *http.Request, return } + tags := make(map[string]string) + + for key, value := range adminFlag.Tags { + if slices.Contains(r.config.Scoring.PublicTags, key) { + tags[key] = value + } + } + score := api.TimelineEntryScore{ SubmitTime: time.Now(), Value: result.Value, Total: total, + Tags: tags, } _ = r.eventSend("timeline", api.EventTimeline{TeamID: team.ID, Team: &team.TeamPut, Score: &score, Type: "score-updated"})