-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(typo): remove typo in telegram set (#263)
- Loading branch information
Showing
1 changed file
with
14 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
}; |