Do less work in onCreateAnswer

This commit is contained in:
Marshall Polaris 2022-07-12 13:48:56 -07:00
parent d7d621fc99
commit d6c0af1f5f

View File

@ -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')