From 42fbcb90224b36bf9405064cc6b1748ee9dc8675 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Mon, 11 Nov 2024 21:27:11 +0800 Subject: [PATCH] deactivate upon offboarding and save data --- .../src/definitions/common/parameters/checkerResponses.json | 2 +- functions/src/definitions/taskHandlers/reactivations.ts | 6 ++++++ functions/src/services/checker/managementService.ts | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/functions/src/definitions/common/parameters/checkerResponses.json b/functions/src/definitions/common/parameters/checkerResponses.json index 7771edf0..ccfc398b 100644 --- a/functions/src/definitions/common/parameters/checkerResponses.json +++ b/functions/src/definitions/common/parameters/checkerResponses.json @@ -15,7 +15,7 @@ "NO_OUTSTANDING": "Great, you have no further messages to assess. Keep it up!💪", "REMINDER": "📍 We Miss You! 👀\n\nHey {{name}}, it looks like you've been inactive for the past {{num_days}} days. Just a friendly reminder: if we don't see any activity for 7 days, your access as a checker will be temporarily deactivated.\n\nIf you need any help or have any questions, feel free to ask in the Q&A channel of our Checker's Telegram group - we're here to help! 😊", "DEACTIVATION": "📍 Temporary Deactivation Notice\n\nHi {{name}},\n\nYour access as a checker has been temporarily deactivated due to inactivity. No worries though - simply press the button below to get back to checking! 🚀\n\nWe're excited to see you back in action soon 😊", - "MANAGE_OUT": "📍 CheckMate Fact-checker Programme Status\n\nHi {{name}},\n\nThank you so much for your time and dedication during the CheckMate programme. While you've given it your best, it seems we haven't quite met the criteria needed to continue as a volunteer in our checking crew.\n\nWe'd love to hear about your experience - your feedback will help us improve! Please take a moment to fill out this quick survey: \n\nAs part of this process, you'll also be removed from the Checkers' Crew Telegram chat. We appreciate your understanding and wish you all the best moving forward 💛\n\nThank you for your contribution,\n\nThe CheckMate Team", + "MANAGE_OUT": "📍 CheckMate Fact-checker Programme Status\n\nHi {{name}},\n\nThank you so much for your time and dedication during the CheckMate programme. While you've given it your best, it seems we haven't quite met the criteria needed to continue as a volunteer in our checking crew.\n\nWe'd love to hear about your experience - your feedback will help us improve! Please take a moment to fill out this quick survey: \n\nAs part of this process, you'll also be removed from the Checkers' Crew Telegram chat, and will not receive future messages to vote on. We appreciate your understanding and wish you all the best moving forward 💛\n\nThank you for your contribution,\n\nThe CheckMate Team", "GRADUATION": "📍 Congratulations, You've Graduated! 🎉\n\nHi {{name}},\n\nHuge congratulations on completing the CheckMate checkers' programme! You've worked hard, and completed the following:\n\nNo. of messages voted on: {{num_messages}}\nAccuracy: {{accuracy}}\nNo. of new users referred: {{num_referred}}\nNo. of messages reported: {{num_reported}}\n\nYour dedication has clearly paid off! 🎓\n\nWe'd love to hear about your experience - please take a moment to fill out our survey\n\nTo generate your official completion certificate, just press the button below.\n\nThank you for being part of the Checkers' Crew. We're so proud of you! 💪", "WELCOME": "📍 Welcome to the Checkers' Crew! 👋\n\nLet's welcome our new checkers!🎉\n\n{{names}}\n\nWe're so excited to have you join our fact-checking family. This group is your hub for connecting with fellow Checkers, sharing tips, and staying up to date with important updates.\n\nIf you ever feel unsure about anything, don't hesitate to reach out or ask in our Q&A channel. We're all here to support each other and improve our skills together 🤗\n\nLet's get started!" } diff --git a/functions/src/definitions/taskHandlers/reactivations.ts b/functions/src/definitions/taskHandlers/reactivations.ts index 4518e900..b6826663 100644 --- a/functions/src/definitions/taskHandlers/reactivations.ts +++ b/functions/src/definitions/taskHandlers/reactivations.ts @@ -67,6 +67,12 @@ export const sendCheckerReactivation = onTaskDispatched( logger.error(`Checker ${checkerId} not found`) return } + if (checkerDocSnap.get("offboardingTime") != null) { + logger.info( + `Checker ${checkerId} has been offboarded. Stopping reactivation attempts.` + ) + return + } const reactivationCheckResponse = await checkCheckerActivity( checkerDocSnap, cumulativeDelaySeconds diff --git a/functions/src/services/checker/managementService.ts b/functions/src/services/checker/managementService.ts index 9daedc6d..7913ef0c 100644 --- a/functions/src/services/checker/managementService.ts +++ b/functions/src/services/checker/managementService.ts @@ -58,6 +58,11 @@ export async function offboardChecker(checkerDocSnap: DocumentSnapshot) { ) //call Telegram API to kick checker from group await adminBot.telegram.unbanChatMember(CHECKERS_CHAT_ID, telegramId) + await checkerDocSnap.ref.update({ + isActive: false, + offboardingTime: Timestamp.now(), + onboardingStatus: "offboarded", + }) return ServiceResponse.success({ message: "Checker expelled", })