Instance owners can disable RSS
RSS is still enabled by default, but will be disabled on bibliogram.art.
This commit is contained in:
@@ -41,7 +41,7 @@ module.exports = [
|
||||
},
|
||||
{
|
||||
route: "/api/stats/2.0", methods: ["GET"], code: async ({url}) => {
|
||||
const versions = ["1.0", "1.1"]
|
||||
const versions = ["1.0", "1.1", "1.2"]
|
||||
const features = [
|
||||
"PAGE_PROFILE",
|
||||
"PAGE_POST",
|
||||
@@ -60,6 +60,15 @@ module.exports = [
|
||||
availableVersions: versions,
|
||||
features,
|
||||
history: history.export()
|
||||
}],
|
||||
["1.2", {
|
||||
version: "1.2",
|
||||
availableVersions: versions,
|
||||
features,
|
||||
history: history.export(),
|
||||
settings: {
|
||||
rssEnabled: constants.settings.rss_enabled
|
||||
}
|
||||
}]
|
||||
])
|
||||
).get(url.searchParams.get("bv") || versions[0])
|
||||
|
||||
@@ -1,27 +1,49 @@
|
||||
const constants = require("../../lib/constants")
|
||||
const {fetchUser} = require("../../lib/collectors")
|
||||
const {fetchUser, requestCache} = require("../../lib/collectors")
|
||||
const {render} = require("pinski/plugins")
|
||||
const {pugCache} = require("../passthrough")
|
||||
|
||||
module.exports = [
|
||||
{route: `/u/(${constants.external.username_regex})/rss.xml`, methods: ["GET"], code: ({fill}) => {
|
||||
return fetchUser(fill[0]).then(async user => {
|
||||
const content = await user.timeline.fetchFeed()
|
||||
const xml = content.xml()
|
||||
return {
|
||||
statusCode: 200,
|
||||
contentType: "application/rss+xml", // see https://stackoverflow.com/questions/595616/what-is-the-correct-mime-type-to-use-for-an-rss-feed
|
||||
content: xml
|
||||
}
|
||||
}).catch(error => {
|
||||
if (error === constants.symbols.NOT_FOUND) {
|
||||
return render(404, "pug/friendlyerror.pug", {
|
||||
statusCode: 404,
|
||||
title: "Not found",
|
||||
message: "This user doesn't exist."
|
||||
})
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
})
|
||||
if (constants.settings.rss_enabled) {
|
||||
return fetchUser(fill[0]).then(async user => {
|
||||
const content = await user.timeline.fetchFeed()
|
||||
const xml = content.xml()
|
||||
return {
|
||||
statusCode: 200,
|
||||
contentType: "application/rss+xml", // see https://stackoverflow.com/questions/595616/what-is-the-correct-mime-type-to-use-for-an-rss-feed
|
||||
content: xml
|
||||
}
|
||||
}).catch(error => {
|
||||
if (error === constants.symbols.NOT_FOUND) {
|
||||
return render(404, "pug/friendlyerror.pug", {
|
||||
statusCode: 404,
|
||||
title: "Not found",
|
||||
message: "This user doesn't exist.",
|
||||
withInstancesLink: false
|
||||
})
|
||||
} else if (error === constants.symbols.INSTAGRAM_DEMANDS_LOGIN) {
|
||||
return {
|
||||
statusCode: 503,
|
||||
contentType: "text/html",
|
||||
headers: {
|
||||
"Retry-After": requestCache.getTtl("user/"+fill[0], 1000)
|
||||
},
|
||||
content: pugCache.get("pug/blocked.pug").web({
|
||||
expiresMinutes: requestCache.getTtl("user/"+fill[0], 1000*60)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return Promise.resolve(render(403, "pug/friendlyerror.pug", {
|
||||
statusCode: 403,
|
||||
title: "RSS disabled",
|
||||
message: "RSS is disabled on this instance.",
|
||||
withInstancesLink: true
|
||||
}))
|
||||
}
|
||||
}}
|
||||
]
|
||||
|
||||
@@ -17,7 +17,8 @@ module.exports = [
|
||||
statusCode: 400,
|
||||
title: "Bad request",
|
||||
message: "Expected a username",
|
||||
explanation: "Write /u/{username} or /u?u={username}."
|
||||
explanation: "Write /u/{username} or /u?u={username}.",
|
||||
withInstancesLink: false
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -30,13 +31,14 @@ module.exports = [
|
||||
if (typeof page === "number" && !isNaN(page) && page >= 1) {
|
||||
await user.timeline.fetchUpToPage(page - 1)
|
||||
}
|
||||
return render(200, "pug/user.pug", {url, user})
|
||||
return render(200, "pug/user.pug", {url, user, constants})
|
||||
}).catch(error => {
|
||||
if (error === constants.symbols.NOT_FOUND) {
|
||||
return render(404, "pug/friendlyerror.pug", {
|
||||
statusCode: 404,
|
||||
title: "Not found",
|
||||
message: "This user doesn't exist."
|
||||
message: "This user doesn't exist.",
|
||||
withInstancesLink: false
|
||||
})
|
||||
} else if (error === constants.symbols.INSTAGRAM_DEMANDS_LOGIN) {
|
||||
return {
|
||||
@@ -75,7 +77,8 @@ module.exports = [
|
||||
return render(404, "pug/friendlyerror.pug", {
|
||||
statusCode: 404,
|
||||
title: "Not found",
|
||||
message: "This user doesn't exist."
|
||||
message: "This user doesn't exist.",
|
||||
withInstancesLink: false
|
||||
})
|
||||
} else {
|
||||
throw error
|
||||
@@ -94,7 +97,8 @@ module.exports = [
|
||||
statusCode: 400,
|
||||
title: "Bad request",
|
||||
message: "Expected a shortcode",
|
||||
explanation: "Write /p/{shortcode} or /p?p={shortcode}."
|
||||
explanation: "Write /p/{shortcode} or /p?p={shortcode}.",
|
||||
withInstancesLink: false
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -111,7 +115,8 @@ module.exports = [
|
||||
return render(404, "pug/friendlyerror.pug", {
|
||||
statusCode: 404,
|
||||
title: "Not found",
|
||||
message: "Somehow, you reached a post that doesn't exist."
|
||||
message: "Somehow, you reached a post that doesn't exist.",
|
||||
withInstancesLink: false
|
||||
})
|
||||
} else {
|
||||
throw error
|
||||
|
||||
Reference in New Issue
Block a user