From d54c299312da67df33185ed8e0700f9c60dbe0c2 Mon Sep 17 00:00:00 2001 From: Francesco Persico Date: Tue, 12 Nov 2019 14:52:57 +0100 Subject: [PATCH] [#169703944] Disable email channel if profile email is not validated (#26) * [#169703944] Disable email channel if profile email is not validated * [#169703944] Update comments --- CreateNotificationActivity/handler.ts | 5 +++++ package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CreateNotificationActivity/handler.ts b/CreateNotificationActivity/handler.ts index 605feaaa..9013e59d 100644 --- a/CreateNotificationActivity/handler.ts +++ b/CreateNotificationActivity/handler.ts @@ -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 = @@ -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 diff --git a/package.json b/package.json index c7564368..b8b48f17 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index ace2f528..cbdd3a1a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"