mirror of
				https://git.sr.ht/~cadence/bibliogram
				synced 2025-11-04 05:25:37 +00:00 
			
		
		
		
	Fragments have rate limit symbol handler
This commit is contained in:
		
							parent
							
								
									81b2c77b98
								
							
						
					
					
						commit
						20ea14c0d1
					
				@ -120,12 +120,12 @@ module.exports = [
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		route: `/fragment/user/(${constants.external.username_regex})/(\\d+)`, methods: ["GET"], code: async ({req, url, fill}) => {
 | 
			
		||||
			const settings = getSettings(req)
 | 
			
		||||
			return fetchUser(fill[0]).then(async user => {
 | 
			
		||||
				const pageNumber = +fill[1]
 | 
			
		||||
				const pageIndex = pageNumber - 1
 | 
			
		||||
				await user.timeline.fetchUpToPage(pageIndex)
 | 
			
		||||
				if (user.timeline.pages[pageIndex]) {
 | 
			
		||||
					const settings = getSettings(req)
 | 
			
		||||
					return render(200, "pug/fragments/timeline_page.pug", {page: user.timeline.pages[pageIndex], pageIndex, user, url, settings})
 | 
			
		||||
				} else {
 | 
			
		||||
					return {
 | 
			
		||||
@ -142,6 +142,16 @@ module.exports = [
 | 
			
		||||
						message: "This user doesn't exist.",
 | 
			
		||||
						withInstancesLink: false
 | 
			
		||||
					})
 | 
			
		||||
				} else if (error === constants.symbols.INSTAGRAM_DEMANDS_LOGIN || error === constants.symbols.RATE_LIMITED) {
 | 
			
		||||
					return render(503, "pug/friendlyerror.pug", {
 | 
			
		||||
						statusCode: 503,
 | 
			
		||||
						title: "Timeline loading blocked",
 | 
			
		||||
						message: "Timeline loading blocked",
 | 
			
		||||
						explanation:
 | 
			
		||||
								"Instagram blocked this server for requesting too many timeline pages."
 | 
			
		||||
							+"\nThis block is not permanent, and will expire soon."
 | 
			
		||||
							+"\nPlease wait a few minutes before trying again."
 | 
			
		||||
					})
 | 
			
		||||
				} else {
 | 
			
		||||
					throw error
 | 
			
		||||
				}
 | 
			
		||||
@ -171,6 +181,16 @@ module.exports = [
 | 
			
		||||
						message: "Somehow, you reached a post that doesn't exist.",
 | 
			
		||||
						withInstancesLink: false
 | 
			
		||||
					})
 | 
			
		||||
				} else if (error === constants.symbols.RATE_LIMITED) {
 | 
			
		||||
					return render(503, "pug/friendlyerror.pug", {
 | 
			
		||||
						statusCode: 503,
 | 
			
		||||
						title: "Post loading blocked",
 | 
			
		||||
						message: "Post loading blocked",
 | 
			
		||||
						explanation:
 | 
			
		||||
								"Instagram blocked this server for requesting too much post data."
 | 
			
		||||
							+"\nThis block is not permanent, and will expire soon."
 | 
			
		||||
							+"\nPlease wait a few minutes before trying again."
 | 
			
		||||
					})
 | 
			
		||||
				} else {
 | 
			
		||||
					throw error
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user