mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-22 03:37:43 +00:00
more breahing room with tokens
This commit is contained in:
parent
4f34e3927b
commit
5ede5d6987
2 changed files with 5 additions and 1 deletions
|
@ -128,6 +128,10 @@ func (rc *Client) NewAuthenticatedClient(redditId, refreshToken, accessToken str
|
||||||
panic("requires an access token")
|
panic("requires an access token")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if refreshToken == "" {
|
||||||
|
panic("requires a refresh token")
|
||||||
|
}
|
||||||
|
|
||||||
return &AuthenticatedClient{rc, redditId, refreshToken, accessToken}
|
return &AuthenticatedClient{rc, redditId, refreshToken, accessToken}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) {
|
||||||
}(&account)
|
}(&account)
|
||||||
|
|
||||||
rac := nc.reddit.NewAuthenticatedClient(account.AccountID, account.RefreshToken, account.AccessToken)
|
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",
|
nc.logger.Debug("refreshing reddit token",
|
||||||
zap.Int64("account#id", id),
|
zap.Int64("account#id", id),
|
||||||
zap.String("account#username", account.NormalizedUsername()),
|
zap.String("account#username", account.NormalizedUsername()),
|
||||||
|
|
Loading…
Reference in a new issue