Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into prod
Browse files Browse the repository at this point in the history
  • Loading branch information
Florin H committed Oct 18, 2023
2 parents 0c5a261 + b90e280 commit ffc2e70
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
11 changes: 5 additions & 6 deletions api/src/components/coauthor/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,13 @@ export const updateConfirmation = async (
version.coAuthors.filter((coAuthor) => !coAuthor.confirmedCoAuthor).length - 1
});
} else {
// notify main author about rejection
await email.notifyCoAuthorRejection({
coAuthor: {
email: event.user.email || ''
},
// notify corresponding author about cancelled approval
await email.notifyCoAuthorCancelledApproval({
publication: {
id: version.versionOf,
title: version.title || '',
authorEmail: version.user.email || ''
authorEmail: version.user.email || '',
url: `${process.env.BASE_URL}/publications/${version.versionOf}`
}
});
}
Expand Down
28 changes: 28 additions & 0 deletions api/src/lib/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,3 +647,31 @@ export const notifyCoAuthorsAboutChanges = async (options: NotifyCoAuthorsAboutC
subject: 'Changes have been made to a publication that you are an author on'
});
};

type NotifyCoAuthorCancelledApproval = {
publication: {
id: string;
title: string;
authorEmail: string;
url: string;
};
};

export const notifyCoAuthorCancelledApproval = async (options: NotifyCoAuthorCancelledApproval): Promise<void> => {
const html = `
<p>A co-author had previously approved your publication, <strong><i>${options.publication.title}</i></strong>, but has now changed their mind, indicating that changes might be needed.</p>
<br>
<p style="text-align: center;"><a style="${styles.button}" href="${options.publication.url}">View publication</a></p>
<br>
<p>This author’s approval is required before publishing. Please discuss whether any further changes are needed with the author.</p>
`;

const text = `A co-author had previously approved your publication, ${options.publication.title}, but has now changed their mind, indicating that changes might be needed. You can view the publication following this link: ${options.publication.url}. This author’s approval is required before publishing. Please discuss whether any further changes are needed with the author.`;

await send({
html: standardHTMLEmailTemplate('A co-author has cancelled their approval', html),
text,
to: options.publication.authorEmail,
subject: 'A co-author has cancelled their approval'
});
};

0 comments on commit ffc2e70

Please sign in to comment.