1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-06-30 06:30:11 +02:00

feat: add support for different email and user

This commit is contained in:
Elias Schneider 2022-12-08 20:00:04 +01:00
parent bfb0d151ea
commit 888a0c5faf
2 changed files with 28 additions and 4 deletions

View File

@ -74,7 +74,13 @@ const configVariables: Prisma.ConfigCreateInput[] = [
},
{
key: "SMTP_EMAIL",
description: "Email address of the SMTP server",
description: "Email address which the emails get sent from",
type: "string",
value: "",
},
{
key: "SMTP_USERNAME",
description: "Username of the SMTP server",
type: "string",
value: "",
},
@ -103,14 +109,32 @@ async function main() {
}
}
// Delete the config variable if it doesn't exist anymore
const configVariablesFromDatabase = await prisma.config.findMany();
// Delete the config variable if it doesn't exist anymore
for (const configVariableFromDatabase of configVariablesFromDatabase) {
if (!configVariables.find((v) => v.key == configVariableFromDatabase.key)) {
const configVariable = configVariables.find(
(v) => v.key == configVariableFromDatabase.key
);
if (!configVariable) {
await prisma.config.delete({
where: { key: configVariableFromDatabase.key },
});
// Update the config variable if the metadata changed
} else if (
JSON.stringify({
key: configVariableFromDatabase.key,
value: configVariableFromDatabase.value,
...configVariable,
}) != JSON.stringify(configVariableFromDatabase)
) {
await prisma.config.update({
where: { key: configVariableFromDatabase.key },
data: configVariables.find(
(v) => v.key == configVariableFromDatabase.key
),
});
}
}
}

View File

@ -14,7 +14,7 @@ export class EmailService {
port: parseInt(this.config.get("SMTP_PORT")),
secure: parseInt(this.config.get("SMTP_PORT")) == 465,
auth: {
user: this.config.get("SMTP_EMAIL"),
user: this.config.get("SMTP_USERNAME"),
pass: this.config.get("SMTP_PASSWORD"),
},
});