api-client/turnstile: don't retry making session if it's not needed

This commit is contained in:
dumbmoron 2024-09-14 19:11:53 +00:00
parent 5d7cd861f3
commit 95f0fbdb5e
No known key found for this signature in database

View file

@ -26,9 +26,11 @@ export class TurnstileCobaltAPI extends CobaltAPI {
}
async request(data: CobaltRequest) {
const sessionOrError = await this.#session.getSession();
const headers: Record<string, string> = {};
if (this.#instanceHasTurnstile) {
const sessionOrError = await this.#session.getSession();
if ("error" in sessionOrError) {
if (sessionOrError.error.code !== CobaltAuthError.NotConfigured) {
return sessionOrError;
@ -38,6 +40,7 @@ export class TurnstileCobaltAPI extends CobaltAPI {
} else {
headers['Authorization'] = `Bearer ${sessionOrError.token}`;
}
}
return super.request(data, headers);
}