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

Function EditTextMessage

Telegram/SourceFiles/api/api_editing.cpp:485–594  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

483}
484
485mtpRequestId EditTextMessage(
486 not_null<HistoryItem*> item,
487 const TextWithEntities &caption,
488 Data::WebPageDraft webpage,
489 SendOptions options,
490 Fn<void(mtpRequestId requestId)> done,
491 Fn<void(const QString &error, mtpRequestId requestId)> fail,
492 bool spoilered) {
493 const auto media = item->media();
494 if (media
495 && HistoryView::MediaEditManager::CanBeSpoilered(item)
496 && spoilered != media->hasSpoiler()) {
497 auto takeInputMedia = Fn<std::optional<MTPInputMedia>()>(nullptr);
498 auto takeFileReference = Fn<QByteArray()>(nullptr);
499 if (const auto photo = media->photo()) {
500 using Flag = MTPDinputMediaPhoto::Flag;
501 const auto flags = Flag()
502 | (media->ttlSeconds() ? Flag::f_ttl_seconds : Flag())
503 | (spoilered ? Flag::f_spoiler : Flag());
504 takeInputMedia = [=] {
505 return MTP_inputMediaPhoto(
506 MTP_flags(flags),
507 photo->mtpInput(),
508 MTP_int(media->ttlSeconds()),
509 MTPInputDocument()); // video
510 };
511 takeFileReference = [=] { return photo->fileReference(); };
512 } else if (const auto document = media->document()) {
513 using Flag = MTPDinputMediaDocument::Flag;
514 const auto videoCover = media->videoCover();
515 const auto videoTimestamp = media->videoTimestamp();
516 const auto flags = Flag()
517 | (media->ttlSeconds() ? Flag::f_ttl_seconds : Flag())
518 | (spoilered ? Flag::f_spoiler : Flag())
519 | (videoTimestamp ? Flag::f_video_timestamp : Flag())
520 | (videoCover ? Flag::f_video_cover : Flag());
521 takeInputMedia = [=] {
522 return MTP_inputMediaDocument(
523 MTP_flags(flags),
524 document->mtpInput(),
525 (videoCover
526 ? videoCover->mtpInput()
527 : MTPInputPhoto()),
528 MTP_int(media->ttlSeconds()),
529 MTP_int(videoTimestamp),
530 MTPstring()); // query
531 };
532 takeFileReference = [=] { return document->fileReference(); };
533 }
534
535 const auto usedFileReference = takeFileReference
536 ? takeFileReference()
537 : QByteArray();
538 const auto origin = item->fullId();
539 const auto api = &item->history()->session().api();
540 const auto performRequest = [=](
541 const auto &repeatRequest,
542 mtpRequestId originalRequestId) -> mtpRequestId {

Callers 4

editMethod · 0.85
saveEditMessageMethod · 0.85
editMethod · 0.85
editMethod · 0.85

Calls 15

MTP_flagsFunction · 0.85
QByteArrayClass · 0.85
EditMessageFunction · 0.85
ttlSecondsMethod · 0.80
videoCoverMethod · 0.80
videoTimestampMethod · 0.80
apiMethod · 0.80
FlagEnum · 0.50
MTP_intFunction · 0.50
mediaMethod · 0.45
hasSpoilerMethod · 0.45
photoMethod · 0.45

Tested by

no test coverage detected