0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-25 02:31:59 -05:00

Added restriction to not send mail for published posts

no issue
This commit is contained in:
Rish 2019-11-04 16:07:33 +07:00
parent 5b438d3df9
commit 424e3aea7c

View file

@ -1,7 +1,6 @@
const common = require('../lib/common');
const membersService = require('./members');
const bulkEmailService = require('./bulk-email');
const ghostBookshelf = require('../models/base');
const models = require('../models');
const sendEmail = async (post) => {
@ -27,7 +26,13 @@ function listener(model, options) {
return;
}
sendEmail(model.toJSON()).then(() => {
sendEmail(model.toJSON()).then(async () => {
const deliveredEvents = await models.Action.findAll({
filter: `event:delivered+resource_id:${model.id}`
});
if (deliveredEvents && deliveredEvents.toJSON().length > 0) {
return;
}
let actor = {id: null, type: null};
if (options.context && options.context.user) {
actor = {
@ -42,7 +47,7 @@ function listener(model, options) {
actor_id: actor.id,
actor_type: actor.type
};
models.Action.add(action, {context: {internal: true}});
return models.Action.add(action, {context: {internal: true}});
});
}