[core] Fix: Allow start when no tokens are available
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
3213f4ac37
commit
e8d39c19a4
2 changed files with 9 additions and 1 deletions
|
@ -38,6 +38,8 @@ type (
|
||||||
Service struct{ db database.Connector }
|
Service struct{ db database.Connector }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ErrChannelNotAuthorized = errors.New("channel is not authorized")
|
||||||
|
|
||||||
func New(db database.Connector) (*Service, error) {
|
func New(db database.Connector) (*Service, error) {
|
||||||
return &Service{db}, errors.Wrap(
|
return &Service{db}, errors.Wrap(
|
||||||
db.DB().AutoMigrate(&extendedPermission{}),
|
db.DB().AutoMigrate(&extendedPermission{}),
|
||||||
|
@ -144,6 +146,9 @@ func (s Service) GetTwitchClientForChannel(channel string, cfg ClientConfig) (*t
|
||||||
)
|
)
|
||||||
|
|
||||||
if err = s.db.DB().First(&perm, "channel = ?", strings.TrimLeft(channel, "#")).Error; err != nil {
|
if err = s.db.DB().First(&perm, "channel = ?", strings.TrimLeft(channel, "#")).Error; err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return nil, ErrChannelNotAuthorized
|
||||||
|
}
|
||||||
return nil, errors.Wrap(err, "getting twitch credential from database")
|
return nil, errors.Wrap(err, "getting twitch credential from database")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
main.go
5
main.go
|
@ -272,7 +272,10 @@ func main() {
|
||||||
frontendReloadHooks.Ping()
|
frontendReloadHooks.Ping()
|
||||||
},
|
},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.WithError(err).Fatal("Unable to initialize Twitch client")
|
if !errors.Is(err, access.ErrChannelNotAuthorized) {
|
||||||
|
log.WithError(err).Fatal("Unable to initialize Twitch client")
|
||||||
|
}
|
||||||
|
twitchClient = twitch.New(cfg.TwitchClient, cfg.TwitchClientSecret, cfg.TwitchToken, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
twitchWatch := newTwitchWatcher()
|
twitchWatch := newTwitchWatcher()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue