Skip to content

Conversation

@nshirley
Copy link
Contributor

Because

This pull request

Issue that this pull request solves

Closes: (issue number)

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

Any other information that is important to this pull request.

constructor(
private emailSender: sender.EmailSender,
private linkBuilder: renderer.EmailLinkBuilder,
private mailerConfig: ConfigType['smtp'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably want mozlog and/or statsd here too, right?

>;
};

type PasswordForgotOtpEmailInput = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I really don't love these. BUT it does make sure we maintain strong typing. Since each email just has unique data they need we kind of have to do this. Any other ideas?

* @param date - Date to format (defaults to now)
* @param formatString - Moment.js format string (defaults to 'L' for localized date)
*/
constructLocalDateString(
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this get used somewhere other than a test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not yet. It's based on the existing _constructLocalDateString in email.js which is used heavily for subplat emails. I can remove it if we don't need it yet though!

primaryEmail?: string;
date?: string;
time?: string;
acceptLanguage?: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

acceptLanguage is a parameter on the renderEmail but I couldn't find any other of the union-ed types that had this. But with this, calling functions could have it strongly typed. This felt like a good place for it

*/
async buildHeaders({
template,
buildHeaders({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were no awaited calls so it doesn't need to be async

deviceId?: string;
flowId?: string;
flowBeginTime?: number;
layoutTemplateValues?: Partial<Omit<renderer.TemplateData, 'privacyUrl'>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's a partial, why have an ommit?

flowId?: string;
flowBeginTime?: number;
layoutTemplateValues?: Partial<Omit<renderer.TemplateData, 'privacyUrl'>>;
templateValues: Omit<
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have these omits?

Copy link
Contributor

@dschom dschom left a comment

Choose a reason for hiding this comment

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

Just leaving some intermediate feedback. Looks great. I think there is probably a little clean up to do so we get a nicer type definition for the PasswordForgotOtpEmailInput.

opts.templateValues.timeZone,
opts.templateValues.acceptLanguage
);

Copy link
Contributor

Choose a reason for hiding this comment

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

Just kind of thinking out loud, but maybe the link build should part of the renderPasswordForgotOtp method. It seems like generating the link is part of the rendering the template to me. This also means that we wouldn't need those 'omits' on the type above you were questioning, since that data could be determined interally.

Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants