mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
sending job key with the listings
This commit is contained in:
@@ -6,18 +6,19 @@ const msg = Slack.chat.postMessage;
|
||||
* @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 { token, channel, enabled } = notificationConfig.slack;
|
||||
if (!enabled) {
|
||||
return [Promise.resolve()];
|
||||
}
|
||||
return newListings.map(payload =>
|
||||
return newListings.map((payload) =>
|
||||
msg({
|
||||
token,
|
||||
channel,
|
||||
text: `*(${serviceName})* - ${payload.title}`,
|
||||
text: `*(${serviceName} - ${jobKey})* - ${payload.title}`,
|
||||
attachments: [
|
||||
{
|
||||
fallback: payload.title,
|
||||
@@ -28,23 +29,23 @@ exports.send = (serviceName, newListings, notificationConfig) => {
|
||||
{
|
||||
title: 'Price',
|
||||
value: payload.price,
|
||||
short: false
|
||||
short: false,
|
||||
},
|
||||
{
|
||||
title: 'Size',
|
||||
value: payload.size,
|
||||
short: false
|
||||
short: false,
|
||||
},
|
||||
{
|
||||
title: 'Address',
|
||||
value: payload.address,
|
||||
short: false
|
||||
}
|
||||
short: false,
|
||||
},
|
||||
],
|
||||
footer: 'Powered by Fredy',
|
||||
ts: new Date().getTime() / 1000
|
||||
}
|
||||
]
|
||||
ts: new Date().getTime() / 1000,
|
||||
},
|
||||
],
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user