diff --git a/lib/discourse_chat_integration/provider/telegram/telegram_command_controller.rb b/lib/discourse_chat_integration/provider/telegram/telegram_command_controller.rb index b5d1287..fe01d9a 100644 --- a/lib/discourse_chat_integration/provider/telegram/telegram_command_controller.rb +++ b/lib/discourse_chat_integration/provider/telegram/telegram_command_controller.rb @@ -58,6 +58,8 @@ module DiscourseChatIntegration::Provider::TelegramProvider end def process_command(message) + return unless message['text'] # No command to be processed + chat_id = params['message']['chat']['id'] provider = DiscourseChatIntegration::Provider::TelegramProvider::PROVIDER_NAME diff --git a/spec/lib/discourse_chat_integration/provider/telegram/telegram_command_controller_spec.rb b/spec/lib/discourse_chat_integration/provider/telegram/telegram_command_controller_spec.rb index e4124df..fe0cbfb 100644 --- a/spec/lib/discourse_chat_integration/provider/telegram/telegram_command_controller_spec.rb +++ b/spec/lib/discourse_chat_integration/provider/telegram/telegram_command_controller_spec.rb @@ -135,6 +135,18 @@ describe 'Telegram Command Controller', type: :request do expect(response.status).to eq(200) expect(stub).to have_been_requested.times(1) end + + context "when 'text' is missing" do + it "does not break" do + post '/chat-integration/telegram/command/shhh.json', params: { + message: { chat: { id: 123 } } + } + + expect(response).to have_http_status :ok + expect(DiscourseChatIntegration::Rule.count).to eq(0) + expect(DiscourseChatIntegration::Channel.count).to eq(1) + end + end end end end