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

Function SendConfirmedFile

Telegram/SourceFiles/api/api_sending.cpp:529–710  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527}
528
529void SendConfirmedFile(
530 not_null<Main::Session*> session,
531 const std::shared_ptr<FilePrepareResult> &file) {
532 const auto isEditing = (file->type != SendMediaType::Audio)
533 && (file->type != SendMediaType::Round)
534 && (file->to.replaceMediaOf != 0);
535 const auto newId = FullMsgId(
536 file->to.peer,
537 (isEditing
538 ? file->to.replaceMediaOf
539 : session->data().nextLocalMessageId()));
540 const auto groupId = file->album ? file->album->groupId : uint64(0);
541 if (file->album) {
542 const auto proj = [](const SendingAlbum::Item &item) {
543 return item.taskId;
544 };
545 const auto it = ranges::find(file->album->items, file->taskId, proj);
546 Assert(it != file->album->items.end());
547
548 it->msgId = newId;
549 }
550
551 const auto itemToEdit = isEditing
552 ? session->data().message(newId)
553 : nullptr;
554 const auto history = session->data().history(file->to.peer);
555 const auto peer = history->peer;
556
557 if (!isEditing) {
558 const auto histories = &session->data().histories();
559 file->to.replyTo.messageId = histories->convertTopicReplyToId(
560 history,
561 file->to.replyTo.messageId);
562 file->to.replyTo.topicRootId = histories->convertTopicReplyToId(
563 history,
564 file->to.replyTo.topicRootId);
565 }
566
567 session->uploader().upload(newId, file);
568
569 auto action = SendAction(history, file->to.options);
570 action.clearDraft = false;
571 action.replyTo = file->to.replyTo;
572 action.generateLocal = true;
573 action.replaceMediaOf = file->to.replaceMediaOf;
574 session->api().sendAction(action);
575
576 auto caption = TextWithEntities{
577 file->caption.text,
578 TextUtilities::ConvertTextTagsToEntities(file->caption.tags)
579 };
580 const auto prepareFlags = Ui::ItemTextOptions(
581 history,
582 session->user()).flags;
583 TextUtilities::PrepareForSending(caption, prepareFlags);
584 TextUtilities::Trim(caption);
585
586 auto flags = isEditing ? MessageFlags() : NewMessageFlags(peer);

Callers 1

finishMethod · 0.85

Calls 15

TrimFunction · 0.85
NewMessageFlagsFunction · 0.85
FillMessagePostFlagsFunction · 0.85
MTP_flagsFunction · 0.85
NewMessageFromIdFunction · 0.85
NewMessageDateFunction · 0.85
NewMessagePostAuthorFunction · 0.85
nextLocalMessageIdMethod · 0.80
convertTopicReplyToIdMethod · 0.80
sendActionMethod · 0.80

Tested by

no test coverage detected