From 1e92978c0da369d4ba7a6a0a3ea4e60e9303a235 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Mon, 20 Apr 2020 01:57:21 +1200 Subject: [PATCH] Fix error response caching --- src/lib/collectors.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/collectors.js b/src/lib/collectors.js index e054251..bfe92ca 100644 --- a/src/lib/collectors.js +++ b/src/lib/collectors.js @@ -86,15 +86,15 @@ async function fetchUser(username, context) { * @returns {Promise} */ function fetchUserFromHTML(username) { - return userRequestCache.getOrFetch("user/"+username, false, true, () => { - if (constants.caching.self_blocked_status.enabled) { - if (history.store.has("user")) { - const entry = history.store.get("user") - if (!entry.lastRequestSuccessful && Date.now() < entry.lastRequestAt + constants.caching.self_blocked_status.time) { - return Promise.reject(constants.symbols.RATE_LIMITED) - } + if (constants.caching.self_blocked_status.enabled) { + if (history.store.has("user")) { + const entry = history.store.get("user") + if (!entry.lastRequestSuccessful && Date.now() < entry.lastRequestAt + constants.caching.self_blocked_status.time) { + return Promise.reject(constants.symbols.RATE_LIMITED) } } + } + return userRequestCache.getOrFetch("user/"+username, false, true, () => { return switcher.request("user_html", `https://www.instagram.com/${username}/`, async res => { if (res.status === 301) throw constants.symbols.ENDPOINT_OVERRIDDEN if (res.status === 302) throw constants.symbols.INSTAGRAM_DEMANDS_LOGIN