Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#169703944] check isEmailValidated / isEmailEnabled flags before sending email #32

Merged
merged 1 commit into from
Mar 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions CreateNotificationActivity/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,12 @@ export const getCreateNotificationActivityHandler = (

// whether email notifications are enabled in this user profile - this is
// true by default, it's false only for users that have isEmailEnabled = false
// in their profile
const isEmailEnabledInProfile = profile.isEmailEnabled;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false when undefined

// in their profile. We assume it's true when not defined in user's profile.
const isEmailEnabledInProfile = profile.isEmailEnabled !== false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true when undefined


// Check if the email in the user profile is validated.
// we assume it's true when not defined in user's profile.
const isEmailValidatedInProfile = profile.isEmailValidated !== false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gunzip Could you confirm the field isEmailValidated is set to false on CIE first authentication?
Because this assumption is valid only for SPID users

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fix regards existing (SPID) users that never had this field set up (so it's undefined in their profile)


// first we check whether the user has blocked emails notifications for the
// service that is sending the message
Expand All @@ -172,12 +176,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