1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2026-01-06 21:41:13 +00:00

Hopefully the final assistants changes

This commit is contained in:
Cadence Ember
2020-04-13 02:52:04 +12:00
parent dc91575e1c
commit 41cbffa95a
9 changed files with 97 additions and 29 deletions

View File

@@ -5,11 +5,11 @@ const db = require("../db")
class AssistantSwitcher {
constructor() {
this.assistants = constants.assistant.origins.map(origin => new Assistant(origin))
this.assistants = constants.use_assistant.assistants.map(data => new Assistant(data.origin, data.key))
}
enabled() {
return constants.assistant.enabled && this.assistants.length
return constants.use_assistant.enabled && this.assistants.length
}
getAvailableAssistants() {
@@ -30,6 +30,9 @@ class AssistantSwitcher {
rejection.catch(() => {}) // otherwise we get a warning that the rejection was handled asynchronously
collectors.userRequestCache.set(`user/${username}`, false, rejection)
return reject(e)
} else if (e === constants.symbols.assistant_statuses.NOT_AUTHENTICATED) {
// no further requests will be successful. the assistant has already marked itself as not available.
console.error(`Assistant ${assistant.origin} refused request, not authenticated`)
}
// that assistant broke. try the next one.
}