mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2024-11-22 08:07:30 +00:00
Change self_blocked_status to include timeline
Disabled by default, enable in the usual way.
This commit is contained in:
parent
e1883b2d9e
commit
2419fbf08b
@ -86,10 +86,11 @@ async function fetchUser(username, context) {
|
||||
* @returns {Promise<{user: import("./structures/User"), quotaUsed: number}>}
|
||||
*/
|
||||
function fetchUserFromHTML(username) {
|
||||
if (constants.caching.self_blocked_status.enabled) {
|
||||
const blockedCacheConfig = constants.caching.self_blocked_status.user_html
|
||||
if (blockedCacheConfig) {
|
||||
if (history.store.has("user")) {
|
||||
const entry = history.store.get("user")
|
||||
if (!entry.lastRequestSuccessful && Date.now() < entry.lastRequestAt + constants.caching.self_blocked_status.time) {
|
||||
if (!entry.lastRequestSuccessful && Date.now() < entry.lastRequestAt + blockedCacheConfig.time) {
|
||||
return Promise.reject(constants.symbols.RATE_LIMITED)
|
||||
}
|
||||
}
|
||||
@ -271,6 +272,15 @@ function fetchUserFromSaved(saved) {
|
||||
* @returns {Promise<{result: import("./types").PagedEdges<import("./types").TimelineEntryN2>, fromCache: boolean}>}
|
||||
*/
|
||||
function fetchTimelinePage(userID, after) {
|
||||
const blockedCacheConfig = constants.caching.self_blocked_status.timeline_graphql
|
||||
if (blockedCacheConfig) {
|
||||
if (history.store.has("timeline")) {
|
||||
const entry = history.store.get("timeline")
|
||||
if (!entry.lastRequestSuccessful && Date.now() < entry.lastRequestAt + blockedCacheConfig.time) {
|
||||
return Promise.reject(constants.symbols.RATE_LIMITED)
|
||||
}
|
||||
}
|
||||
}
|
||||
const p = new URLSearchParams()
|
||||
p.set("query_hash", constants.external.timeline_query_hash)
|
||||
p.set("variables", JSON.stringify({
|
||||
@ -294,7 +304,7 @@ function fetchTimelinePage(userID, after) {
|
||||
history.report("timeline", true)
|
||||
return timeline
|
||||
}).catch(error => {
|
||||
if (error === constants.symbols.RATE_LIMITED) {
|
||||
if (error === constants.symbols.RATE_LIMITED || error === constants.symbols.INSTAGRAM_BLOCK_TYPE_DECEMBER) {
|
||||
history.report("timeline", false)
|
||||
}
|
||||
throw error
|
||||
@ -326,7 +336,7 @@ function fetchIGTVPage(userID, after) {
|
||||
history.report("igtv", true)
|
||||
return timeline
|
||||
}).catch(error => {
|
||||
if (error === constants.symbols.RATE_LIMITED) {
|
||||
if (error === constants.symbols.RATE_LIMITED || error === constants.symbols.INSTAGRAM_BLOCK_TYPE_DECEMBER) {
|
||||
history.report("igtv", false)
|
||||
}
|
||||
throw error
|
||||
@ -430,7 +440,7 @@ function fetchShortcodeData(shortcode) {
|
||||
return data
|
||||
}
|
||||
}).catch(error => {
|
||||
if (error === constants.symbols.RATE_LIMITED) {
|
||||
if (error === constants.symbols.RATE_LIMITED || error === constants.symbols.INSTAGRAM_BLOCK_TYPE_DECEMBER) {
|
||||
history.report("post", false)
|
||||
}
|
||||
throw error
|
||||
|
@ -216,8 +216,14 @@ let constants = {
|
||||
cache_sweep_interval: 3*60*1000,
|
||||
csrf_time: 60*60*1000,
|
||||
self_blocked_status: {
|
||||
enabled: true,
|
||||
time: 2*60*60*1000,
|
||||
user_html: {
|
||||
enabled: false,
|
||||
time: 15*60*1000
|
||||
},
|
||||
timeline_graphql: {
|
||||
enabled: false,
|
||||
time: 24*60*60*1000
|
||||
}
|
||||
},
|
||||
db_user_id: true,
|
||||
db_post_n3: false,
|
||||
|
Loading…
Reference in New Issue
Block a user