fix: use bcc for admin emails, fix #371

This commit is contained in:
lesion 2024-04-10 11:43:04 +02:00
parent 80efc69946
commit 4ba5645ebf
No known key found for this signature in database
GPG key ID: 352918250B012177
3 changed files with 6 additions and 6 deletions

View file

@ -306,7 +306,7 @@ const eventController = {
log.info('[EVENT] Report event to %s', emails)
// notify admins
mail.send(emails, 'report', { event, message: body.message, author })
mail.send(emails, 'report', { event, message: body.message, author }, undefined, true)
// notify author
if (event['user.email'] && body.is_author_visible && !isMine) {

View file

@ -7,7 +7,7 @@ const { Task, TaskManager } = require('../taskManager')
const locales = require('../../locales')
const mail = {
send (addresses, template, locals, locale) {
send (addresses, template, locals, locale, bcc) {
locale = locale || settingsController.settings.instance_locale
if (process.env.NODE_ENV === 'production' && (!settingsController.settings.admin_email || !settingsController.settings.smtp)) {
log.error(`Cannot send any email: SMTP Email configuration not completed!`)
@ -17,12 +17,12 @@ const mail = {
const task = new Task({
name: 'MAIL',
method: mail._send,
args: [addresses, template, locals, locale]
args: [addresses, template, locals, locale, bcc]
})
TaskManager.add(task)
},
_send (addresses, template, locals, locale) {
_send (addresses, template, locals, locale, bcc=false) {
locale = locale || settingsController.settings.instance_locale
const settings = settingsController.settings
log.info(`Send ${template} email to ${addresses} with locale ${locale}`)
@ -61,7 +61,7 @@ const mail = {
const msg = {
template,
message: {
to: addresses
[bcc ? 'bcc' : 'to']: addresses
},
locals: {
...locals,

View file

@ -26,7 +26,7 @@ const notifier = {
let emails = [settingsController.settings.admin_email]
emails = emails.concat(admins?.map(a => a.email))
p = mail.send(emails, 'event',
{ event, to_confirm: !event.is_visible, notification })
{ event, to_confirm: !event.is_visible, notification }, undefined, true)
promises.push(p)
break
case 'ap':