1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-30 02:40:33 +00:00
strimertul/problem.go
2024-02-29 21:19:23 +01:00

38 lines
837 B
Go

package main
import "go.uber.org/zap"
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
scopesMatch, err := client.CheckScopes()
if err != nil {
logger.Warn("Could not check scopes for problems", zap.Error(err))
} else {
if !scopesMatch {
problems = append(problems, Problem{
ID: ProblemIDEventSubScope,
Details: nil,
})
}
}
}
}
return
}