refactor: emailer.send and emailer.sendToEmail returns Boolean based on message being successfully sent

Note that of course this doesn't mean the message was _delivered_, just sent off.

This will stop issues where emailer errors crash NodeBB
This commit is contained in:
Julian Lam
2022-01-28 15:01:55 -05:00
parent 680e36da67
commit f0e32ff182
2 changed files with 16 additions and 12 deletions

View File

@@ -45,7 +45,7 @@ describe('emailer', () => {
// TODO: test sendmail here at some point
it('plugin hook should work', (done) => {
it('plugin hook should work', async () => {
const error = new Error();
Plugins.hooks.register('emailer-test', {
@@ -59,12 +59,10 @@ describe('emailer', () => {
},
});
Emailer.sendToEmail(template, email, language, params, (err) => {
assert.equal(err, error);
const success = await Emailer.sendToEmail(template, email, language, params);
assert.strictEqual(success, false);
Plugins.hooks.unregister('emailer-test', 'filter:email.send');
done();
});
Plugins.hooks.unregister('emailer-test', 'filter:email.send');
});
it('should build custom template on config change', (done) => {