mirror of
https://github.com/stonith404/pingvin-share.git
synced 2024-10-02 09:30:10 +02:00
feat: custom email message
This commit is contained in:
parent
bfb47ba6e8
commit
0616a68bd2
@ -60,6 +60,12 @@ const configVariables: Prisma.ConfigCreateInput[] = [
|
|||||||
value: "false",
|
value: "false",
|
||||||
secret: false,
|
secret: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "EMAIL_MESSAGE",
|
||||||
|
description: "Message which gets sent to the recipients. {creator} and {shareUrl} will be replaced with the creator's name and the share URL.",
|
||||||
|
type: "text",
|
||||||
|
value: "Hey!\n{creator} shared some files with you. View or download the files with this link: {shareUrl}\nShared securely with Pingvin Share 🐧",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "SMTP_HOST",
|
key: "SMTP_HOST",
|
||||||
description: "Host of the SMTP server",
|
description: "Host of the SMTP server",
|
||||||
|
@ -23,7 +23,8 @@ export class ConfigService {
|
|||||||
|
|
||||||
if (configVariable.type == "number") return parseInt(configVariable.value);
|
if (configVariable.type == "number") return parseInt(configVariable.value);
|
||||||
if (configVariable.type == "boolean") return configVariable.value == "true";
|
if (configVariable.type == "boolean") return configVariable.value == "true";
|
||||||
if (configVariable.type == "string") return configVariable.value;
|
if (configVariable.type == "string" || configVariable.type == "text")
|
||||||
|
return configVariable.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
async listForAdmin() {
|
async listForAdmin() {
|
||||||
@ -46,10 +47,15 @@ export class ConfigService {
|
|||||||
if (!configVariable || configVariable.locked)
|
if (!configVariable || configVariable.locked)
|
||||||
throw new NotFoundException("Config variable not found");
|
throw new NotFoundException("Config variable not found");
|
||||||
|
|
||||||
if (typeof value != configVariable.type)
|
if (
|
||||||
|
typeof value != configVariable.type &&
|
||||||
|
typeof value == "string" &&
|
||||||
|
configVariable.type != "text"
|
||||||
|
) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
`Config variable must be of type ${configVariable.type}`
|
`Config variable must be of type ${configVariable.type}`
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const updatedVariable = await this.prisma.config.update({
|
const updatedVariable = await this.prisma.config.update({
|
||||||
where: { key },
|
where: { key },
|
||||||
|
@ -28,7 +28,11 @@ export class EmailService {
|
|||||||
from: `"Pingvin Share" <${this.config.get("SMTP_EMAIL")}>`,
|
from: `"Pingvin Share" <${this.config.get("SMTP_EMAIL")}>`,
|
||||||
to: recipientEmail,
|
to: recipientEmail,
|
||||||
subject: "Files shared with you",
|
subject: "Files shared with you",
|
||||||
text: `Hey!\n${creator.username} shared some files with you. View or dowload the files with this link: ${shareUrl}\nShared securely with Pingvin Share 🐧`,
|
text: this.config
|
||||||
|
.get("EMAIL_MESSAGE")
|
||||||
|
.replaceAll("\\n", "\n")
|
||||||
|
.replaceAll("{creator}", creator.username)
|
||||||
|
.replaceAll("{shareUrl}", shareUrl),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,9 +73,18 @@ const AdminConfigTable = () => {
|
|||||||
</Text>
|
</Text>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{configVariable.obscured
|
<Text
|
||||||
? "•".repeat(configVariable.value.length)
|
style={{
|
||||||
: configVariable.value}
|
whiteSpace: "nowrap",
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
maxWidth: "40ch",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{configVariable.obscured
|
||||||
|
? "•".repeat(configVariable.value.length)
|
||||||
|
: configVariable.value}
|
||||||
|
</Text>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<Group position="right">
|
<Group position="right">
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
Space,
|
Space,
|
||||||
Stack,
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
|
Textarea,
|
||||||
TextInput,
|
TextInput,
|
||||||
Title,
|
Title,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
@ -45,6 +46,7 @@ const Body = ({
|
|||||||
const form = useForm({
|
const form = useForm({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
stringValue: configVariable.value,
|
stringValue: configVariable.value,
|
||||||
|
textValue: configVariable.value,
|
||||||
numberValue: parseInt(configVariable.value),
|
numberValue: parseInt(configVariable.value),
|
||||||
booleanValue: configVariable.value,
|
booleanValue: configVariable.value,
|
||||||
},
|
},
|
||||||
@ -56,12 +58,16 @@ const Body = ({
|
|||||||
</Text>
|
</Text>
|
||||||
{configVariable.type == "string" &&
|
{configVariable.type == "string" &&
|
||||||
(configVariable.obscured ? (
|
(configVariable.obscured ? (
|
||||||
<PasswordInput label="Value" {...form.getInputProps("stringValue")} />
|
<PasswordInput {...form.getInputProps("stringValue")} />
|
||||||
) : (
|
) : (
|
||||||
<TextInput label="Value" {...form.getInputProps("stringValue")} />
|
<TextInput {...form.getInputProps("stringValue")} />
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
{configVariable.type == "text" && (
|
||||||
|
<Textarea autosize {...form.getInputProps("textValue")} />
|
||||||
|
)}
|
||||||
{configVariable.type == "number" && (
|
{configVariable.type == "number" && (
|
||||||
<NumberInput label="Value" {...form.getInputProps("numberValue")} />
|
<NumberInput {...form.getInputProps("numberValue")} />
|
||||||
)}
|
)}
|
||||||
{configVariable.type == "boolean" && (
|
{configVariable.type == "boolean" && (
|
||||||
<Select
|
<Select
|
||||||
@ -78,6 +84,8 @@ const Body = ({
|
|||||||
const value =
|
const value =
|
||||||
configVariable.type == "string"
|
configVariable.type == "string"
|
||||||
? form.values.stringValue
|
? form.values.stringValue
|
||||||
|
: configVariable.type == "text"
|
||||||
|
? form.values.textValue
|
||||||
: configVariable.type == "number"
|
: configVariable.type == "number"
|
||||||
? form.values.numberValue
|
? form.values.numberValue
|
||||||
: form.values.booleanValue == "true";
|
: form.values.booleanValue == "true";
|
||||||
|
@ -27,7 +27,7 @@ const get = (key: string, configVariables: Config[]): any => {
|
|||||||
|
|
||||||
if (configVariable.type == "number") return parseInt(configVariable.value);
|
if (configVariable.type == "number") return parseInt(configVariable.value);
|
||||||
if (configVariable.type == "boolean") return configVariable.value == "true";
|
if (configVariable.type == "boolean") return configVariable.value == "true";
|
||||||
if (configVariable.type == "string") return configVariable.value;
|
if (configVariable.type == "string" || configVariable.type == "text") return configVariable.value;
|
||||||
};
|
};
|
||||||
|
|
||||||
const finishSetup = async (): Promise<AdminConfig[]> => {
|
const finishSetup = async (): Promise<AdminConfig[]> => {
|
||||||
|
Loading…
Reference in New Issue
Block a user