The new logbot, not committed from the wrong terminal window this time.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

40 lines
896 B

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
}