| 4757 | } |
| 4758 | |
| 4759 | void ApiWrap::sendMediaWithRandomId( |
| 4760 | not_null<HistoryItem*> item, |
| 4761 | const MTPInputMedia &media, |
| 4762 | Api::SendOptions options, |
| 4763 | uint64 randomId, |
| 4764 | Fn<void(bool)> done) { |
| 4765 | const auto history = item->history(); |
| 4766 | const auto replyTo = item->replyTo(); |
| 4767 | const auto peer = history->peer; |
| 4768 | |
| 4769 | auto caption = item->originalText(); |
| 4770 | TextUtilities::Trim(caption); |
| 4771 | auto sentEntities = Api::EntitiesToMTP( |
| 4772 | _session, |
| 4773 | caption.entities, |
| 4774 | Api::ConvertOption::SkipLocal); |
| 4775 | |
| 4776 | const auto updateRecentStickers = Api::HasAttachedStickers(media); |
| 4777 | const auto starsPaid = std::min( |
| 4778 | peer->starsPerMessageChecked(), |
| 4779 | options.starsApproved); |
| 4780 | if (starsPaid) { |
| 4781 | options.starsApproved -= starsPaid; |
| 4782 | } |
| 4783 | |
| 4784 | using Flag = MTPmessages_SendMedia::Flag; |
| 4785 | const auto flags = Flag(0) |
| 4786 | | (replyTo ? Flag::f_reply_to : Flag(0)) |
| 4787 | | (ShouldSendSilent(history->peer, options) |
| 4788 | ? Flag::f_silent |
| 4789 | : Flag(0)) |
| 4790 | | (!sentEntities.v.isEmpty() ? Flag::f_entities : Flag(0)) |
| 4791 | | (options.scheduled ? Flag::f_schedule_date : Flag(0)) |
| 4792 | | ((options.scheduled && options.scheduleRepeatPeriod) |
| 4793 | ? Flag::f_schedule_repeat_period |
| 4794 | : Flag(0)) |
| 4795 | | (options.sendAs ? Flag::f_send_as : Flag(0)) |
| 4796 | | (options.shortcutId ? Flag::f_quick_reply_shortcut : Flag(0)) |
| 4797 | | (options.effectId ? Flag::f_effect : Flag(0)) |
| 4798 | | (options.suggest ? Flag::f_suggested_post : Flag(0)) |
| 4799 | | (options.invertCaption ? Flag::f_invert_media : Flag(0)) |
| 4800 | | (starsPaid ? Flag::f_allow_paid_stars : Flag(0)); |
| 4801 | |
| 4802 | auto &histories = history->owner().histories(); |
| 4803 | const auto itemId = item->fullId(); |
| 4804 | histories.sendPreparedMessage( |
| 4805 | history, |
| 4806 | replyTo, |
| 4807 | randomId, |
| 4808 | Data::Histories::PrepareMessage<MTPmessages_SendMedia>( |
| 4809 | MTP_flags(flags), |
| 4810 | peer->input(), |
| 4811 | Data::Histories::ReplyToPlaceholder(), |
| 4812 | (options.price |
| 4813 | ? MTPInputMedia(MTP_inputMediaPaidMedia( |
| 4814 | MTP_flags(0), |
| 4815 | MTP_long(options.price), |
| 4816 | MTP_vector<MTPInputMedia>(1, media), |
nothing calls this directly
no test coverage detected