mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-02-19 01:55:48 -05:00
fix: email configuration updated without restart
This commit is contained in:
parent
faea1abcc4
commit
11174656e4
2 changed files with 14 additions and 12 deletions
|
@ -7,15 +7,17 @@ import { ConfigService } from "src/config/config.service";
|
||||||
export class EmailService {
|
export class EmailService {
|
||||||
constructor(private config: ConfigService) {}
|
constructor(private config: ConfigService) {}
|
||||||
|
|
||||||
transporter = nodemailer.createTransport({
|
getTransporter() {
|
||||||
host: this.config.get("SMTP_HOST"),
|
return nodemailer.createTransport({
|
||||||
port: parseInt(this.config.get("SMTP_PORT")),
|
host: this.config.get("SMTP_HOST"),
|
||||||
secure: parseInt(this.config.get("SMTP_PORT")) == 465,
|
port: parseInt(this.config.get("SMTP_PORT")),
|
||||||
auth: {
|
secure: parseInt(this.config.get("SMTP_PORT")) == 465,
|
||||||
user: this.config.get("SMTP_USERNAME"),
|
auth: {
|
||||||
pass: this.config.get("SMTP_PASSWORD"),
|
user: this.config.get("SMTP_USERNAME"),
|
||||||
},
|
pass: this.config.get("SMTP_PASSWORD"),
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async sendMail(recipientEmail: string, shareId: string, creator: User) {
|
async sendMail(recipientEmail: string, shareId: string, creator: User) {
|
||||||
if (!this.config.get("ENABLE_EMAIL_RECIPIENTS"))
|
if (!this.config.get("ENABLE_EMAIL_RECIPIENTS"))
|
||||||
|
@ -23,7 +25,7 @@ export class EmailService {
|
||||||
|
|
||||||
const shareUrl = `${this.config.get("APP_URL")}/share/${shareId}`;
|
const shareUrl = `${this.config.get("APP_URL")}/share/${shareId}`;
|
||||||
|
|
||||||
await this.transporter.sendMail({
|
await this.getTransporter().sendMail({
|
||||||
from: `"Pingvin Share" <${this.config.get("SMTP_EMAIL")}>`,
|
from: `"Pingvin Share" <${this.config.get("SMTP_EMAIL")}>`,
|
||||||
to: recipientEmail,
|
to: recipientEmail,
|
||||||
subject: this.config.get("EMAIL_SUBJECT"),
|
subject: this.config.get("EMAIL_SUBJECT"),
|
||||||
|
@ -36,7 +38,7 @@ export class EmailService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendTestMail(recipientEmail: string) {
|
async sendTestMail(recipientEmail: string) {
|
||||||
await this.transporter.sendMail({
|
await this.getTransporter().sendMail({
|
||||||
from: `"Pingvin Share" <${this.config.get("SMTP_EMAIL")}>`,
|
from: `"Pingvin Share" <${this.config.get("SMTP_EMAIL")}>`,
|
||||||
to: recipientEmail,
|
to: recipientEmail,
|
||||||
subject: "Test email",
|
subject: "Test email",
|
||||||
|
|
|
@ -36,8 +36,8 @@ const AdminConfigInput = ({
|
||||||
(configVariable.obscured ? (
|
(configVariable.obscured ? (
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
onChange={(e) => onValueChange(configVariable, e.target.value)}
|
|
||||||
{...form.getInputProps("stringValue")}
|
{...form.getInputProps("stringValue")}
|
||||||
|
onChange={(e) => onValueChange(configVariable, e.target.value)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<TextInput
|
<TextInput
|
||||||
|
|
Loading…
Add table
Reference in a new issue