1
0
Fork 0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2026-03-29 15:51:35 +00:00

User pages now count for quota, as it should be.

This commit is contained in:
Cadence Ember 2022-05-06 16:05:37 +12:00
parent 5a1b0e88b2
commit 7acb21f613
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
4 changed files with 23 additions and 5 deletions

View file

@ -13,6 +13,16 @@ function getPageTitle(post) {
return (post.getCaptionIntroduction() || `Post from @${post.getBasicOwner().username}`) + " | Bibliogram"
}
async function getUserAndQuota(req, username) {
if (quota.remaining(req) === 0) {
throw constants.symbols.QUOTA_REACHED
}
const {user, quotaUsed} = await fetchUser(username)
const remaining = quota.add(req, quotaUsed)
return {user, remaining}
}
function getPostAndQuota(req, shortcode) {
if (quota.remaining(req) === 0) {
throw constants.symbols.QUOTA_REACHED
@ -101,8 +111,7 @@ module.exports = [
throw constants.symbols.QUOTA_REACHED
}
const {user, quotaUsed} = await fetchUser(username)
let remaining = quota.add(req, quotaUsed)
let {user, remaining} = await getUserAndQuota(req, username)
const selectedTimeline = user[type]
let pageNumber = +params.get("page")