From 8c2045a7f98c20980a2276ab8e4096edd3036b64 Mon Sep 17 00:00:00 2001 From: Michael DiCarlo Date: Fri, 9 Apr 2021 08:32:12 -0400 Subject: [PATCH] Telegram: Better telegram response message on failure --- .../websites/telegram/telegram.service.ts | 6 ++++-- ui/src/websites/telegram/TelegramLogin.tsx | 20 +++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/electron-app/src/server/websites/telegram/telegram.service.ts b/electron-app/src/server/websites/telegram/telegram.service.ts index 701c37ae..c6fa2d31 100644 --- a/electron-app/src/server/websites/telegram/telegram.service.ts +++ b/electron-app/src/server/websites/telegram/telegram.service.ts @@ -90,10 +90,12 @@ export class Telegram extends Website { phone_code: data.code, phone_code_hash: this.authData[data.appId].phone_code_hash, }) - .then(() => true) + .then(() => { + result: true; + }) .catch((err) => { this.logger.error(err); - return false; + return { result: false, message: err.error_message }; }); } diff --git a/ui/src/websites/telegram/TelegramLogin.tsx b/ui/src/websites/telegram/TelegramLogin.tsx index c67752d7..ecbf030c 100644 --- a/ui/src/websites/telegram/TelegramLogin.tsx +++ b/ui/src/websites/telegram/TelegramLogin.tsx @@ -97,7 +97,7 @@ export default class TelegramLogin extends React.Component - You must create you own app configuration + You must create your own app configuration } @@ -147,16 +147,20 @@ export default class TelegramLogin extends React.Component(this.props.account.website, 'authenticate', { - appId: this.state.appId, - code: this.state.code - }) - .then(success => { - if (success) { + WebsiteService.postCustomRoute<{ result: boolean; message?: string }>( + this.props.account.website, + 'authenticate', + { + appId: this.state.appId, + code: this.state.code + } + ) + .then(res => { + if (res.result) { message.success('Telegram authenticated.'); this.setState({ displayCodeDialog: false }); } else { - message.error('Failed to authenticate Telegram.'); + message.error(res.message || 'Failed to authenticate Telegram.'); } }) .catch(() => {