Skip to content

Commit

Permalink
fix(typo): remove typo in telegram set (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
leocabeza authored Jul 23, 2020
1 parent 931a65b commit 6757fd8
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions api/telegram/set.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
import fetch from 'node-fetch';
import * as Sentry from '@sentry/node';
import fetch from "node-fetch";
import * as Sentry from "@sentry/node";

const { TELEGRAM_BOT_TOKEN, APP_URL, SENTRY_DSN } = process.env;

Sentry.init({ dsn: SENTRY_DSN });

/* used to activate webhook whenever we change the APP_URL */
export default async(request, response) => {
export default async (request, response) => {
try {
if (request.query.token === TELEGRAM_BOT_TOKEN) {
const fetchResponse = await fetch(`https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/setWebhook?url=${APP_URL}/api/telegram/update?token=${TELEGRAM_BOT_TOKEN}}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
});
const fetchResponse = await fetch(
`https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/setWebhook?url=${APP_URL}/api/telegram/update?token=${TELEGRAM_BOT_TOKEN}`,
{
method: "POST",
headers: {
"Content-Type": "application/json"
}
}
);
const jsonResponse = await fetchResponse.json();

response.status(200).json(jsonResponse);
} else {
response.status(401).send('Unauthorized');
response.status(401).send("Unauthorized");
}
} catch (error) {
Sentry.captureException(error);

response.status(400).send('not ok');
response.status(400).send("not ok");
}
};

0 comments on commit 6757fd8

Please sign in to comment.