Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 7x 5x 2x 1x 4x 1x 3x | "use strict"; /** * An email sender sends an email */ class EmailSender { constructor() { /** * Filters to validate address with before sending emails to. * @type {Array<EmailFilter>} */ this.filters = []; } /** * Send an email. This performs various checks and calls sendImplementation * * @param {string} to where to send email * @param {string} from reply address * @param {string} subject subject of email * @param {string} body content of email */ async send(to, from, subject, body) { for (let filter of this.filters) { if (!await filter.doesAllow(to)) { throw new Error(`${filter.name} does not allow specified email address: '${to}'.`); } } await this.sendImplementation(to, from, subject, body); } /** * @abstract * * @param {string} to where to send email * @param {string} from reply address * @param {string} subject subject of email * @param {string} body content of email */ async sendImplementation(to_, from_, subject_, body_) { throw new Error('TODO: not implemented'); } } module.exports = EmailSender; |