Allow telegram to send notifications to ‘broadcast channels’
This commit is contained in:
parent
701e246ad2
commit
0d9b251030
|
@ -27,6 +27,23 @@ module DiscourseChat::Provider::TelegramProvider
|
||||||
|
|
||||||
DiscourseChat::Provider::TelegramProvider.sendMessage(message)
|
DiscourseChat::Provider::TelegramProvider.sendMessage(message)
|
||||||
|
|
||||||
|
elsif params.key?('channel_post') and params['channel_post']['text'].include? '/getchatid'
|
||||||
|
chat_id = params['channel_post']['chat']['id']
|
||||||
|
|
||||||
|
message_text = I18n.t(
|
||||||
|
"chat_integration.provider.telegram.unknown_chat",
|
||||||
|
site_title: CGI::escapeHTML(SiteSetting.title),
|
||||||
|
chat_id: chat_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
message = {
|
||||||
|
chat_id: chat_id,
|
||||||
|
text: message_text,
|
||||||
|
parse_mode: "html",
|
||||||
|
disable_web_page_preview: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
DiscourseChat::Provider::TelegramProvider.sendMessage(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Always give telegram a success message, otherwise we'll stop receiving webhooks
|
# Always give telegram a success message, otherwise we'll stop receiving webhooks
|
||||||
|
|
|
@ -101,6 +101,18 @@ describe 'Telegram Command Controller', type: :request do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should respond only to a specific command in a broadcast channel" do
|
||||||
|
post '/chat-integration/telegram/command/shhh.json', channel_post: {chat: {id:123}, text: "something" }
|
||||||
|
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
expect(stub).to have_been_requested.times(0)
|
||||||
|
|
||||||
|
post '/chat-integration/telegram/command/shhh.json', channel_post: {chat: {id:123}, text: "/getchatid" }
|
||||||
|
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
expect(stub).to have_been_requested.times(1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue