mirror of
				https://git.sr.ht/~cadence/bibliogram
				synced 2025-10-31 11:35:35 +00:00 
			
		
		
		
	Use block status to inform future request policy
This commit is contained in:
		
							parent
							
								
									d66d12e7da
								
							
						
					
					
						commit
						3adb0d0ac6
					
				| @ -87,6 +87,14 @@ async function fetchUser(username, context) { | |||||||
|  */ |  */ | ||||||
| function fetchUserFromHTML(username) { | function fetchUserFromHTML(username) { | ||||||
| 	return userRequestCache.getOrFetch("user/"+username, false, true, () => { | 	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) | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
| 		return switcher.request("user_html", `https://www.instagram.com/${username}/`, async res => { | 		return switcher.request("user_html", `https://www.instagram.com/${username}/`, async res => { | ||||||
| 			if (res.status === 301) throw constants.symbols.ENDPOINT_OVERRIDDEN | 			if (res.status === 301) throw constants.symbols.ENDPOINT_OVERRIDDEN | ||||||
| 			if (res.status === 302) throw constants.symbols.INSTAGRAM_DEMANDS_LOGIN | 			if (res.status === 302) throw constants.symbols.INSTAGRAM_DEMANDS_LOGIN | ||||||
|  | |||||||
| @ -63,6 +63,10 @@ let constants = { | |||||||
| 		instance_list_cache_time: 3*60*1000, | 		instance_list_cache_time: 3*60*1000, | ||||||
| 		updater_cache_time: 2*60*1000, | 		updater_cache_time: 2*60*1000, | ||||||
| 		cache_sweep_interval: 3*60*1000, | 		cache_sweep_interval: 3*60*1000, | ||||||
|  | 		self_blocked_status: { | ||||||
|  | 			enabled: false, | ||||||
|  | 			time: 2*60*60*1000, | ||||||
|  | 		}, | ||||||
| 		db_user_id: true, | 		db_user_id: true, | ||||||
| 		db_post_n3: true, | 		db_post_n3: true, | ||||||
| 		db_request_history: false | 		db_request_history: false | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user