Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions api/timeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
3 changes: 3 additions & 0 deletions askgod.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions internal/database/db_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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, ","),
Expand Down
10 changes: 10 additions & 0 deletions internal/rest/api_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net/http"
"os"
"slices"
"strconv"
"time"

Expand Down Expand Up @@ -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"})
Expand Down