@@ -96,7 +96,7 @@ const ComputervisionController = class ComputervisionController {
9696 if ( ! req . userSession && ! req . applicationSession ) {
9797 throw util . httpError ( 401 , "Unauthorized" ) ;
9898 }
99- const photoURL = req . query . image_url || req . body . image_url ;
99+ const photoURL = req . query . image_url || req . body ? .image_url ;
100100 if ( ! photoURL ) {
101101 throw util . httpError ( 422 , "No scorable photo" ) ;
102102 }
@@ -164,7 +164,7 @@ const ComputervisionController = class ComputervisionController {
164164 if ( ! req . userSession && ! req . applicationSession ) {
165165 throw util . httpError ( 401 , "Unauthorized" ) ;
166166 }
167- if ( req . userSession ?. isAdmin && req . body . image_url ) {
167+ if ( req . userSession ?. isAdmin && req . body ? .image_url ) {
168168 return ComputervisionController . scoreImageURL ( req ) ;
169169 }
170170 req . file = req . file || (
@@ -192,33 +192,33 @@ const ComputervisionController = class ComputervisionController {
192192 } ) ;
193193 formData . append ( "geomodel" , "true" ) ;
194194 formData . append ( "format" , "object" ) ;
195- if ( req . body . taxon_id ) {
195+ if ( req . body ? .taxon_id ) {
196196 formData . append ( "taxon_id" , req . body . taxon_id ) ;
197197 }
198- if ( req . body . aggregated || req . query . aggregated ) {
198+ if ( req . body ? .aggregated || req . query . aggregated ) {
199199 formData . append ( "aggregated" , "true" ) ;
200200 }
201- const testFeature = req . body . test_feature || req . query . test_feature ;
201+ const testFeature = req . body ? .test_feature || req . query . test_feature ;
202202 if ( testFeature === "ancestor_unrestricted" ) {
203203 formData . append ( "common_ancestor_rank_type" , "unrestricted" ) ;
204204 } else if ( testFeature === "ancestor_major_ranks" ) {
205205 formData . append ( "common_ancestor_rank_type" , "major" ) ;
206206 }
207- if ( ! req . body . skip_frequencies && req . body . lat && req . body . lng ) {
207+ if ( ! req . body ? .skip_frequencies && req . body ? .lat && req . body ? .lng ) {
208208 formData . append ( "lat" , req . body . lat ) ;
209209 formData . append ( "lng" , req . body . lng ) ;
210210 }
211211
212- if ( req . body . include_representative_photos
212+ if ( req . body ? .include_representative_photos
213213 || req . query . include_representative_photos
214214 ) {
215215 formData . append ( "return_embedding" , "true" ) ;
216216 }
217217
218- if ( req . body . human_exclusion
218+ if ( req . body ? .human_exclusion
219219 || req . query . human_exclusion
220220 ) {
221- formData . append ( "human_exclusion" , req . body . human_exclusion || req . query . human_exclusion ) ;
221+ formData . append ( "human_exclusion" , req . body ? .human_exclusion || req . query . human_exclusion ) ;
222222 }
223223
224224 const requestAbortController = new AbortController ( ) ;
@@ -354,7 +354,7 @@ const ComputervisionController = class ComputervisionController {
354354 s . frequency_score = s . geo_score >= s . geo_threshold ? 1 : 0 ;
355355 s . taxon_id = s . id ;
356356 delete s . id ;
357- if ( ! ( req . body . aggregated || req . query . aggregated ) ) {
357+ if ( ! ( req . body ? .aggregated || req . query . aggregated ) ) {
358358 s . original_geo_score = s . geo_score ;
359359 s . original_combined_score = s . combined_score ;
360360 delete s . geo_threshold ;
@@ -366,13 +366,13 @@ const ComputervisionController = class ComputervisionController {
366366 await ESModel . fetchBelongsTo ( withTaxa , Taxon , taxonOpts ) ;
367367 await Taxon . preloadIntoTaxonPhotos ( _ . map ( _ . filter ( withTaxa , "taxon" ) , "taxon" ) , { localeOpts } ) ;
368368
369- if ( ! ( req . body . aggregated || req . query . aggregated ) ) {
369+ if ( ! ( req . body ? .aggregated || req . query . aggregated ) ) {
370370 _ . each ( withTaxa , s => {
371371 delete s . taxon_id ;
372372 } ) ;
373373 }
374374
375- if ( req . body . include_representative_photos
375+ if ( req . body ? .include_representative_photos
376376 || req . query . include_representative_photos
377377 ) {
378378 await ComputervisionController . addRepresentativePhotos (
0 commit comments