Debugging twitch

This commit is contained in:
Asaf Gartner 2022-05-30 19:08:09 +03:00
parent 4c296c9ddd
commit 8c47590b99
2 changed files with 6 additions and 4 deletions

View File

@ -134,6 +134,8 @@ func getStreamStatus(ctx context.Context, twitchIDs []string) ([]streamStatus, e
if err != nil {
return nil, oops.New(err, "failed to read response body while processing stream statuses")
}
log := logging.ExtractLogger(ctx)
log.Debug().Str("getStreamStatus response", string(body)).Msg("Got getStreamStatus response")
var streamResponse twitchResponse
err = json.Unmarshal(body, &streamResponse)

View File

@ -99,13 +99,13 @@ func MonitorTwitchSubscriptions(ctx context.Context, dbConn *pgxpool.Pool) jobs.
var timer *time.Timer
t := time.AfterFunc(3*time.Minute, func() {
expiredTimers <- timer
processEventSubNotification(ctx, dbConn, &notification)
processEventSubNotification(ctx, dbConn, &notification, true)
})
timer = t
timers = append(timers, t)
// NOTE(asaf): We also run this immediately. Since we get the category in the notification
// we could show the stream as online if it's the right category.
processEventSubNotification(ctx, dbConn, &notification)
processEventSubNotification(ctx, dbConn, &notification, false)
}
}
}
@ -417,7 +417,7 @@ func notifyDiscordOfLiveStream(ctx context.Context, dbConn db.ConnOrTx) error {
return nil
}
func processEventSubNotification(ctx context.Context, dbConn db.ConnOrTx, notification *twitchNotification) {
func processEventSubNotification(ctx context.Context, dbConn db.ConnOrTx, notification *twitchNotification, delayed bool) {
log := logging.ExtractLogger(ctx)
log.Debug().Interface("Notification", notification).Msg("Processing twitch notification")
if notification.Type == notificationTypeNone {
@ -444,7 +444,7 @@ func processEventSubNotification(ctx context.Context, dbConn db.ConnOrTx, notifi
}
for _, streamer := range allStreamers {
if streamer.TwitchLogin == result[0].TwitchLogin {
if result[0].Live == notification.Status.Live {
if delayed || (result[0].Live == notification.Status.Live) {
status = result[0]
} else {
status = notification.Status