Skip to content

Commit

Permalink
Merge pull request #377 from aXenDeveloper/fix/mail_config
Browse files Browse the repository at this point in the history
fix(mail): Create empty config mail when doesn't exists
  • Loading branch information
aXenDeveloper authored Jun 11, 2024
2 parents b2658bd + b39f574 commit c68605a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
13 changes: 13 additions & 0 deletions backend/src/plugins/core/admin/email/mail.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ export class MailService {
private readonly transporter: nodemailer.Transporter;

constructor() {
if (!fs.existsSync(this.path)) {
// Create a default config file
fs.writeFileSync(
this.path,
JSON.stringify({
smtp_host: "",
smtp_user: "",
smtp_secure: false,
smtp_port: 587
})
);
}

const data = fs.readFileSync(this.path, "utf-8");
const config: ShowAdminEmailSettingsServiceObjWithPassword =
JSON.parse(data);
Expand Down
10 changes: 0 additions & 10 deletions backend/src/plugins/core/admin/email/settings/show/show.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ export class ShowAdminEmailSettingsService extends HelpersAdminEmailSettingsServ
settings: { email: emailSettings }
} = getConfigFile();

if (!fs.existsSync(this.path)) {
return {
smtp_host: "",
smtp_user: "",
smtp_secure: false,
smtp_port: 587,
...emailSettings
};
}

const read = fs.readFileSync(this.path, "utf-8");
const config: ShowAdminEmailSettingsServiceObj = JSON.parse(read);

Expand Down

0 comments on commit c68605a

Please sign in to comment.