Skip to content

Commit

Permalink
fix: int list unmarshal
Browse files Browse the repository at this point in the history
  • Loading branch information
Bloeckchengrafik authored Oct 27, 2024
1 parent c746804 commit 2209fce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,23 @@ func DecodeResponse(lines []string, v interface{}) error {
if len(parts) == 2 {
v := Decode(parts[1])
if i, err := strconv.Atoi(v); err != nil {
// Only support comma seperated lists
// by keyname to avoid incorrect decoding.
if key == "client_servergroups" {
parts := strings.Split(v, ",")
serverGroups := make([]int, len(parts))
for i, s := range parts {
group, err := strconv.Atoi(s)
if err != nil {
fmt.Printf("decode server group: %w", err)
return fmt.Errorf("decode server group: %w", err)
}
serverGroups[i] = group
}
input[key] = serverGroups
} else {
input[key] = v
}
} else {
input[key] = i
}
Expand Down
2 changes: 1 addition & 1 deletion server_cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ type OnlineClientTimes struct {
type OnlineClientGroups struct {
ChannelGroupID *int `ms:"client_channel_group_id"`
ChannelGroupInheritedChannelID *int `ms:"client_channel_group_inherited_channel_id"`
ServerGroups *int `ms:"client_servergroups"`
ServerGroups *[]int `ms:"client_servergroups"`
}

// OnlineClientInfo represents all ClientList extensions when the ClientInfo parameter is passed.
Expand Down

0 comments on commit 2209fce

Please sign in to comment.