1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-30 10:36:35 +02:00

Server: Fixed mail queue as some emails were not being processed

This commit is contained in:
Laurent Cozic 2021-07-11 18:03:44 +01:00
parent a4255bb8fe
commit 89f4ca14e8
2 changed files with 6 additions and 5 deletions

View File

@ -22,8 +22,9 @@ export default class EmailModel extends BaseModel<Email> {
}
public async push(email: EmailToSend) {
EmailModel.eventEmitter.emit('saved');
return super.save({ ...email });
const output = await super.save({ ...email });
EmailModel.eventEmitter.emit('queued');
return output;
}
public async needToBeSent(): Promise<Email[]> {

View File

@ -1,11 +1,11 @@
import Logger from '@joplin/lib/Logger';
import UserModel from '../models/UserModel';
import BaseService from './BaseService';
import Mail = require('nodemailer/lib/mailer');
import { createTransport } from 'nodemailer';
import { Email, EmailSender } from '../db';
import { errorToString } from '../utils/errors';
import MarkdownIt = require('markdown-it');
import EmailModel from '../models/EmailModel';
const logger = Logger.create('EmailService');
@ -128,8 +128,8 @@ export default class EmailService extends BaseService {
return;
}
UserModel.eventEmitter.on('created', () => {
logger.info('User was created - scheduling maintenance');
EmailModel.eventEmitter.on('queued', () => {
logger.info('Email was queued - scheduling maintenance');
void this.scheduleMaintenance();
});