Skip to content

Commit

Permalink
Removed redundant context passing
Browse files Browse the repository at this point in the history
- Context object is not needed when model is used directly
  • Loading branch information
naz committed Nov 7, 2019
1 parent d7d0665 commit 3ca2588
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions core/server/services/mega/mega.js
Expand Up @@ -55,7 +55,7 @@ const addEmail = async (post) => {
return null;
}

const existing = await models.Email.findOne({post_id: post.id}, {context: {internal: true}});
const existing = await models.Email.findOne({post_id: post.id});

if (!existing) {
return models.Email.add({
Expand All @@ -66,7 +66,7 @@ const addEmail = async (post) => {
html: emailTmpl.html,
plaintext: emailTmpl.plaintext,
submitted_at: moment().toDate()
}, {context: {internal: true}});
});
} else {
return existing;
}
Expand Down Expand Up @@ -157,7 +157,7 @@ async function listener(emailModel, options) {
return;
}

const postModel = await models.Post.findOne({id: emailModel.get('post_id')}, {context: {internal: true}});
const postModel = await models.Post.findOne({id: emailModel.get('post_id')});

const post = await serialize(postModel);

Expand All @@ -174,17 +174,15 @@ async function listener(emailModel, options) {
await models.Email.edit({
status: 'submitting'
}, {
id: emailModel.id,
internalContext
id: emailModel.id
});

await sendEmail(post, members);

await models.Email.edit({
status: 'submitted'
}, {
id: emailModel.id,
internalContext
id: emailModel.id
});
}

Expand Down

0 comments on commit 3ca2588

Please sign in to comment.