Skip to content

Commit 4f4edcc

Browse files
committed
Trying to resolve the 400 errors.
1 parent bcb4d86 commit 4f4edcc

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

functions/common/methods.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import nodemailer from 'nodemailer'
1414
import { extname, join } from 'path'
1515
import qs from 'qs'
1616
import {
17+
BikeTagEnv,
1718
getDomainInfo,
1819
getImageSized,
1920
getTagDateISOFromTimezone,
@@ -857,9 +858,14 @@ export const archiveAndClearQueue = async (
857858
{ game: queuedTags[0].game },
858859
{ source: 'sanity' },
859860
)
860-
game = gameResponse.success ? gameResponse.data : undefined
861+
if (gameResponse.success) {
862+
game = gameResponse.data
863+
} else {
864+
return { results: [{ message: ErrorMessage.GameNotSet, game: undefined }], errors: true }
865+
}
861866
}
862-
const imageSource = game?.awsRegion ? 'aws' : 'imgur'
867+
868+
const imageSource = getImageSource(game)
863869

864870
if (queuedTags.length && game) {
865871
const nonAdminBikeTagOpts = getBikeTagClientOpts(undefined, true, false, game)
@@ -1939,5 +1945,5 @@ export const getImageSource = (game: Game): 'aws' | 'imgur' => {
19391945
} else if (game.mainhash?.length) {
19401946
return 'imgur'
19411947
}
1942-
return 'imgur'
1948+
return BikeTagEnv.IMAGE_SOURCE as 'aws' | 'imgur'
19431949
}

src/common/constants.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const BikeTagDefaults = {
66
hostKey: 'ItsABikeTagGame',
77
logo: '/images/BikeTag.svg',
88
jingle: 'media/biketag-jingle-1.mp3',
9-
imageSource: 'imgur',
9+
imageSource: 'aws',
1010
gameSource: 'sanity',
1111
store: 'biketag',
1212
cacheResetInterval: '5000',
@@ -41,11 +41,10 @@ export const BikeTagEnv = {
4141
B_KEY: process.env.B_KEY ?? process.env.CLIENT_KEY ?? null,
4242
/* BikeTag Configuration */
4343
GAME_NAME: process.env.GAME_NAME ?? null,
44-
GAME_SOURCE: process.env.GAME_SOURCE ?? BikeTagDefaults.gameSource ?? null,
45-
IMAGE_SOURCE: process.env.IMAGE_SOURCE ?? BikeTagDefaults.imageSource ?? null,
44+
GAME_SOURCE: process.env.GAME_SOURCE ?? BikeTagDefaults.gameSource,
45+
IMAGE_SOURCE: process.env.IMAGE_SOURCE ?? BikeTagDefaults.imageSource,
4646
HOST: process.env.HOST ?? BikeTagDefaults.host ?? null,
4747
BIKETAG_AUTHED: process.env.BIKETAG_AUTHED ?? null,
48-
DEFAULT_IMAGE_SOURCE: process.env.DEFAULT_IMAGE_SOURCE ?? BikeTagDefaults.imageSource ?? 'imgur',
4948
/* Google Configuration */
5049
G_AKEY:
5150
process.env.G_AKEY ?? process.env.GOOGLE_ACCESS_TOKEN ?? process.env.GOOGLE_API_KEY ?? null,

src/store/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
243243
}
244244
},
245245
async fetchCredentials(fetchNewCredentials = false) {
246-
if (!this.credentialsFetched || fetchNewCredentials) {
246+
if ((!this.credentialsFetched && !this.token?.length) || fetchNewCredentials) {
247247
try {
248248
const biketagConf = await client.fetchCredentials(`player-id ${this.profile.sub}`)
249249
if (biketagConf?.biketag?.clientToken) {

0 commit comments

Comments
 (0)