mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
moving to node-fetch coz axios is causing issues with scrapingAnt
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const { markdown2Html } = require('../../services/markdown');
|
||||
const { getJob } = require('../../services/storage/jobStorage');
|
||||
const axios = require('axios');
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
/**
|
||||
* sends new listings to mattermost
|
||||
@@ -21,9 +21,13 @@ exports.send = ({ serviceName, newListings, notificationConfig, jobKey }) => {
|
||||
(o) => `| [${o.title}](${o.link}) | ` + [o.address, o.size.replace(/2m/g, '$m^2$'), o.price].join(' | ') + ' |\n'
|
||||
);
|
||||
|
||||
return axios.post(`${webhook}`, {
|
||||
channel: channel,
|
||||
text: message,
|
||||
return fetch(webhook, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: {
|
||||
channel: channel,
|
||||
text: message,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { markdown2Html } = require('../../services/markdown');
|
||||
const { getJob } = require('../../services/storage/jobStorage');
|
||||
const axios = require('axios');
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
const MAX_ENTITIES_PER_CHUNK = 8;
|
||||
const RATE_LIMIT_INTERVAL = 1010;
|
||||
@@ -47,15 +47,22 @@ exports.send = ({ serviceName, newListings, notificationConfig, jobKey }) => {
|
||||
*/
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
axios
|
||||
.post(`https://api.telegram.org/bot${token}/sendMessage`, {
|
||||
fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
|
||||
method: 'post',
|
||||
body: JSON.stringify({
|
||||
chat_id: chatId,
|
||||
text: message,
|
||||
parse_mode: 'HTML',
|
||||
disable_web_page_preview: true,
|
||||
}),
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
.then(() => {
|
||||
resolve();
|
||||
})
|
||||
.then(() => resolve())
|
||||
.catch(() => reject());
|
||||
.catch(() => {
|
||||
reject();
|
||||
});
|
||||
}, RATE_LIMIT_INTERVAL);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user