Commit 6aaed08e authored by nickstiffler's avatar nickstiffler Committed by Yannis Barlas

feat(notifications): email authors on new submission

parent 3818a8b9
......@@ -533,18 +533,21 @@ const identityVerification = async context => {
}
/*
Sends email to editors that a new article has been submitted
Sends email that a new article has been submitted
*/
const initialSubmission = async context => {
const editorEmails = await getEditorEmails()
const { version } = context
const currentUser = await getCurrentUser(context)
/**
* Send email to editors that there is a new submission
*/
const content = `
<p>There has been a new submission!</p>
<p>
User ${
currentUser.username
currentUser.displayName
} just submitted article "${formatManuscriptTitle(version.title)}".
</p>
${getArticleLink(version.manuscriptId)}
......@@ -557,6 +560,71 @@ const initialSubmission = async context => {
}
sendEmail(data)
/**
* Send email to submitting author that their submission was successfully
* received.
*/
const authorName = await currentUser.displayName
const authorEmail = await getEmailsByUserIds([currentUser.id])
const authorContent = `
<p>Dear ${authorName},</p>
<p>
Thank you for submitting your data to microPublication Biology.
<br />
This message is to acknowledge receipt of your submission.
</p>
<p>We will keep you posted.</p>
<p>Best wishes,</p>
<p>The microPublication Team</p>
`
const authorData = {
content: authorContent,
subject: 'New Submission',
to: authorEmail,
}
sendEmail(authorData)
/**
* Send email to co-authors that they were included in a submission
*/
const authorEmails = version.authors
.map(author => author.email)
.filter(email => email !== authorEmail[0])
const coAuthorContent = `
<p>
This message is to inform you that you are listed as a co-author on the
manuscript "${formatManuscriptTitle(
version.title,
)}", which was recently submitted to microPublication Biology.
</p>
<p>
${authorName} is responsible for communicating with the journal and
managing communication between co-authors for this article. Please
contact this author directly with any queries you may have related to
this manuscript.
</p>
<p>
If you have have any further concerns you are welcome to contact us
directly at
<a href="mailto:contact@micropublication.org">
contact@micropublication.org
</a>.
</p>
`
const coAuthorData = {
content: coAuthorContent,
subject: 'New Submission',
to: authorEmails,
}
sendEmail(coAuthorData)
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment