diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index a67ea6bec..a0a6f0117 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -114,7 +114,7 @@ bool HasInlineItems(const HistoryItemsList &items) { } // namespace -QString GetErrorTextForForward( +QString GetErrorTextForSending( not_null peer, const HistoryItemsList &items, const TextWithTags &comment, @@ -234,7 +234,7 @@ void FastShareMessage(not_null item) { const auto error = [&] { for (const auto peer : result) { - const auto error = GetErrorTextForForward( + const auto error = GetErrorTextForSending( peer, items, comment); @@ -354,11 +354,11 @@ MTPDmessage_ClientFlags NewMessageClientFlags() { return MTPDmessage_ClientFlag::f_sending; } -QString GetErrorTextForForward( +QString GetErrorTextForSending( not_null peer, const HistoryItemsList &items, bool ignoreSlowmodeCountdown) { - return GetErrorTextForForward(peer, items, {}, ignoreSlowmodeCountdown); + return GetErrorTextForSending(peer, items, {}, ignoreSlowmodeCountdown); } struct HistoryMessage::CreateConfig { diff --git a/Telegram/SourceFiles/history/history_message.h b/Telegram/SourceFiles/history/history_message.h index d786fd6cf..d724723c0 100644 --- a/Telegram/SourceFiles/history/history_message.h +++ b/Telegram/SourceFiles/history/history_message.h @@ -19,11 +19,11 @@ Fn HistoryDependentItemCallback( const FullMsgId &msgId); MTPDmessage::Flags NewMessageFlags(not_null peer); MTPDmessage_ClientFlags NewMessageClientFlags(); -QString GetErrorTextForForward( +QString GetErrorTextForSending( not_null peer, const HistoryItemsList &items, bool ignoreSlowmodeCountdown = false); -QString GetErrorTextForForward( +QString GetErrorTextForSending( not_null peer, const HistoryItemsList &items, const TextWithTags &comment, diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index e8f2ad131..6c098b7e1 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -2937,7 +2937,7 @@ void HistoryWidget::send(Api::SendOptions options) { message.webPageId = webPageId; if (_canSendMessages) { - const auto error = GetErrorTextForForward( + const auto error = GetErrorTextForSending( _peer, _toForward, message.textWithTags); diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 5f0bf9009..22cb43ec3 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -2330,12 +2330,18 @@ std::unique_ptr ListWidget::prepareDrag() { ? _pressItemExact : pressedItem; if (_mouseCursorState == CursorState::Date) { - forwardIds = session().data().itemOrItsGroup(_overElement->data()); + if (_overElement->data()->allowsForward()) { + forwardIds = session().data().itemOrItsGroup( + _overElement->data()); + } } else if (_pressState.pointState == PointState::GroupPart) { - forwardIds = MessageIdsList(1, exactItem->fullId()); + if (exactItem->allowsForward()) { + forwardIds = MessageIdsList(1, exactItem->fullId()); + } } else if (const auto media = pressedView->media()) { - if (media->dragItemByHandler(pressedHandler) - || media->dragItem()) { + if (pressedView->data()->allowsForward() + && (media->dragItemByHandler(pressedHandler) + || media->dragItem())) { forwardIds = MessageIdsList(1, exactItem->fullId()); } } diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index ff6541be6..d4da0b589 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -400,7 +400,7 @@ void ScheduledWidget::send(Api::SendOptions options) { //message.action.replyTo = replyToId(); message.webPageId = webPageId; - //const auto error = GetErrorTextForForward( + //const auto error = GetErrorTextForSending( // _peer, // _toForward, // message.textWithTags); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 4e30489f0..9eee1e906 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -597,7 +597,7 @@ bool MainWidget::setForwardDraft(PeerId peerId, MessageIdsList &&items) { Expects(peerId != 0); const auto peer = session().data().peer(peerId); - const auto error = GetErrorTextForForward( + const auto error = GetErrorTextForSending( peer, session().data().idsToItems(items), true); @@ -685,7 +685,7 @@ void MainWidget::finishForwarding(Api::SendAction action) { const auto history = action.history; auto toForward = history->validateForwardDraft(); if (!toForward.empty()) { - const auto error = GetErrorTextForForward(history->peer, toForward); + const auto error = GetErrorTextForSending(history->peer, toForward); if (!error.isEmpty()) { return; } diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 114f8f590..af7571cc3 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_common.h" #include "history/history.h" #include "history/history_item.h" +#include "history/history_message.h" // GetErrorTextForSending. #include "window/window_session_controller.h" #include "window/window_controller.h" #include "support/support_helper.h" @@ -868,6 +869,19 @@ QPointer ShowSendNowMessagesBox( const auto text = (items.size() > 1) ? tr::lng_scheduled_send_now_many(tr::now, lt_count, items.size()) : tr::lng_scheduled_send_now(tr::now); + + const auto error = GetErrorTextForSending( + history->peer, + session->data().idsToItems(items), + TextWithTags()); + if (!error.isEmpty()) { + auto config = Ui::Toast::Config(); + config.multiline = true; + config.minWidth = st::msgMinWidth; + config.text = error; + Ui::Toast::Show(config); + return { nullptr }; + } const auto box = std::make_shared>(); auto done = [ =, @@ -878,12 +892,10 @@ QPointer ShowSendNowMessagesBox( (*box)->closeBox(); } auto ids = QVector(); - for (const auto &itemId : list) { - if (const auto item = session->data().message(itemId)) { - if (item->allowsSendNow()) { - ids.push_back(MTP_int( - session->data().scheduledMessages().lookupId(item))); - } + for (const auto item : session->data().idsToItems(list)) { + if (item->allowsSendNow()) { + ids.push_back(MTP_int( + session->data().scheduledMessages().lookupId(item))); } } session->api().request(MTPmessages_SendScheduledMessages( @@ -891,6 +903,8 @@ QPointer ShowSendNowMessagesBox( MTP_vector(ids) )).done([=](const MTPUpdates &result) { session->api().applyUpdates(result); + }).fail([=](const RPCError &error) { + session->api().sendMessageFail(error, history->peer); }).send(); if (callback) { callback();