@@ -29,7 +29,7 @@ export const transcription = functions.https.onRequest(async (req, res) => {
29
29
const authenticatedEventIds = [ ] as string [ ]
30
30
const hashedToken = sha256 ( String ( req . headers [ "x-maple-webhook" ] ) )
31
31
32
- for ( const index in maybeEventsInDb . docs ) {
32
+ for ( const index in maybeEventsInDb . docs ) {
33
33
const doc = maybeEventsInDb . docs [ index ]
34
34
35
35
const tokenDocInDb = await db
@@ -46,6 +46,17 @@ export const transcription = functions.https.onRequest(async (req, res) => {
46
46
}
47
47
}
48
48
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
+
49
60
if ( authenticatedEventIds . length === 1 ) {
50
61
// If there is one authenticated event, pull out the parts we want to
51
62
// save and try to save them in the db.
@@ -86,17 +97,16 @@ export const transcription = functions.https.onRequest(async (req, res) => {
86
97
87
98
// Delete the hashed webhook auth token from our db now that
88
99
// 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
+ }
100
110
} catch ( error ) {
101
111
console . log ( error )
102
112
}
0 commit comments