Skip to content

Commit

Permalink
chore(deps-dev): bump prettier from 2.4.1 to 2.5.0 (#3102)
Browse files Browse the repository at this point in the history
* chore(deps-dev): bump prettier from 2.4.1 to 2.5.0

Bumps [prettier](https://github.com/prettier/prettier) from 2.4.1 to 2.5.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](prettier/prettier@2.4.1...2.5.0)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore: run lint

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kar Rui Lau <[email protected]>
  • Loading branch information
dependabot[bot] and karrui authored Nov 26, 2021
1 parent 5252c96 commit bf26ff4
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 196 deletions.
16 changes: 11 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
"mongodb-memory-server-core": "^6.9.6",
"ngrok": "^4.2.2",
"optimize-css-assets-webpack-plugin": "^5.0.8",
"prettier": "^2.4.1",
"prettier": "^2.5.0",
"proxyquire": "^2.1.3",
"regenerator": "^0.14.4",
"rimraf": "^3.0.2",
Expand Down
185 changes: 93 additions & 92 deletions src/app/modules/bounce/bounce.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,104 +18,105 @@ const logger = createLoggerWithLabel(module)
* @param req Express request object
* @param res - Express response object
*/
export const handleSns: ControllerHandler<unknown, never, ISnsNotification> =
async (req, res) => {
const notificationResult = await BounceService.validateSnsRequest(
req.body,
).andThen(() => BounceService.safeParseNotification(req.body.Message))
if (notificationResult.isErr()) {
logger.warn({
message: 'Unable to parse email notification request',
meta: {
action: 'handleSns',
},
error: notificationResult.error,
})
return res.sendStatus(StatusCodes.UNAUTHORIZED)
}
const notification = notificationResult.value
export const handleSns: ControllerHandler<
unknown,
never,
ISnsNotification
> = async (req, res) => {
const notificationResult = await BounceService.validateSnsRequest(
req.body,
).andThen(() => BounceService.safeParseNotification(req.body.Message))
if (notificationResult.isErr()) {
logger.warn({
message: 'Unable to parse email notification request',
meta: {
action: 'handleSns',
},
error: notificationResult.error,
})
return res.sendStatus(StatusCodes.UNAUTHORIZED)
}
const notification = notificationResult.value

BounceService.logEmailNotification(notification)
// If not admin response, no more action to be taken
if (
BounceService.extractEmailType(notification) !== EmailType.AdminResponse
) {
return res.sendStatus(StatusCodes.OK)
}
BounceService.logEmailNotification(notification)
// If not admin response, no more action to be taken
if (
BounceService.extractEmailType(notification) !== EmailType.AdminResponse
) {
return res.sendStatus(StatusCodes.OK)
}

const bounceDocResult = await BounceService.getUpdatedBounceDoc(
notification,
)
if (bounceDocResult.isErr()) {
logger.warn({
message: 'Error while retrieving or creating new bounce doc',
meta: {
action: 'handleSns',
},
error: bounceDocResult.error,
})
return res.sendStatus(StatusCodes.OK)
}
const bounceDoc = bounceDocResult.value
const bounceDocResult = await BounceService.getUpdatedBounceDoc(notification)
if (bounceDocResult.isErr()) {
logger.warn({
message: 'Error while retrieving or creating new bounce doc',
meta: {
action: 'handleSns',
},
error: bounceDocResult.error,
})
return res.sendStatus(StatusCodes.OK)
}
const bounceDoc = bounceDocResult.value

const formResult = await FormService.retrieveFullFormById(bounceDoc.formId)
if (formResult.isErr()) {
// Either database error occurred or the formId saved in the bounce collection
// doesn't exist, so something went wrong.
logger.error({
message: 'Failed to retrieve form corresponding to bounced formId',
meta: {
action: 'handleSns',
formId: bounceDoc.formId,
},
})
return res.sendStatus(StatusCodes.INTERNAL_SERVER_ERROR)
}
const form = formResult.value
const formResult = await FormService.retrieveFullFormById(bounceDoc.formId)
if (formResult.isErr()) {
// Either database error occurred or the formId saved in the bounce collection
// doesn't exist, so something went wrong.
logger.error({
message: 'Failed to retrieve form corresponding to bounced formId',
meta: {
action: 'handleSns',
formId: bounceDoc.formId,
},
})
return res.sendStatus(StatusCodes.INTERNAL_SERVER_ERROR)
}
const form = formResult.value

if (bounceDoc.isCriticalBounce()) {
// Send notifications and deactivate form on best-effort basis, ignore errors
const possibleSmsRecipients =
await BounceService.getEditorsWithContactNumbers(form).unwrapOr([])
const emailRecipients = await BounceService.sendEmailBounceNotification(
bounceDoc,
form,
).unwrapOr([])
const smsRecipients = await BounceService.sendSmsBounceNotification(
bounceDoc,
if (bounceDoc.isCriticalBounce()) {
// Send notifications and deactivate form on best-effort basis, ignore errors
const possibleSmsRecipients =
await BounceService.getEditorsWithContactNumbers(form).unwrapOr([])
const emailRecipients = await BounceService.sendEmailBounceNotification(
bounceDoc,
form,
).unwrapOr([])
const smsRecipients = await BounceService.sendSmsBounceNotification(
bounceDoc,
form,
possibleSmsRecipients,
).unwrapOr([])
bounceDoc.setNotificationState(emailRecipients, smsRecipients)

const shouldDeactivate = bounceDoc.areAllPermanentBounces()
if (shouldDeactivate) {
await FormService.deactivateForm(bounceDoc.formId)
await BounceService.notifyAdminsOfDeactivation(
form,
possibleSmsRecipients,
).unwrapOr([])
bounceDoc.setNotificationState(emailRecipients, smsRecipients)

const shouldDeactivate = bounceDoc.areAllPermanentBounces()
if (shouldDeactivate) {
await FormService.deactivateForm(bounceDoc.formId)
await BounceService.notifyAdminsOfDeactivation(
form,
possibleSmsRecipients,
)
}

// Important log message for user follow-ups
BounceService.logCriticalBounce({
bounceDoc,
notification,
autoEmailRecipients: emailRecipients,
autoSmsRecipients: smsRecipients,
hasDeactivated: shouldDeactivate,
})
)
}

return BounceService.saveBounceDoc(bounceDoc)
.map(() => res.sendStatus(StatusCodes.OK))
.mapErr((error) => {
// Accept the risk that there might be concurrency problems
// when multiple server instances try to access the same
// document, due to notifications arriving asynchronously.
if (error instanceof DatabaseConflictError)
return res.sendStatus(StatusCodes.OK)
// Otherwise internal database error
return res.sendStatus(StatusCodes.INTERNAL_SERVER_ERROR)
})
// Important log message for user follow-ups
BounceService.logCriticalBounce({
bounceDoc,
notification,
autoEmailRecipients: emailRecipients,
autoSmsRecipients: smsRecipients,
hasDeactivated: shouldDeactivate,
})
}

return BounceService.saveBounceDoc(bounceDoc)
.map(() => res.sendStatus(StatusCodes.OK))
.mapErr((error) => {
// Accept the risk that there might be concurrency problems
// when multiple server instances try to access the same
// document, due to notifications arriving asynchronously.
if (error instanceof DatabaseConflictError)
return res.sendStatus(StatusCodes.OK)
// Otherwise internal database error
return res.sendStatus(StatusCodes.INTERNAL_SERVER_ERROR)
})
}
17 changes: 9 additions & 8 deletions src/app/utils/field-validation/validators/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import { ProcessedSingleAnswerResponse } from '../../../modules/submission/submi
/**
* A function which returns a validator to check if single answer has a non-empty response
*/
export const notEmptySingleAnswerResponse: ResponseValidator<ProcessedSingleAnswerResponse> =
(response) => {
if (response.answer.trim().length === 0)
return left(
'CommonValidator.notEmptySingleAnswerResponse:\tanswer is an empty string',
)
return right(response)
}
export const notEmptySingleAnswerResponse: ResponseValidator<
ProcessedSingleAnswerResponse
> = (response) => {
if (response.answer.trim().length === 0)
return left(
'CommonValidator.notEmptySingleAnswerResponse:\tanswer is an empty string',
)
return right(response)
}

/**
* A function which returns a signature validator constructor for mobile and email verified field.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@
<button
ng-disabled="!vm.contact.number || vm.vfnState !==
vm.VERIFY_STATE.IDLE || vm.contact.isFetching"
class="
ecm__vfn-button ecm__button
vfn-btn
btn-custom btn-large
field-group
"
class="ecm__vfn-button ecm__button vfn-btn btn-custom btn-large field-group"
ng-class="vm.vfnState === vm.VERIFY_STATE.SUCCESS ?
'ecm__vfn-button--success' : ''"
ng-click="vm.vfnState !== vm.VERIFY_STATE.SUCCESS && vm.sendOtp()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@
</div>
</div>
<div
class="
logic-panel-section logic-panel-outcomes
outcome-prevent-submit
"
class="logic-panel-section logic-panel-outcomes outcome-prevent-submit"
ng-if="logic.logicType === vm.LogicType.PreventSubmit"
>
<div class="if-then-text then-show">THEN DISABLE FORM</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
<div class="row" id="email-row">
<label
for="settings-email"
class="
label-custom label-medium label-bottom-with-link
col-sm-7 col-xs-12
"
class="label-custom label-medium label-bottom-with-link col-sm-7 col-xs-12"
>
Emails where responses will be sent
<i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
>
<i class="bx bxs-user-plus bx-lg hidden-xs"></i>
<i
class="
bx
bxs-user-plus
bx-md
hidden-sm hidden-md hidden-lg hidden-xl
"
class="bx bxs-user-plus bx-md hidden-sm hidden-md hidden-lg hidden-xl"
></i>
</button>
<avatar-dropdown-component></avatar-dropdown-component>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,7 @@
<span class="pull-left current-role-text">{{ ROLES.ADMIN }}</span>
</div>
<div
class="
col-xs-2 col-xs-offset-5 col-sm-1 col-sm-offset-0
remove-right-padding
"
class="col-xs-2 col-xs-offset-5 col-sm-1 col-sm-offset-0 remove-right-padding"
></div>
</div>
<div class="collab-hr"></div>
Expand Down Expand Up @@ -316,10 +313,7 @@
</div>
</div>
<div
class="
col-xs-2 col-xs-offset-5 col-sm-1 col-sm-offset-0
remove-right-padding
"
class="col-xs-2 col-xs-offset-5 col-sm-1 col-sm-offset-0 remove-right-padding"
>
<button
class="btn-delete"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,7 @@ <h2 class="modal-title">Edit Thank You</h2>
</div>

<div
class="
preview-page-panel
col-md-7
hidden-sm hidden-xs
container
no-padding
"
class="preview-page-panel col-md-7 hidden-sm hidden-xs container no-padding"
>
<form class="public-form">
<end-page-component
Expand Down
Loading

0 comments on commit bf26ff4

Please sign in to comment.