Skip to content

Improve /run/update/ detection by replacing string matching with JSON parsingΒ #140

Description

@pratham15541

Reference: https://github.com/omegaup/quark/blob/main/cmd/omegaup-broadcaster/main.go#L293-L296

πŸ“ Issue Description

Currently, the detection of /run/update/ messages relies on string matching:

strings.Contains(message.Message, "\"message\":\"/run/update/\"")

Suggested Improvement

Parse the JSON payload and check the message field explicitly:

type payload struct {
    Message string `json:"message"`
}

var p payload
if err := json.Unmarshal([]byte(message.Message), &p); err == nil {
    if len(message.Contest) > 0 && strings.HasPrefix(p.Message, "/run/update/") {
        contestChan <- message.Contest
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions