MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / SendExistingMedia

Function SendExistingMedia

Telegram/SourceFiles/api/api_sending.cpp:157–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155
156template <typename MediaData>
157void SendExistingMedia(
158 MessageToSend &&message,
159 not_null<MediaData*> media,
160 Fn<MTPInputMedia()> inputMedia,
161 Data::FileOrigin origin,
162 std::optional<MsgId> localMessageId) {
163 const auto history = message.action.history;
164 const auto peer = history->peer;
165 const auto session = &history->session();
166 const auto api = &session->api();
167
168 message.action.clearDraft = false;
169 message.action.generateLocal = true;
170 api->sendAction(message.action);
171
172 const auto newId = FullMsgId(
173 peer->id,
174 localMessageId
175 ? (*localMessageId)
176 : session->data().nextLocalMessageId());
177 const auto randomId = base::RandomValue<uint64>();
178 auto &action = message.action;
179
180 auto flags = NewMessageFlags(peer);
181 auto sendFlags = MTPmessages_SendMedia::Flags(0);
182 if (action.replyTo) {
183 flags |= MessageFlag::HasReplyInfo;
184 sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to;
185 }
186 const auto silentPost = ShouldSendSilent(peer, action.options);
187 InnerFillMessagePostFlags(action.options, peer, flags);
188 if (silentPost) {
189 sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
190 }
191 const auto sendAs = action.options.sendAs;
192 if (sendAs) {
193 sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
194 }
195 auto caption = TextWithEntities{
196 message.textWithTags.text,
197 TextUtilities::ConvertTextTagsToEntities(message.textWithTags.tags)
198 };
199 TextUtilities::Trim(caption);
200 auto sentEntities = EntitiesToMTP(
201 session,
202 caption.entities,
203 ConvertOption::SkipLocal);
204 if (!sentEntities.v.isEmpty()) {
205 sendFlags |= MTPmessages_SendMedia::Flag::f_entities;
206 }
207 const auto captionText = caption.text;
208 const auto starsPaid = std::min(
209 peer->starsPerMessageChecked(),
210 action.options.starsApproved);
211 if (action.options.scheduled) {
212 flags |= MessageFlag::IsOrWasScheduled;
213 sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_date;
214 if (action.options.scheduleRepeatPeriod) {

Callers 2

SendExistingDocumentFunction · 0.85
SendExistingPhotoFunction · 0.85

Calls 15

NewMessageFlagsFunction · 0.85
ShouldSendSilentFunction · 0.85
TrimFunction · 0.85
EntitiesToMTPFunction · 0.85
NewMessageFromIdFunction · 0.85
NewMessageDateFunction · 0.85
NewMessagePostAuthorFunction · 0.85
MTP_flagsFunction · 0.85
ReplyToPlaceholderClass · 0.85
MTP_stringFunction · 0.85

Tested by

no test coverage detected