Skip to content

Commit

Permalink
fix: remove attachment integrity validation
Browse files Browse the repository at this point in the history
  • Loading branch information
justynoh committed May 6, 2024
1 parent 598c483 commit 79408a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,16 @@ export const validateMultirespondentSubmission = async (
const incomingResField = req.body.responses[fieldId]
const prevResField = previousResponses[fieldId]

// TODO(FRM-1724): Reenable this validation.
if (prevResField.fieldType === BasicField.Attachment) {
prevResField.answer.content = Buffer.from(
/**
* JSON.parse(JSON.stringify(fooBuffer)) does not fully reconstruct the Buffer object
* it gets parsed as { type: 'Buffer', data: number[] } instead of the original Buffer object
*/
// @ts-expect-error data does not exist on Buffer
prevResField.answer.content.data,
)
// prevResField.answer.content = Buffer.from(
// /**
// * JSON.parse(JSON.stringify(fooBuffer)) does not fully reconstruct the Buffer object
// * it gets parsed as { type: 'Buffer', data: number[] } instead of the original Buffer object
// */
// // @ts-expect-error data does not exist on Buffer
// prevResField.answer.content.data,
// )
}

const resp = isFieldResponseV3Equal(
Expand Down
6 changes: 4 additions & 2 deletions src/app/utils/response-v3.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import crypto from 'crypto'
import _ from 'lodash'

import { BasicField, FieldResponseV3 } from '../../../shared/types'
import { ParsedClearAttachmentResponseV3 } from '../../types/api'

export const isFieldResponseV3Equal = (
l: FieldResponseV3,
Expand Down Expand Up @@ -31,6 +29,9 @@ export const isFieldResponseV3Equal = (
case BasicField.Children:
return _.isEqual(l.answer, r.answer)
case BasicField.Attachment: {
return true
// TODO(FRM-1724): Re-enable this validation
/**
const lAnswer = l.answer as ParsedClearAttachmentResponseV3['answer']
const rAnswer = r.answer as ParsedClearAttachmentResponseV3['answer']
Expand All @@ -47,6 +48,7 @@ export const isFieldResponseV3Equal = (
return (
lMd5.equals(rMd5) && l.answer.hasBeenScanned === rAnswer.hasBeenScanned
)
*/
}
case BasicField.Section:
return true
Expand Down

0 comments on commit 79408a9

Please sign in to comment.