Skip to content

Commit

Permalink
remove attachment field checks and validation
Browse files Browse the repository at this point in the history
  • Loading branch information
frankchn committed May 14, 2021
1 parent abee913 commit e04d38c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
23 changes: 1 addition & 22 deletions src/app/models/field/attachmentField.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { Document, Schema } from 'mongoose'

import {
AttachmentSize,
IAttachmentField,
IFormSchema,
ResponseMode,
} from '../../../types'
import { AttachmentSize, IAttachmentField, IFormSchema } from '../../../types'

// Manual override since mongoose types don't have generics yet.
interface IAttachmentFieldSchema extends IAttachmentField, Document {
Expand All @@ -24,22 +19,6 @@ const createAttachmentFieldSchema = () => {
},
})

// Prevent attachments from being saved on a webhooked form.
AttachmentFieldSchema.pre<IAttachmentFieldSchema>(
'validate',
function (next) {
const { webhook, responseMode } = this.parent()

if (responseMode === ResponseMode.Encrypt && webhook?.url) {
return next(
Error('Attachments are not allowed when a form has a webhook url'),
)
}

return next()
},
)

return AttachmentFieldSchema
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,8 @@ function editFormController(

$scope.isStorageForm = $scope.myform.responseMode === responseModeEnum.ENCRYPT

// Disable attachment fields when we have webhooks
$scope.isDisabledField = function (fieldType) {
return fieldType.name === 'attachment' && $scope.myform.webhook.url !== ''
$scope.isDisabledField = function () {
return false
}

/**
Expand Down

0 comments on commit e04d38c

Please sign in to comment.