1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 17:59:25 +00:00

Don't block main thread waiting for email to build and send

This commit is contained in:
2022-04-24 19:02:37 +00:00
parent 9ae60ef85b
commit 62364baa1d
3 changed files with 35 additions and 34 deletions

View File

@@ -173,23 +173,23 @@ class Test {
mark
);
const parents = await tr.student.getParents();
const body = 'Your result has been added for ' +
`the test "${this.template.name}" that you ` +
`took on ${this.getDateString()}\n\n` +
`You scored ${mark}/${this.template.maxMark} ` +
`(${tr.percentage}%) which is a grade ` +
`${tr.grade}`;
const email = new EmailBuilder()
.addTo([ tr.student, ...parents ]
.map(u => u.getEmail()))
.setSubject('Stratos - Test result added')
.setBody(
'Your result has been added for ' +
`the test "${this.template.name}" that you ` +
`took on ${this.getDateString()}\n\n` +
`You scored ${mark}/${this.template.maxMark} ` +
`(${tr.percentage}%) which is a grade ` +
`${tr.grade}`
);
tr.student.getParents().then(parents => {
const email = new EmailBuilder()
.addTo([ tr.student, ...parents ]
.map(u => u.getEmail()))
.setSubject('Stratos - Test result added')
.setBody(body);
const emailer = new Emailer();
await emailer.sendEmail(email);
const emailer = new Emailer();
emailer.sendEmail(email);
});
return tr;
}