strimertul/problem.go

44 lines
920 B
Go
Raw Permalink Normal View History

2024-02-29 20:18:59 +00:00
package main
2024-03-10 16:38:18 +00:00
import (
"log/slog"
2024-03-16 00:20:15 +00:00
"git.sr.ht/~ashkeel/strimertul/log"
2024-03-10 16:38:18 +00:00
"git.sr.ht/~ashkeel/strimertul/twitch"
)
2024-02-29 20:18:59 +00:00
type ProblemID string
const (
ProblemIDTwitchNoApp = "twitch:app_missing"
ProblemIDEventSubNoAuth = "twitch:eventsub_no_auth"
ProblemIDEventSubScope = "twitch:eventsub_scope"
)
type Problem struct {
ID ProblemID `json:"id"`
Details any `json:"details"`
}
func (a *App) GetProblems() (problems []Problem) {
problems = []Problem{}
if a.twitchManager != nil {
client := a.twitchManager.Client()
if client != nil {
// Check if the app needs to be authorized again
2024-03-10 16:38:18 +00:00
scopesMatch, err := twitch.CheckScopes(client.DB)
2024-02-29 20:18:59 +00:00
if err != nil {
2024-03-16 00:20:15 +00:00
slog.Warn("Could not check scopes for problems", log.Error(err))
2024-02-29 20:18:59 +00:00
} else {
if !scopesMatch {
problems = append(problems, Problem{
ID: ProblemIDEventSubScope,
Details: nil,
})
}
}
}
}
return
}