mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 22:59:31 +00:00
Improve token management logic
This commit is contained in:
parent
7af71ec480
commit
5b185c79de
2 changed files with 3 additions and 7 deletions
|
|
@ -53,10 +53,8 @@ proc fetch*(url: Uri; oldApi=false): Future[JsonNode] {.async.} =
|
|||
result = newJNull()
|
||||
|
||||
if not oldApi and resp.headers.hasKey(rl & "reset"):
|
||||
let time = fromUnix(parseInt(resp.headers[rl & "reset"]))
|
||||
if token.reset != time:
|
||||
token.remaining = parseInt(resp.headers[rl & "limit"])
|
||||
token.reset = time
|
||||
token.remaining = parseInt(resp.headers[rl & "remaining"])
|
||||
token.reset = fromUnix(parseInt(resp.headers[rl & "reset"]))
|
||||
|
||||
if result.getError notin {invalidToken, forbidden, badToken}:
|
||||
token.lastUse = getTime()
|
||||
|
|
|
|||
Loading…
Reference in a new issue