FIX: telegram: Not all channel posts contain text (#34)

The `text` field is marked optional, and is not guaranteed to exist:

https://core.telegram.org/bots/api#message

We should silently ignore these actions (while responding with a
positive acknowledgement) instead of throwing a `NoMethodError`.
This commit is contained in:
Saj Goonatilleke 2019-11-20 21:45:34 +11:00 committed by Régis Hanol
parent 6fcf381751
commit 05d4338a12
1 changed files with 1 additions and 1 deletions

View File

@ -29,7 +29,7 @@ module DiscourseChat::Provider::TelegramProvider
DiscourseChat::Provider::TelegramProvider.sendMessage(message)
elsif params.key?('channel_post') && params['channel_post']['text'].include?('/getchatid')
elsif params.dig('channel_post', 'text')&.include?('/getchatid')
chat_id = params['channel_post']['chat']['id']
message_text = I18n.t(