From cc463b07b19928479f95a2911f4932f7d4bfe56f Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 1 May 2020 14:35:20 +0400 Subject: [PATCH] Don't send dice / dart to channels. Fixes #7703. --- .../history/view/media/history_view_dice.cpp | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_dice.cpp b/Telegram/SourceFiles/history/view/media/history_view_dice.cpp index ee089ef96..4db8eec9c 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_dice.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_dice.cpp @@ -42,22 +42,24 @@ namespace { .durationMs = Ui::Toast::kDefaultDuration * 2, .multiline = true, }; - auto link = Ui::Text::Link( - tr::lng_about_random_send(tr::now).toUpper()); - link.entities.push_back( - EntityInText(EntityType::Bold, 0, link.text.size())); - config.text.append(' ').append(std::move(link)); - config.filter = crl::guard(&history->session(), [=]( - const ClickHandlerPtr &handler, - Qt::MouseButton button) { - if (button == Qt::LeftButton) { - auto message = Api::MessageToSend(history); - message.action.clearDraft = false; - message.textWithTags.text = emoji; - Api::SendDice(message); - } - return false; - }); + if (history->peer->canWrite()) { + auto link = Ui::Text::Link( + tr::lng_about_random_send(tr::now).toUpper()); + link.entities.push_back( + EntityInText(EntityType::Bold, 0, link.text.size())); + config.text.append(' ').append(std::move(link)); + config.filter = crl::guard(&history->session(), [=]( + const ClickHandlerPtr &handler, + Qt::MouseButton button) { + if (button == Qt::LeftButton) { + auto message = Api::MessageToSend(history); + message.action.clearDraft = false; + message.textWithTags.text = emoji; + Api::SendDice(message); + } + return false; + }); + } Ui::Toast::Show(config); }); }