From d6c0af1f5fa107f73b7462c9ddd3d0aeee3619b0 Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Tue, 12 Jul 2022 13:48:56 -0700 Subject: [PATCH] Do less work in onCreateAnswer --- functions/src/on-create-answer.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/src/on-create-answer.ts b/functions/src/on-create-answer.ts index af4690b0..6af5e699 100644 --- a/functions/src/on-create-answer.ts +++ b/functions/src/on-create-answer.ts @@ -10,14 +10,14 @@ export const onCreateAnswer = functions.firestore contractId: string } const { eventId } = context - const contract = await getContract(contractId) - if (!contract) - throw new Error('Could not find contract corresponding with answer') - const answer = change.data() as Answer // Ignore ante answer. if (answer.number === 0) return + const contract = await getContract(contractId) + if (!contract) + throw new Error('Could not find contract corresponding with answer') + const answerCreator = await getUser(answer.userId) if (!answerCreator) throw new Error('Could not find answer creator')