From afd90a02c0e95e1141a06b54e2c00d7a199620cc Mon Sep 17 00:00:00 2001 From: alexbcberio Date: Thu, 6 Jan 2022 03:22:29 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Small=20check=20to=20keep=20some=20?= =?UTF-8?q?rewards=20in=20the=20queue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/pubSubClient/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backend/pubSubClient/index.ts b/src/backend/pubSubClient/index.ts index 979d529..dcc7289 100644 --- a/src/backend/pubSubClient/index.ts +++ b/src/backend/pubSubClient/index.ts @@ -93,6 +93,15 @@ async function onRedemption(message: PubSubRedemptionMessage) { broadcast(JSON.stringify(handledMessage)); } + // TODO: improve this check + const keepInQueueRewards = [RedemptionIds.KaraokeTime]; + + // @ts-expect-error String is not assignable to... but all keys are strings + if (keepInQueueRewards.includes(message.rewardId)) { + console.log(`${LOG_PREFIX}Reward kept in queue due to config`); + return; + } + const completeOrCancelReward = handledMessage && isProduction ? completeRewards : cancelRewards; @@ -103,6 +112,9 @@ async function onRedemption(message: PubSubRedemptionMessage) { message.rewardId, message.id ); + console.log( + `${LOG_PREFIX}Reward removed from queue (completed or canceled)` + ); } catch (e) { if (e instanceof Error) { console.log(`${LOG_PREFIX}${e.message}`);