Skip to content

Commit

Permalink
[#169703944] Disable email channel if profile email is not validated (#…
Browse files Browse the repository at this point in the history
…26)

* [#169703944] Disable email channel if profile email is not validated

* [#169703944] Update comments
  • Loading branch information
francescopersico authored Nov 12, 2019
1 parent 5ac133e commit d54c299
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CreateNotificationActivity/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ export const getCreateNotificationActivityHandler = (
// in their profile
const isEmailEnabledInProfile = profile.isEmailEnabled;

// Check if the email in the user profile is validated
const isEmailValidatedInProfile = profile.isEmailValidated;

// first we check whether the user has blocked emails notifications for the
// service that is sending the message
const isEmailBlockedForService =
Expand All @@ -172,12 +175,14 @@ export const getCreateNotificationActivityHandler = (
// we send an email notification when all the following conditions are met:
//
// * email notifications are enabled in the user profile (isEmailEnabledInProfile)
// * email is validated in the user profile (isEmailValidatedInProfile)
// * email notifications are not blocked for the sender service (!isEmailBlockedForService)
// * the sender service allows email channel
// * a destination email address is configured (maybeEmailFromProfile)
//
const maybeEmailNotificationAddress =
isEmailEnabledInProfile &&
isEmailValidatedInProfile &&
!isEmailBlockedForService &&
isEmailChannelAllowed
? maybeEmailFromProfile
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"express": "^4.15.3",
"fp-ts": "1.12.0",
"html-to-text": "^4.0.0",
"io-functions-commons": "^1.1.0",
"io-functions-commons": "^1.5.0",
"io-functions-express": "^0.1.0",
"io-ts": "1.8.5",
"italia-ts-commons": "^5.1.5",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2706,10 +2706,10 @@ invert-kv@^2.0.0:
resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02"
integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==

io-functions-commons@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/io-functions-commons/-/io-functions-commons-1.1.0.tgz#0d5eb093700c9d8f8d4799cfb4afdac5e3782ba9"
integrity sha512-cngfKMqsUFNHA2JUde/HERAcLo6Cm9SqgvnebFQGCLAQbB0UVQ8NV02Z+L8MNAoOFrB9ZXwy31rOqNcPzZ0Q5w==
io-functions-commons@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/io-functions-commons/-/io-functions-commons-1.5.0.tgz#eb69f7756f35b4fd8ccee4e3e64c87bae29bf92d"
integrity sha512-bVESsh8hSnHMRZTrLtE78cFkm8Q1hu0YUcZJyNORK1ltedn1sDTIxi7/AeHYSMQXbz2DAOfEuy5/pRtsVlTC4g==
dependencies:
applicationinsights "^1.0.3"
azure-storage "^2.10.3"
Expand Down

0 comments on commit d54c299

Please sign in to comment.