-
Notifications
You must be signed in to change notification settings - Fork 3
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
[#IP-284] add timestamp check on profile for is_email_enabled #174
[#IP-284] add timestamp check on profile for is_email_enabled #174
Conversation
Example of PR titles that include pivotal stories:
Generated by 🚫 dangerJS |
GetProfile/handler.ts
Outdated
@@ -21,6 +21,7 @@ import { | |||
} from "@pagopa/ts-commons/lib/responses"; | |||
import { FiscalCode } from "@pagopa/ts-commons/lib/strings"; | |||
|
|||
import * as date_fns from "date-fns"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we import only isBefore
method?
import * as date_fns from "date-fns"; | |
import { isBefore } from "date-fns"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ee889ae
@@ -76,6 +77,8 @@ export const IConfig = t.intersection([ | |||
SPID_LOGS_PUBLIC_KEY: NonEmptyString, | |||
SUBSCRIPTIONS_FEED_TABLE: NonEmptyString, | |||
|
|||
EMAIL_MODE_SWITCH_LIMIT_DATE: UTCISODateFromString, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question. Is this variable required for some reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed with default value in ee889ae
Co-authored-by: Daniele Manni <BurnedMarshal@users.noreply.github.com>
utils/config.ts
Outdated
// No need to re-evaluate this object for each call | ||
const errorOrConfig: t.Validation<IConfig> = IConfig.decode({ | ||
...process.env, | ||
EMAIL_MODE_SWITCH_LIMIT_DATE: fromNullableE( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value should be a string because here we apply the decoder IConfig and
UTCISODateFromString requires a string as input.
utils/config.ts
Outdated
EMAIL_MODE_SWITCH_LIMIT_DATE: fromNullableE( | ||
DEFAULT_EMAIL_MODE_SWITCH_LIMIT_DATE | ||
)(process.env.EMAIL_MODE_SWITCH_LIMIT_DATE) | ||
.chain(_ => | ||
UTCISODateFromString.decode(_).mapLeft( | ||
() => DEFAULT_EMAIL_MODE_SWITCH_LIMIT_DATE | ||
) | ||
) | ||
.fold(_ => new Date(_), identity), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EMAIL_MODE_SWITCH_LIMIT_DATE: fromNullableE( | |
DEFAULT_EMAIL_MODE_SWITCH_LIMIT_DATE | |
)(process.env.EMAIL_MODE_SWITCH_LIMIT_DATE) | |
.chain(_ => | |
UTCISODateFromString.decode(_).mapLeft( | |
() => DEFAULT_EMAIL_MODE_SWITCH_LIMIT_DATE | |
) | |
) | |
.fold(_ => new Date(_), identity), | |
EMAIL_MODE_SWITCH_LIMIT_DATE: fromNullable(process.env.EMAIL_MODE_SWITCH_LIMIT_DATE) | |
.getOrElse(DEFAULT_EMAIL_MODE_SWITCH_LIMIT_DATE), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
List of Changes
EMAIL_MODE_SWITCH_LIMIT_DATE
in config propertiesGetProfile
returns isEmailEnabled set to false if profile timestamp is before a specific limit date (see previous bullet), otherwise return the value stored on cosmosdbStoreSpidLogs
function for better unit testingMotivation and Context
We want that a citizen with an old profile, or even a profile that was upserted before the release limit date, has email notification turned off for default
How Has This Been Tested?
It has been tested by performing:
Types of changes