package channels import ( "context" "encoding/json" "git.aiterp.net/rpdata/logbot3/internal/api" "git.aiterp.net/rpdata/logbot3/internal/models" ) type setLoggedResult struct { EditChannel models.Channel `json:"editChannel"` } var setLoggedGQL = ` mutation SetChanelLogged($name: String!, $logged: Boolean!) { editChannel(input: {name: $name, logged: $logged}) { name logged eventName locationName } } ` // SetLogged sets a channel as logged func SetLogged(ctx context.Context, name string, logged bool) (models.Channel, error) { data, err := api.Global().Query(ctx, setLoggedGQL, map[string]interface{}{"name": name, "logged": logged}, []string{"channel.edit"}) if err != nil { return models.Channel{}, err } result := setLoggedResult{} err = json.Unmarshal(data, &result) if err != nil { return models.Channel{}, err } return result.EditChannel, nil }