disable mail when not available

This commit is contained in:
split / May 2024-05-23 18:23:13 +00:00 committed by GitHub
parent 82f3c31df2
commit 87c7b3295c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -20,7 +20,9 @@ const transport = createTransport({
* @param content Email content
* @returns Promise which resolves to the output from nodemailer.transport.sendMail
*/
export function sendMail(to: string, subject: string, content: string) {
export async function sendMail(to: string, subject: string, content: string) {
if (!config.mail.enabled) return false
return transport.sendMail({
to,
subject,

View file

@ -93,6 +93,8 @@ const validators: {
requireProofOfIdentity: true,
validator: (actor, target, params, ctx) => {
if (!Configuration.mail.enabled) return [501, "email not enabled on instance"]
if (!params.email) {
if (target.email) {
sendMail(