Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.
This repository was archived by the owner on Sep 25, 2025. It is now read-only.

Consolidate email templates #2071

Open
Open

Description

@ojeytonwilliams

Currently the text of the emails that Chapter sends is embedded directly in the controllers. If we move them into their own file this both removes clutter from the controllers and makes it easier to audit the text and ensure that it has a consistent voice.

server/src/email-templates.ts seems like a good enough place for these helper functions for now.

Activity

  1. added
    Help Wanted
    Good First Issue
    on Dec 8, 2022
  2. UrielOfir commented on Jan 7, 2023

    @UrielOfir

    Hi :)
    I would like to assign myself for this issue.
    I didn't understand what did you mean that "emails sending is embedded directly in the controllers".
    Did you mean to the code in this file-
    https://github.com/freeCodeCamp/chapter/blob/08cb5b009187e7ce7530350365b881c37daa8c3e/server/src/controllers/Users/resolver.ts
    line 60?

  3. ojeytonwilliams commented on Jan 9, 2023

    @ojeytonwilliams
    ContributorAuthor

    Hi @UrielOfir. What I was trying to say was that we should not put the email content directly in the resolvers that handle the user's request. For example

    const emailSubject = `Instance role changed`;
    const emailContent = `Hello, ${user.name}.<br />
    Your instance role has been changed to ${newRole}.`;
    await mailerService.sendEmail({
    emailList: [user.email],
    subject: emailSubject,
    htmlEmail: emailContent,
    });

    bloats the resolver logic. If it read like this

        emailTemplates.sendInstanceRoleChanged({ name: user.name, newRole })

    it would be a lot cleaner.

  4. Chirag2193 commented on Apr 30, 2023

    @Chirag2193
    Contributor

    This issue seems to have been merged under above PR #2319
    We ok to close this?

  5. allella commented on Apr 30, 2023

    @allella
    Contributor

    It looks like the constants were moved out of the revolvers in PR #2319, but @ojeytonwilliams 's example above seemed to go further by moving the mailerService.sendEmail out of the resolver.

    Oliver, is there more to go done here?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIEmailGood First IssueHelp Wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions