| 66 | } |
| 67 | |
| 68 | void SendSimpleMedia(SendAction action, MTPInputMedia inputMedia) { |
| 69 | const auto history = action.history; |
| 70 | const auto peer = history->peer; |
| 71 | const auto session = &history->session(); |
| 72 | const auto api = &session->api(); |
| 73 | |
| 74 | action.clearDraft = false; |
| 75 | action.generateLocal = false; |
| 76 | api->sendAction(action); |
| 77 | |
| 78 | const auto randomId = base::RandomValue<uint64>(); |
| 79 | |
| 80 | auto flags = NewMessageFlags(peer); |
| 81 | auto sendFlags = MTPmessages_SendMedia::Flags(0); |
| 82 | if (action.replyTo) { |
| 83 | flags |= MessageFlag::HasReplyInfo; |
| 84 | sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to; |
| 85 | } |
| 86 | const auto silentPost = ShouldSendSilent(peer, action.options); |
| 87 | InnerFillMessagePostFlags(action.options, peer, flags); |
| 88 | if (silentPost) { |
| 89 | sendFlags |= MTPmessages_SendMedia::Flag::f_silent; |
| 90 | } |
| 91 | const auto sendAs = action.options.sendAs; |
| 92 | if (sendAs) { |
| 93 | sendFlags |= MTPmessages_SendMedia::Flag::f_send_as; |
| 94 | } |
| 95 | const auto messagePostAuthor = peer->isBroadcast() |
| 96 | ? session->user()->name() |
| 97 | : QString(); |
| 98 | const auto starsPaid = std::min( |
| 99 | peer->starsPerMessageChecked(), |
| 100 | action.options.starsApproved); |
| 101 | if (action.options.scheduled) { |
| 102 | flags |= MessageFlag::IsOrWasScheduled; |
| 103 | sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_date; |
| 104 | if (action.options.scheduleRepeatPeriod) { |
| 105 | sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_repeat_period; |
| 106 | } |
| 107 | } |
| 108 | if (action.options.shortcutId) { |
| 109 | flags |= MessageFlag::ShortcutMessage; |
| 110 | sendFlags |= MTPmessages_SendMedia::Flag::f_quick_reply_shortcut; |
| 111 | } |
| 112 | if (action.options.effectId) { |
| 113 | sendFlags |= MTPmessages_SendMedia::Flag::f_effect; |
| 114 | } |
| 115 | if (action.options.suggest) { |
| 116 | sendFlags |= MTPmessages_SendMedia::Flag::f_suggested_post; |
| 117 | } |
| 118 | if (action.options.invertCaption) { |
| 119 | flags |= MessageFlag::InvertMedia; |
| 120 | sendFlags |= MTPmessages_SendMedia::Flag::f_invert_media; |
| 121 | } |
| 122 | if (starsPaid) { |
| 123 | action.options.starsApproved -= starsPaid; |
| 124 | sendFlags |= MTPmessages_SendMedia::Flag::f_allow_paid_stars; |
| 125 | } |
no test coverage detected