mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-15 01:14:27 -05:00
fix: hide and disallow email recipients if disabled
This commit is contained in:
parent
32ad43ae27
commit
34db3ae2a9
4 changed files with 38 additions and 28 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { Injectable } from "@nestjs/common";
|
import { Injectable, InternalServerErrorException } from "@nestjs/common";
|
||||||
import { ConfigService } from "@nestjs/config";
|
import { ConfigService } from "@nestjs/config";
|
||||||
import { User } from "@prisma/client";
|
import { User } from "@prisma/client";
|
||||||
import * as nodemailer from "nodemailer";
|
import * as nodemailer from "nodemailer";
|
||||||
|
@ -19,6 +19,9 @@ export class EmailService {
|
||||||
});
|
});
|
||||||
|
|
||||||
async sendMail(recipientEmail: string, shareId: string, creator: User) {
|
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 shareUrl = `${this.config.get("APP_URL")}/share/${shareId}`;
|
||||||
const creatorIdentifier =
|
const creatorIdentifier =
|
||||||
creator.firstName && creator.lastName
|
creator.firstName && creator.lastName
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
SHOW_HOME_PAGE=true
|
SHOW_HOME_PAGE=true
|
||||||
ALLOW_REGISTRATION=true
|
ALLOW_REGISTRATION=true
|
||||||
MAX_FILE_SIZE=1000000000
|
MAX_FILE_SIZE=1000000000
|
||||||
ALLOW_UNAUTHENTICATED_SHARES=false
|
ALLOW_UNAUTHENTICATED_SHARES=false
|
||||||
|
EMAIL_RECIPIENTS_ENABLED=false
|
|
@ -5,7 +5,8 @@ const nextConfig = {
|
||||||
ALLOW_REGISTRATION: process.env.ALLOW_REGISTRATION,
|
ALLOW_REGISTRATION: process.env.ALLOW_REGISTRATION,
|
||||||
SHOW_HOME_PAGE: process.env.SHOW_HOME_PAGE,
|
SHOW_HOME_PAGE: process.env.SHOW_HOME_PAGE,
|
||||||
MAX_FILE_SIZE: process.env.MAX_FILE_SIZE,
|
MAX_FILE_SIZE: process.env.MAX_FILE_SIZE,
|
||||||
ALLOW_UNAUTHENTICATED_SHARES: process.env.ALLOW_UNAUTHENTICATED_SHARES
|
ALLOW_UNAUTHENTICATED_SHARES: process.env.ALLOW_UNAUTHENTICATED_SHARES,
|
||||||
|
EMAIL_RECIPIENTS_ENABLED: process.env.EMAIL_RECIPIENTS_ENABLED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,31 +225,36 @@ const CreateUploadModalBody = ({
|
||||||
{ExpirationPreview({ form })}
|
{ExpirationPreview({ form })}
|
||||||
</Text>
|
</Text>
|
||||||
<Accordion>
|
<Accordion>
|
||||||
<Accordion.Item value="recipients" sx={{ borderBottom: "none" }}>
|
{publicRuntimeConfig.EMAIL_RECIPIENTS_ENABLED == "true" && (
|
||||||
<Accordion.Control>Email recipients</Accordion.Control>
|
<Accordion.Item value="recipients" sx={{ borderBottom: "none" }}>
|
||||||
<Accordion.Panel>
|
<Accordion.Control>Email recipients</Accordion.Control>
|
||||||
<MultiSelect
|
<Accordion.Panel>
|
||||||
data={form.values.recipients}
|
<MultiSelect
|
||||||
placeholder="Enter email recipients"
|
data={form.values.recipients}
|
||||||
searchable
|
placeholder="Enter email recipients"
|
||||||
{...form.getInputProps("recipients")}
|
searchable
|
||||||
creatable
|
{...form.getInputProps("recipients")}
|
||||||
getCreateLabel={(query) => `+ ${query}`}
|
creatable
|
||||||
onCreate={(query) => {
|
getCreateLabel={(query) => `+ ${query}`}
|
||||||
if (!query.match(/^\S+@\S+\.\S+$/)) {
|
onCreate={(query) => {
|
||||||
form.setFieldError("recipients", "Invalid email address");
|
if (!query.match(/^\S+@\S+\.\S+$/)) {
|
||||||
} else {
|
form.setFieldError(
|
||||||
form.setFieldError("recipients", null);
|
"recipients",
|
||||||
form.setFieldValue("recipients", [
|
"Invalid email address"
|
||||||
...form.values.recipients,
|
);
|
||||||
query,
|
} else {
|
||||||
]);
|
form.setFieldError("recipients", null);
|
||||||
return query;
|
form.setFieldValue("recipients", [
|
||||||
}
|
...form.values.recipients,
|
||||||
}}
|
query,
|
||||||
/>
|
]);
|
||||||
</Accordion.Panel>
|
return query;
|
||||||
</Accordion.Item>
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Accordion.Panel>
|
||||||
|
</Accordion.Item>
|
||||||
|
)}
|
||||||
<Accordion.Item value="security" sx={{ borderBottom: "none" }}>
|
<Accordion.Item value="security" sx={{ borderBottom: "none" }}>
|
||||||
<Accordion.Control>Security options</Accordion.Control>
|
<Accordion.Control>Security options</Accordion.Control>
|
||||||
<Accordion.Panel>
|
<Accordion.Panel>
|
||||||
|
|
Loading…
Add table
Reference in a new issue