Skip to content

Commit

Permalink
Fix #607 : In Telegram service, use the chat.id to answer to a user, …
Browse files Browse the repository at this point in the history
…not the from.id
  • Loading branch information
Pierre-Gilles committed Jul 28, 2020
1 parent a7f8fbf commit 8c8e638
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/services/telegram/lib/message.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ const { EVENTS } = require('../../../utils/constants');
async function newMessage(msg) {
logger.debug(`new message from telegram, ${msg.text}`);
logger.debug(msg);

const telegramUserId = msg.from.id;
const telegramChatId = msg.chat.id;

if (msg.text.startsWith('/start')) {
const splitted = msg.text.split(' ');
await this.linkUser(splitted[1], telegramUserId);
return null;
}

const user = await this.gladys.user.getByTelegramUserId(telegramUserId);

const message = {
source: 'telegram',
source_user_id: telegramUserId,
source_user_id: telegramChatId,
user_id: user.id,
user,
language: user.language,
Expand Down

0 comments on commit 8c8e638

Please sign in to comment.