|
|
@ -12,7 +12,7 @@ module.exports = function (app, opts) { |
|
|
|
const { models, ORM: sequelize } = app.fs.dc |
|
|
|
const { clickHouse } = app.fs |
|
|
|
const { database: anxinyun } = clickHouse.anxinyun.opts.config |
|
|
|
const { pushBySms, pushByEmail } = app.fs.utils |
|
|
|
const { pushBySms, pushByEmail, sendNoticeToWeb } = app.fs.utils |
|
|
|
const curMinOfYear = moment().diff(moment().startOf('year'), 'minutes') |
|
|
|
const configListRes = await models.AlarmPushConfig.findAll({ |
|
|
|
where: { |
|
|
@ -674,14 +674,14 @@ module.exports = function (app, opts) { |
|
|
|
const receiverRes = |
|
|
|
c.receiverPepUserId.length ? |
|
|
|
await clickHouse.pepEmis.query(` |
|
|
|
SELECT id, email FROM user WHERE id IN (${c.receiverPepUserId.join(',')},-1) |
|
|
|
SELECT id, name, email FROM user WHERE id IN (${c.receiverPepUserId.join(',')},-1) |
|
|
|
`).toPromise()
|
|
|
|
: [] |
|
|
|
let receiverId = [] |
|
|
|
const emails = receiverRes.reduce((arr, r) => { |
|
|
|
if (r.email) { |
|
|
|
arr.push(r.email) |
|
|
|
receiverId.push(r.id) |
|
|
|
receiverId.push({ id: r.id, name: r.name }) |
|
|
|
} |
|
|
|
return arr |
|
|
|
}, []) |
|
|
@ -692,14 +692,30 @@ module.exports = function (app, opts) { |
|
|
|
text: '', |
|
|
|
html: html |
|
|
|
}) |
|
|
|
await models.EmailSendLog.create({ |
|
|
|
|
|
|
|
//存日志 存动态 socket到前端
|
|
|
|
let dataToSave = { |
|
|
|
time: moment().format(), |
|
|
|
pushConfigId: c.id, |
|
|
|
cfgName: c.name,//策略名称
|
|
|
|
tactics: c.tactics, |
|
|
|
tacticsParams: c.tacticsParams, |
|
|
|
projectCorrelationId: pomsProjectId, |
|
|
|
toPepUserIds: receiverId |
|
|
|
}) |
|
|
|
toPepUserIds: receiverId.map(r => r.id) |
|
|
|
} |
|
|
|
let r = await models.EmailSendLog.create(dataToSave, { returning: true }) |
|
|
|
|
|
|
|
let dynamic = { |
|
|
|
time: r.dataValues.time, |
|
|
|
emailSendId: r.dataValues.id, |
|
|
|
projectCorrelationId: r.dataValues.projectCorrelationId, |
|
|
|
type: 2//通知
|
|
|
|
} |
|
|
|
await models.LatestDynamicList.create(dynamic); |
|
|
|
|
|
|
|
|
|
|
|
//消息推送到前端
|
|
|
|
await sendNoticeToWeb(receiverId, dataToSave); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|