1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
This commit is contained in:
Patrik J. Braun 2023-07-30 17:37:54 +02:00
parent f007037bc5
commit b8f9dbe55f
2 changed files with 14 additions and 9 deletions

View File

@ -85,7 +85,7 @@ export class ConfigDiagnostics {
private static async testEmailMessagingConfig(Messaging: MessagingConfig, config: PrivateConfigClass): Promise<void> {
Logger.debug(LOG_TAG, 'Testing EmailMessaging config');
if (Messaging.Email.type === EmailMessagingType.sendmail && !Config.Environment.sendMailAvailable) {
if (Messaging.Email.type === EmailMessagingType.sendmail && ServerEnvironment.sendMailAvailable === false) {
throw new Error('sendmail e-mail sending method is not supported as the sendmail application cannot be found in the OS.');
}
}
@ -306,12 +306,12 @@ export class ConfigDiagnostics {
sendmail: true,
});
try {
Config.Environment.sendMailAvailable = await transporter.verify();
ServerEnvironment.sendMailAvailable = await transporter.verify();
} catch (e) {
Config.Environment.sendMailAvailable = false;
ServerEnvironment.sendMailAvailable = false;
}
ServerEnvironment.sendMailAvailable = Config.Environment.sendMailAvailable;
if (!Config.Environment.sendMailAvailable) {
Config.Environment.sendMailAvailable = ServerEnvironment.sendMailAvailable;
if (!ServerEnvironment.sendMailAvailable) {
Config.Messaging.Email.type = EmailMessagingType.SMTP;
Logger.info(LOG_TAG, 'Sendmail is not available on the OS. You will need to use an SMTP server if you wish the app to send mails.');
}

View File

@ -55,7 +55,7 @@ describe('Settings middleware', () => {
it('should save enforced users settings', (done: (err?: any) => void) => {
ServerEnvironment.sendMailAvailable = false;
Config.Environment.sendMailAvailable = false
Config.Environment.sendMailAvailable = false;
Config.Messaging.Email.type = EmailMessagingType.sendmail;
const req: any = {
session: {},
@ -80,9 +80,14 @@ describe('Settings middleware', () => {
expect(Config.Users.enforcedUsers[0].name).to.be.equal('Apple');
expect(Config.Users.enforcedUsers.length).to.be.equal(1);
Config.original().then((cfg) => {
expect(cfg.Users.enforcedUsers.length).to.be.equal(1);
expect(cfg.Users.enforcedUsers[0].name).to.be.equal('Apple');
done();
try {
expect(cfg.Users.enforcedUsers.length).to.be.equal(1);
expect(cfg.Users.enforcedUsers[0].name).to.be.equal('Apple');
done();
} catch (err) {
console.error(err);
done(err);
}
}).catch(done);
} catch (err) {
console.error(err);