Skip to content

Commit

Permalink
Added restriction to not send mail for published posts
Browse files Browse the repository at this point in the history
no issue
  • Loading branch information
rishabhgrg committed Nov 4, 2019
1 parent 5b438d3 commit 424e3ae
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions core/server/services/mega.js
@@ -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) => {
Expand All @@ -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 = {
Expand All @@ -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}});
});
}

Expand Down

0 comments on commit 424e3ae

Please sign in to comment.