mirror of
https://github.com/plankanban/planka.git
synced 2025-12-17 09:13:23 +03:00
ref: Refactoring
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const POST_MESSAGE_API_URL = (telegramBotToken) =>
|
||||
const buildSendMessageApiUrl = (telegramBotToken) =>
|
||||
`https://api.telegram.org/bot${telegramBotToken}/sendMessage`;
|
||||
|
||||
module.exports = {
|
||||
@@ -8,6 +8,7 @@ module.exports = {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const headers = {
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
@@ -25,7 +26,7 @@ module.exports = {
|
||||
|
||||
let response;
|
||||
try {
|
||||
response = await fetch(POST_MESSAGE_API_URL(sails.config.custom.telegramBotToken), {
|
||||
response = await fetch(buildSendMessageApiUrl(sails.config.custom.telegramBotToken), {
|
||||
headers,
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
@@ -36,8 +37,8 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
const responseErrorJson = await response.json();
|
||||
sails.log.error(`Error sending to Telegram: ${responseErrorJson.description}`);
|
||||
const responseJson = await response.json();
|
||||
sails.log.error(`Error sending to Telegram: ${responseJson.description}`);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user