1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2024-11-22 08:07:30 +00:00

Fix error response caching

This commit is contained in:
Cadence Ember 2020-04-20 01:57:21 +12:00
parent 456bafa199
commit 1e92978c0d
No known key found for this signature in database
GPG Key ID: 128B99B1B74A6412

View File

@ -86,15 +86,15 @@ async function fetchUser(username, context) {
* @returns {Promise<import("./structures/User")>}
*/
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