sending job key with the listings

This commit is contained in:
Christian Kellner
2020-07-17 16:34:10 +02:00
parent ee313e401c
commit a58b849f26
6 changed files with 44 additions and 40 deletions

View File

@@ -5,9 +5,10 @@ const sgMail = require('@sendgrid/mail');
* @param serviceName e.g immoscout
* @param newListings an array with newly found listings
* @param notificationConfig config of this notification adapter
* * @param jobKey name of the current job that is being executed
* @returns {Promise<Chat.PostMessage.Response> | void}
*/
exports.send = (serviceName, newListings, notificationConfig) => {
exports.send = (serviceName, newListings, notificationConfig, jobKey) => {
const { apiKey, enabled, receiver, from, templateId } = notificationConfig.sendGrid;
if (!enabled) {
return [Promise.resolve()];
@@ -17,9 +18,9 @@ exports.send = (serviceName, newListings, notificationConfig) => {
templateId,
to: receiver,
from,
subject: `Service ${serviceName} found ${newListings.length} new listing(s)`,
subject: `Job ${jobKey} | Service ${serviceName} found ${newListings.length} new listing(s)`,
dynamic_template_data: {
serviceName,
serviceName: `Job: (${jobKey}) | Service: ${serviceName}`,
numberOfListings: newListings.length,
listings: newListings,
},