fix: hide and disallow email recipients if disabled

This commit is contained in:
Elias Schneider
2022-11-11 19:03:08 +01:00
parent 32ad43ae27
commit 34db3ae2a9
4 changed files with 38 additions and 28 deletions

View File

@@ -1,4 +1,4 @@
import { Injectable } from "@nestjs/common";
import { Injectable, InternalServerErrorException } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { User } from "@prisma/client";
import * as nodemailer from "nodemailer";
@@ -19,6 +19,9 @@ export class EmailService {
});
async sendMail(recipientEmail: string, shareId: string, creator: User) {
if (this.config.get("EMAIL_RECIPIENTS_ENABLED") == "false")
throw new InternalServerErrorException("Email service disabled");
const shareUrl = `${this.config.get("APP_URL")}/share/${shareId}`;
const creatorIdentifier =
creator.firstName && creator.lastName