(config, usernames, accountManager, dateOfRemoval, supportEmail)
| 103 | } |
| 104 | |
| 105 | async function sendEmails (config, usernames, accountManager, dateOfRemoval, supportEmail) { |
| 106 | if (config.email && config.email.host) { |
| 107 | const configPath = initConfigDir(config) |
| 108 | const templates = initTemplateDirs(configPath) |
| 109 | const users = await Promise.all(await usernames.map(async username => { |
| 110 | const emailAddress = await accountManager.loadAccountRecoveryEmail({ username }) |
| 111 | const accountUri = accountManager.accountUriFor(username) |
| 112 | return { username, emailAddress, accountUri } |
| 113 | })) |
| 114 | const emailService = new EmailService(templates.email, config.email) |
| 115 | const sendingEmails = users |
| 116 | .filter(user => !!user.emailAddress) |
| 117 | .map(user => emailService.sendWithTemplate('invalid-username.mjs', { |
| 118 | to: user.emailAddress, |
| 119 | accountUri: user.accountUri, |
| 120 | dateOfRemoval, |
| 121 | supportEmail |
| 122 | })) |
| 123 | const emailsSent = await Promise.all(sendingEmails) |
| 124 | console.info(`${emailsSent.length} emails sent to users with invalid usernames`) |
| 125 | return |
| 126 | } |
| 127 | console.info('You have not configured an email service.') |
| 128 | console.info('Please set it up to send users email about their accounts') |
| 129 | } |
| 130 | |
| 131 | function updateIndexFiles (usernames, accountManager, dateOfRemoval, supportEmail) { |
| 132 | const invalidUsernameFilePath = path.join(process.cwd(), 'default-views', 'account', 'invalid-username.hbs') |
no test coverage detected