Open ojeytonwilliams opened 1 year ago
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?
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
bloats the resolver logic. If it read like this
emailTemplates.sendInstanceRoleChanged({ name: user.name, newRole })
it would be a lot cleaner.
This issue seems to have been merged under above PR #2319 We ok to close this?
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?
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.