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

Function SendSimpleMedia

Telegram/SourceFiles/api/api_sending.cpp:68–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68void 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 }

Callers 2

SendLocationFunction · 0.85
SendVenueFunction · 0.85

Calls 15

NewMessageFlagsFunction · 0.85
ShouldSendSilentFunction · 0.85
MTP_flagsFunction · 0.85
ReplyToPlaceholderClass · 0.85
MTP_longFunction · 0.85
ShortcutIdToMTPFunction · 0.85
SuggestToMTPFunction · 0.85
apiMethod · 0.80
sendActionMethod · 0.80
sendPreparedMessageMethod · 0.80

Tested by

no test coverage detected