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

Feature/send notification #384

Merged
merged 17 commits into from
Apr 3, 2024
Merged

Feature/send notification #384

merged 17 commits into from
Apr 3, 2024

Conversation

cephaschapa
Copy link
Contributor

Changes

  • Adds notification template
  • Sends a notification to admins when a user uploads files

@cephaschapa cephaschapa requested a review from lemilonkh March 18, 2024 09:42
@evanp
Copy link
Contributor

evanp commented Apr 2, 2024

It doesn't look like the requested changes were made. @cephaschapa ?

Copy link
Contributor

@lemilonkh lemilonkh left a comment

Choose a reason for hiding this comment

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

PR feedback will be handled in a follow-up ticket/ PR.

};
const host = process.env.HOST ?? "http://localhost:3000";

const emailTemplate = `
Copy link
Contributor

Choose a reason for hiding this comment

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

Create mock for the send email functionality

Copy link
Contributor

Choose a reason for hiding this comment

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

Render template using React-Email again and move this to NotificationService.


`;

if (process.env.NODE_ENV !== "test") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Mock this so you don't need to check here

@@ -58,6 +62,19 @@ export const GET = apiHandler(async (_req: Request, context) => {

export const POST = apiHandler(async (req: NextRequest, context) => {
const userId = context.session?.user.id;
const service = new NotificationService();
Copy link
Contributor

Choose a reason for hiding this comment

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

Use static methods and don't create an instance of NotificationService here.

Comment on lines +18 to +21
private transporter: Transporter;
constructor() {
this.transporter = nodemailer.createTransport({ ...smtpOptions });
}
Copy link
Contributor

Choose a reason for hiding this comment

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

No state in service. Create this in sendEmail or create static helper method in NotificationService.

this.transporter = nodemailer.createTransport({ ...smtpOptions });
}

async sendEmail({
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be static so it can be called like this: await NotificationService.sendEmail(...);

Also this should handle template rendering with react-email.

@lemilonkh lemilonkh merged commit 5801bf9 into develop Apr 3, 2024
3 checks passed
@lemilonkh lemilonkh deleted the feature/send-notification branch April 3, 2024 15:48
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