mirror of
https://github.com/plankanban/planka.git
synced 2025-07-22 22:59:44 +02:00
ref: Refactoring
This commit is contained in:
parent
cc95032e74
commit
38bc4cb0a0
7 changed files with 53 additions and 39 deletions
|
@ -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}`);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue