more breahing room with tokens

This commit is contained in:
Andre Medeiros 2022-05-25 19:49:14 -04:00
parent 4f34e3927b
commit 5ede5d6987
2 changed files with 5 additions and 1 deletions

View file

@ -128,6 +128,10 @@ func (rc *Client) NewAuthenticatedClient(redditId, refreshToken, accessToken str
panic("requires an access token")
}
if refreshToken == "" {
panic("requires a refresh token")
}
return &AuthenticatedClient{rc, redditId, refreshToken, accessToken}
}

View file

@ -178,7 +178,7 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) {
}(&account)
rac := nc.reddit.NewAuthenticatedClient(account.AccountID, account.RefreshToken, account.AccessToken)
if account.TokenExpiresAt.Before(now.Add(1 * time.Minute)) {
if account.TokenExpiresAt.Before(now.Add(5 * time.Minute)) {
nc.logger.Debug("refreshing reddit token",
zap.Int64("account#id", id),
zap.String("account#username", account.NormalizedUsername()),