mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2024-11-22 16:17:29 +00:00
Add ENDPOINT_OVERRIDEN error symbol
Show proper 404 page for /u/privacy, /u/accounts, etc
This commit is contained in:
parent
f8f670c4a9
commit
3b1c6a2849
@ -41,6 +41,7 @@ async function fetchUser(username, isRSS) {
|
||||
function fetchUserFromHTML(username) {
|
||||
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
|
||||
if (res.status === 429) throw constants.symbols.RATE_LIMITED
|
||||
return res
|
||||
|
@ -62,7 +62,8 @@ let constants = {
|
||||
NOT_FOUND: Symbol("NOT_FOUND"),
|
||||
NO_SHARED_DATA: Symbol("NO_SHARED_DATA"),
|
||||
INSTAGRAM_DEMANDS_LOGIN: Symbol("INSTAGRAM_DEMANDS_LOGIN"),
|
||||
RATE_LIMITED: Symbol("RATE_LIMITED")
|
||||
RATE_LIMITED: Symbol("RATE_LIMITED"),
|
||||
ENDPOINT_OVERRIDDEN: Symbol("ENDPOINT_OVERRIDDEN")
|
||||
},
|
||||
|
||||
database_version: 1
|
||||
|
@ -15,7 +15,7 @@ module.exports = [
|
||||
content: xml
|
||||
}
|
||||
}).catch(error => {
|
||||
if (error === constants.symbols.NOT_FOUND) {
|
||||
if (error === constants.symbols.NOT_FOUND || error === constants.symbols.ENDPOINT_OVERRIDDEN) {
|
||||
return render(404, "pug/friendlyerror.pug", {
|
||||
statusCode: 404,
|
||||
title: "Not found",
|
||||
|
@ -60,7 +60,7 @@ module.exports = [
|
||||
}
|
||||
return render(200, "pug/user.pug", {url, user, constants})
|
||||
}).catch(error => {
|
||||
if (error === constants.symbols.NOT_FOUND) {
|
||||
if (error === constants.symbols.NOT_FOUND || error === constants.symbols.ENDPOINT_OVERRIDDEN) {
|
||||
return render(404, "pug/friendlyerror.pug", {
|
||||
statusCode: 404,
|
||||
title: "Not found",
|
||||
@ -100,7 +100,7 @@ module.exports = [
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
if (error === constants.symbols.NOT_FOUND) {
|
||||
if (error === constants.symbols.NOT_FOUND || error === constants.symbols.ENDPOINT_OVERRIDDEN) {
|
||||
return render(404, "pug/friendlyerror.pug", {
|
||||
statusCode: 404,
|
||||
title: "Not found",
|
||||
|
Loading…
Reference in New Issue
Block a user