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

Function ApplyPeerCloudDraft

Telegram/SourceFiles/data/data_drafts.cpp:73–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void ApplyPeerCloudDraft(
74 not_null<Main::Session*> session,
75 PeerId peerId,
76 MsgId topicRootId,
77 PeerId monoforumPeerId,
78 const MTPDdraftMessage &draft) {
79 const auto history = session->data().history(peerId);
80 const auto date = draft.vdate().v;
81 if (history->skipCloudDraftUpdate(topicRootId, monoforumPeerId, date)) {
82 return;
83 }
84 const auto textWithTags = TextWithTags{
85 qs(draft.vmessage()),
86 TextUtilities::ConvertEntitiesToTextTags(
87 Api::EntitiesFromMTP(
88 session,
89 draft.ventities().value_or_empty()))
90 };
91 auto replyTo = draft.vreply_to()
92 ? ReplyToFromMTP(history, *draft.vreply_to())
93 : FullReplyTo();
94 replyTo.topicRootId = topicRootId;
95 replyTo.monoforumPeerId = monoforumPeerId;
96 auto webpage = WebPageDraft{
97 .invert = draft.is_invert_media(),
98 .removed = draft.is_no_webpage(),
99 };
100 if (const auto media = draft.vmedia()) {
101 media->match([&](const MTPDmessageMediaWebPage &data) {
102 const auto parsed = session->data().processWebpage(
103 data.vwebpage());
104 if (!parsed->failed) {
105 webpage.forceLargeMedia = data.is_force_large_media();
106 webpage.forceSmallMedia = data.is_force_small_media();
107 webpage.manual = data.is_manual();
108 webpage.url = parsed->url;
109 webpage.id = parsed->id;
110 }
111 }, [](const auto &) {});
112 }
113 auto suggest = SuggestOptions();
114 if (!history->suggestDraftAllowed()) {
115 // Don't apply suggest options in unsupported chats.
116 } else if (const auto suggested = draft.vsuggested_post()) {
117 const auto &data = suggested->data();
118 suggest.exists = 1;
119 suggest.date = data.vschedule_date().value_or_empty();
120 const auto price = CreditsAmountFromTL(data.vprice());
121 suggest.priceWhole = price.whole();
122 suggest.priceNano = price.nano();
123 suggest.ton = price.ton() ? 1 : 0;
124 }
125 auto cloudDraft = std::make_unique<Draft>(
126 textWithTags,
127 replyTo,
128 suggest,
129 MessageCursor(Ui::kQFixedMax, Ui::kQFixedMax, Ui::kQFixedMax),
130 std::move(webpage));

Callers 4

applyTopicMethod · 0.85
applyMonoforumDialogMethod · 0.85
feedUpdateMethod · 0.85
applyDialogMethod · 0.85

Calls 15

qsFunction · 0.85
EntitiesFromMTPFunction · 0.85
ReplyToFromMTPFunction · 0.85
FullReplyToClass · 0.85
SuggestOptionsClass · 0.85
CreditsAmountFromTLFunction · 0.85
MessageCursorClass · 0.85
GetEnhancedBoolFunction · 0.85
skipCloudDraftUpdateMethod · 0.80
processWebpageMethod · 0.80
suggestDraftAllowedMethod · 0.80
wholeMethod · 0.80

Tested by

no test coverage detected