mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2024-11-16 13:17:30 +00:00
Assistant understands age restricted profiles
This commit is contained in:
parent
fff2d74fe3
commit
138145fa05
@ -35,6 +35,9 @@ class Assistant {
|
|||||||
if (root.identifier === "NOT_FOUND") {
|
if (root.identifier === "NOT_FOUND") {
|
||||||
this.lastRequestStatus = constants.symbols.assistant_statuses.OK
|
this.lastRequestStatus = constants.symbols.assistant_statuses.OK
|
||||||
reject(constants.symbols.NOT_FOUND)
|
reject(constants.symbols.NOT_FOUND)
|
||||||
|
} else if (root.identifier === "AGE_RESTRICTED") {
|
||||||
|
this.lastRequestStatus = constants.symbols.assistant_statuses.OK
|
||||||
|
reject(constants.symbols.extractor_results.AGE_RESTRICTED)
|
||||||
} else if (root.identifier === "NOT_AUTHENTICATED") {
|
} else if (root.identifier === "NOT_AUTHENTICATED") {
|
||||||
this.lastRequestStatus = constants.symbols.assistant_statuses.NOT_AUTHENTICATED
|
this.lastRequestStatus = constants.symbols.assistant_statuses.NOT_AUTHENTICATED
|
||||||
reject(constants.symbols.assistant_statuses.NOT_AUTHENTICATED)
|
reject(constants.symbols.assistant_statuses.NOT_AUTHENTICATED)
|
||||||
|
@ -25,7 +25,7 @@ class AssistantSwitcher {
|
|||||||
const user = await assistant.requestUser(username)
|
const user = await assistant.requestUser(username)
|
||||||
return resolve(user)
|
return resolve(user)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e === constants.symbols.NOT_FOUND) {
|
if (e === constants.symbols.NOT_FOUND || e === constants.symbols.extractor_results.AGE_RESTRICTED) {
|
||||||
const rejection = Promise.reject(e)
|
const rejection = Promise.reject(e)
|
||||||
rejection.catch(() => {}) // otherwise we get a warning that the rejection was handled asynchronously
|
rejection.catch(() => {}) // otherwise we get a warning that the rejection was handled asynchronously
|
||||||
collectors.userRequestCache.set(`user/${username}`, false, rejection)
|
collectors.userRequestCache.set(`user/${username}`, false, rejection)
|
||||||
|
@ -96,6 +96,14 @@ module.exports = [
|
|||||||
message: "User not found.",
|
message: "User not found.",
|
||||||
identifier: "NOT_FOUND"
|
identifier: "NOT_FOUND"
|
||||||
})
|
})
|
||||||
|
} else if (error === constants.symbols.extractor_results.AGE_RESTRICTED) {
|
||||||
|
return reply(403, {
|
||||||
|
status: "fail",
|
||||||
|
version: "1.0",
|
||||||
|
generatedAt: Date.now(),
|
||||||
|
message: "Profile is age restricted.",
|
||||||
|
identifier: "AGE_RESTRICTED"
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user