diff --git a/functions/src/definitions/common/genAI.ts b/functions/src/definitions/common/genAI.ts index aa93da2d..6726b2c1 100644 --- a/functions/src/definitions/common/genAI.ts +++ b/functions/src/definitions/common/genAI.ts @@ -49,9 +49,8 @@ async function anonymiseMessage( const responseObj = JSON.parse(response) const redactions: redaction[] = responseObj.redacted redactions.forEach((redaction) => { - let regex = new RegExp(redaction.text, "g") - returnMessage = returnMessage.replace( - regex, + returnMessage = returnMessage.replaceAll( + redaction.text, redaction.replaceWith ) }) diff --git a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts index e1052204..90a32745 100644 --- a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts +++ b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts @@ -247,6 +247,13 @@ bot.on(message("text"), async (ctx) => { .where("telegramId", "==", checkerId) .get() + if (userQuerySnap.empty) { + await ctx.reply( + `You have not onboarded as a CheckMate Checker yet. Type /onboard to begin your journey.` + ) + return + } + const userSnap = userQuerySnap.docs[0] let currentStep = userSnap.data().onboardingStatus const expectingRepliesTo = ["name", "number", "verify"] @@ -550,10 +557,9 @@ const sendQuizPrompt = async ( const linkURL = `${TYPEFORM_URL}#name=${name}&phone=${whatsappId}` await bot.telegram.sendMessage( chatId, - `${ - isFirstPrompt - ? "Thank you for verifying your WhatsApp number" - : "We noticed you have not completed the quiz yet" + `${isFirstPrompt + ? "Thank you for verifying your WhatsApp number" + : "We noticed you have not completed the quiz yet" }. Please proceed to complete the onboarding quiz here. This will equip you with the skills and knowledge to be a better checker! ${progressBars(2)}`, @@ -587,10 +593,9 @@ const sendWABotPrompt = async ( } await bot.telegram.sendMessage( chatId, - `${ - isFirstPrompt - ? "Next, try out our CheckMate WhatsApp service" - : "We noticed you haven't tried out the WhatsApp service yet. Please try out the CheckMate WhatsApp service" + `${isFirstPrompt + ? "Next, try out our CheckMate WhatsApp service" + : "We noticed you haven't tried out the WhatsApp service yet. Please try out the CheckMate WhatsApp service" } as a user here, and send in the pre-populated message. This Whatsapp service is where people send in the messages that you'll be checking. Part of your role will also be to report suspicious messages here! @@ -622,10 +627,9 @@ const sendTGGroupPrompt = async ( } await bot.telegram.sendMessage( chatId, - `${ - isFirstPrompt - ? "Next, p" - : "We noticed you have not joined the groupchat yet. P" + `${isFirstPrompt + ? "Next, p" + : "We noticed you have not joined the groupchat yet. P" }lease join the CheckMate Checker's groupchat. This group chat is important as it will be used to: 1) Inform checkers of any downtime in the system, updates/improvements being deployed to the bots diff --git a/functions/tsconfig.json b/functions/tsconfig.json index c1ac2b6d..3b4e31da 100644 --- a/functions/tsconfig.json +++ b/functions/tsconfig.json @@ -8,7 +8,8 @@ "moduleResolution": "node", "sourceMap": true, "strict": true, - "target": "es2017", + "target": "ES2021", + "lib": ["ES2021", "DOM"], "noErrorTruncation": true, "esModuleInterop": true, "resolveJsonModule": true