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}>}
|
* @returns {Promise<{user: import("./structures/User"), quotaUsed: number}>}
|
||||||
*/
|
*/
|
||||||
function fetchUserFromHTML(username) {
|
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")) {
|
if (history.store.has("user")) {
|
||||||
const entry = history.store.get("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)
|
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}>}
|
* @returns {Promise<{result: import("./types").PagedEdges<import("./types").TimelineEntryN2>, fromCache: boolean}>}
|
||||||
*/
|
*/
|
||||||
function fetchTimelinePage(userID, after) {
|
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()
|
const p = new URLSearchParams()
|
||||||
p.set("query_hash", constants.external.timeline_query_hash)
|
p.set("query_hash", constants.external.timeline_query_hash)
|
||||||
p.set("variables", JSON.stringify({
|
p.set("variables", JSON.stringify({
|
||||||
@ -294,7 +304,7 @@ function fetchTimelinePage(userID, after) {
|
|||||||
history.report("timeline", true)
|
history.report("timeline", true)
|
||||||
return timeline
|
return timeline
|
||||||
}).catch(error => {
|
}).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)
|
history.report("timeline", false)
|
||||||
}
|
}
|
||||||
throw error
|
throw error
|
||||||
@ -326,7 +336,7 @@ function fetchIGTVPage(userID, after) {
|
|||||||
history.report("igtv", true)
|
history.report("igtv", true)
|
||||||
return timeline
|
return timeline
|
||||||
}).catch(error => {
|
}).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)
|
history.report("igtv", false)
|
||||||
}
|
}
|
||||||
throw error
|
throw error
|
||||||
@ -430,7 +440,7 @@ function fetchShortcodeData(shortcode) {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).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)
|
history.report("post", false)
|
||||||
}
|
}
|
||||||
throw error
|
throw error
|
||||||
|
@ -216,8 +216,14 @@ let constants = {
|
|||||||
cache_sweep_interval: 3*60*1000,
|
cache_sweep_interval: 3*60*1000,
|
||||||
csrf_time: 60*60*1000,
|
csrf_time: 60*60*1000,
|
||||||
self_blocked_status: {
|
self_blocked_status: {
|
||||||
enabled: true,
|
user_html: {
|
||||||
time: 2*60*60*1000,
|
enabled: false,
|
||||||
|
time: 15*60*1000
|
||||||
|
},
|
||||||
|
timeline_graphql: {
|
||||||
|
enabled: false,
|
||||||
|
time: 24*60*60*1000
|
||||||
|
}
|
||||||
},
|
},
|
||||||
db_user_id: true,
|
db_user_id: true,
|
||||||
db_post_n3: false,
|
db_post_n3: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user