feat(frontend): add telegram integration (#491)

* feat(frontend): add telegram notification agent

* feat(telegram): add i18n keys for telegram

* style(telegram): change message formatting in notification

* feat(telegram): add short tutorial for telegram setup

* feat(telegram): add i18n keys for telegram tutorial

* style(telegram): correct grammar in infobox

Co-authored-by: sct <ryan@sct.dev>

* fix(telegram): redo i18n extraction

Co-authored-by: Jakob Ankarhem <jakob.ankarhem@jetshop.se>
Co-authored-by: sct <ryan@sct.dev>
This commit is contained in:
Jakob Ankarhem
2020-12-26 16:02:00 +01:00
committed by GitHub
parent 7434a26f76
commit c8d4d674f4
12 changed files with 517 additions and 3 deletions

View File

@@ -25,6 +25,7 @@ import { Notification } from '../lib/notifications';
import DiscordAgent from '../lib/notifications/agents/discord';
import EmailAgent from '../lib/notifications/agents/email';
import SlackAgent from '../lib/notifications/agents/slack';
import TelegramAgent from '../lib/notifications/agents/telegram';
const settingsRoutes = Router();
@@ -503,6 +504,40 @@ settingsRoutes.post('/notifications/slack/test', (req, res, next) => {
return res.status(204).send();
});
settingsRoutes.get('/notifications/telegram', (_req, res) => {
const settings = getSettings();
res.status(200).json(settings.notifications.agents.telegram);
});
settingsRoutes.post('/notifications/telegram', (req, res) => {
const settings = getSettings();
settings.notifications.agents.telegram = req.body;
settings.save();
res.status(200).json(settings.notifications.agents.telegram);
});
settingsRoutes.post('/notifications/telegram/test', (req, res, next) => {
if (!req.user) {
return next({
status: 500,
message: 'User information missing from request',
});
}
const telegramAgent = new TelegramAgent(req.body);
telegramAgent.send(Notification.TEST_NOTIFICATION, {
notifyUser: req.user,
subject: 'Test Notification',
message:
'This is a test notification! Check check, 1, 2, 3. Are we coming in clear?',
});
return res.status(204).send();
});
settingsRoutes.get('/notifications/email', (_req, res) => {
const settings = getSettings();