Skip to content

Commit c9d5a90

Browse files
committed
Implement further review feedback.
1 parent 24474c6 commit c9d5a90

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

functions/src/webhooks/transcription.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const transcription = functions.https.onRequest(async (req, res) => {
2929
const authenticatedEventIds = [] as string[]
3030
const hashedToken = sha256(String(req.headers["x-maple-webhook"]))
3131

32-
for (const index in maybeEventsInDb.docs){
32+
for (const index in maybeEventsInDb.docs) {
3333
const doc = maybeEventsInDb.docs[index]
3434

3535
const tokenDocInDb = await db
@@ -46,6 +46,17 @@ export const transcription = functions.https.onRequest(async (req, res) => {
4646
}
4747
}
4848

49+
// Log edge cases
50+
if (maybeEventsInDb.docs.length === 0) {
51+
console.log("No matching event in db.")
52+
}
53+
if (authenticatedEventIds.length === 0) {
54+
console.log("No authenticated events in db.")
55+
}
56+
if (authenticatedEventIds.length > 1) {
57+
console.log("More than one matching event in db.")
58+
}
59+
4960
if (authenticatedEventIds.length === 1) {
5061
// If there is one authenticated event, pull out the parts we want to
5162
// save and try to save them in the db.
@@ -86,17 +97,16 @@ export const transcription = functions.https.onRequest(async (req, res) => {
8697

8798
// Delete the hashed webhook auth token from our db now that
8899
// we're done.
89-
authenticatedEventIds.forEach(async docId => {
90-
91-
await db.collection("events")
92-
.doc(docId)
93-
.collection("private")
94-
.doc("webhookAuth")
95-
.set({
96-
videoAssemblyWebhookToken: null
97-
})
98-
99-
})
100+
for (const index in authenticatedEventIds) {
101+
await db
102+
.collection("events")
103+
.doc(authenticatedEventIds[index])
104+
.collection("private")
105+
.doc("webhookAuth")
106+
.set({
107+
videoAssemblyWebhookToken: null
108+
})
109+
}
100110
} catch (error) {
101111
console.log(error)
102112
}

0 commit comments

Comments
 (0)