| 1683 | } |
| 1684 | |
| 1685 | ShareBox::SubmitCallback ShareBox::DefaultForwardCallback( |
| 1686 | std::shared_ptr<Ui::Show> show, |
| 1687 | not_null<History*> history, |
| 1688 | MessageIdsList msgIds, |
| 1689 | std::optional<TimeId> videoTimestamp, |
| 1690 | bool no_quote, |
| 1691 | FnMut<void()>&& successCallback) { |
| 1692 | struct State final { |
| 1693 | State(FnMut<void()>&& callback) |
| 1694 | : submitCallback(std::move(callback)) { |
| 1695 | } |
| 1696 | base::flat_set<mtpRequestId> requests; |
| 1697 | mtpRequestId nextRequestKey = 0; |
| 1698 | FnMut<void()> submitCallback; |
| 1699 | }; |
| 1700 | const auto state = std::make_shared<State>(std::move(successCallback)); |
| 1701 | return [=]( |
| 1702 | std::vector<not_null<Data::Thread*>> &&result, |
| 1703 | Fn<bool()> checkPaid, |
| 1704 | TextWithTags comment, |
| 1705 | Api::SendOptions options, |
| 1706 | Data::ForwardOptions forwardOptions) { |
| 1707 | if (!state->requests.empty()) { |
| 1708 | return; // Share clicked already. |
| 1709 | } |
| 1710 | |
| 1711 | const auto items = history->owner().idsToItems(msgIds); |
| 1712 | const auto existingIds = history->owner().itemsToIds(items); |
| 1713 | if (existingIds.empty() || result.empty()) { |
| 1714 | return; |
| 1715 | } |
| 1716 | if (HistoryView::Controls::HasRichPage(items)) { |
| 1717 | forwardOptions = HistoryView::Controls::NormalizeForwardOptions( |
| 1718 | &history->session(), |
| 1719 | items, |
| 1720 | forwardOptions); |
| 1721 | } |
| 1722 | |
| 1723 | const auto error = GetErrorForSending( |
| 1724 | result, |
| 1725 | { .forward = &items, .text = &comment }); |
| 1726 | if (error.error) { |
| 1727 | show->showBox(MakeSendErrorBox(error, result.size() > 1)); |
| 1728 | return; |
| 1729 | } else if (!checkPaid()) { |
| 1730 | return; |
| 1731 | } |
| 1732 | |
| 1733 | using Flag = MTPmessages_ForwardMessages::Flag; |
| 1734 | auto commonSendFlags = MTPmessages_ForwardMessages::Flags(0); |
| 1735 | if (no_quote) { |
| 1736 | commonSendFlags = (options.scheduled ? Flag::f_schedule_date : Flag(0)) | Flag::f_drop_author; |
| 1737 | } else { |
| 1738 | commonSendFlags = Flag(0) |
| 1739 | | Flag::f_with_my_score |
| 1740 | | (options.scheduled ? Flag::f_schedule_date : Flag(0)) |
| 1741 | | ((options.scheduled && options.scheduleRepeatPeriod) |
| 1742 | ? Flag::f_schedule_repeat_period |
nothing calls this directly
no test coverage detected