Skip to content

Commit 4a2a87f

Browse files
authored
Merge pull request #8 from zer0x64/custom-fireworks2
Custom fireworks
2 parents 218a815 + 5222c78 commit 4a2a87f

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

api/config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ type ConfigDatabase struct {
4444

4545
// ConfigScoring represents the Daemon part of the Askgod configuration.
4646
type ConfigScoring struct {
47-
EventName string `json:"event_name" yaml:"event_name"`
48-
HideOthers bool `json:"hide_others" yaml:"hide_others"`
49-
ReadOnly bool `json:"read_only" yaml:"read_only"`
47+
EventName string `json:"event_name" yaml:"event_name"`
48+
HideOthers bool `json:"hide_others" yaml:"hide_others"`
49+
ReadOnly bool `json:"read_only" yaml:"read_only"`
50+
PublicTags []string `json:"public_tags" yaml:"public_tags"`
5051
}
5152

5253
// ConfigTeams represents the Daemon part of the Askgod configuration.

api/timeline.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ type TimelineEntry struct {
1515

1616
// TimelineEntryScore represents a score entry for a team.
1717
type TimelineEntryScore struct {
18-
SubmitTime time.Time `json:"submit_time" yaml:"submit_time"`
19-
Value int64 `json:"value" yaml:"value"`
20-
Total int64 `json:"total" yaml:"total"`
18+
SubmitTime time.Time `json:"submit_time" yaml:"submit_time"`
19+
Value int64 `json:"value" yaml:"value"`
20+
Total int64 `json:"total" yaml:"total"`
21+
Tags map[string]string `json:"tags" yaml:"tags"`
2122
}

askgod.yaml.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ scoring:
6161
# Disable the submission of new flags
6262
read_only: false
6363

64+
# List of public tags to be sent to the scoreboard/timeline
65+
public_tags:
66+
6467
# Team configuration
6568
teams:
6669
# The team can select its initial details (but not update afterwards)

internal/database/db_config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func (db *DB) GetConfig() (*api.ConfigPut, error) {
4646
EventName: dbConfig["scoring.event_name"],
4747
HideOthers: dbConfig["scoring.hide_others"] == "true",
4848
ReadOnly: dbConfig["scoring.read_only"] == "true",
49+
PublicTags: strings.Split(dbConfig["scoring.public_tags"], ","),
4950
},
5051
Teams: api.ConfigTeams{
5152
SelfRegister: dbConfig["teams.self_register"] == "true",
@@ -92,6 +93,7 @@ func (db *DB) UpdateConfig(config api.ConfigPut) error {
9293
"scoring.event_name": config.Scoring.EventName,
9394
"scoring.hide_others": strconv.FormatBool(config.Scoring.HideOthers),
9495
"scoring.read_only": strconv.FormatBool(config.Scoring.ReadOnly),
96+
"scoring.public_tags": strings.Join(config.Scoring.PublicTags, ","),
9597
"teams.self_register": strconv.FormatBool(config.Teams.SelfRegister),
9698
"teams.self_update": strconv.FormatBool(config.Teams.SelfUpdate),
9799
"teams.hidden": strings.Join(config.Teams.Hidden, ","),

internal/rest/api_flags.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"net/http"
99
"os"
10+
"slices"
1011
"strconv"
1112
"time"
1213

@@ -260,10 +261,19 @@ func (r *rest) submitTeamFlag(writer http.ResponseWriter, request *http.Request,
260261
return
261262
}
262263

264+
tags := make(map[string]string)
265+
266+
for key, value := range adminFlag.Tags {
267+
if slices.Contains(r.config.Scoring.PublicTags, key) {
268+
tags[key] = value
269+
}
270+
}
271+
263272
score := api.TimelineEntryScore{
264273
SubmitTime: time.Now(),
265274
Value: result.Value,
266275
Total: total,
276+
Tags: tags,
267277
}
268278

269279
_ = r.eventSend("timeline", api.EventTimeline{TeamID: team.ID, Team: &team.TeamPut, Score: &score, Type: "score-updated"})

0 commit comments

Comments
 (0)