| 218 | } |
| 219 | |
| 220 | void Polls::create( |
| 221 | const PollData &data, |
| 222 | const TextWithEntities &text, |
| 223 | SendAction action, |
| 224 | Fn<void()> done, |
| 225 | Fn<void(bool fileReferenceExpired)> fail) { |
| 226 | _session->api().sendAction(action); |
| 227 | |
| 228 | const auto history = action.history; |
| 229 | const auto peer = history->peer; |
| 230 | const auto topicRootId = action.replyTo.messageId |
| 231 | ? action.replyTo.topicRootId |
| 232 | : 0; |
| 233 | const auto monoforumPeerId = action.replyTo.monoforumPeerId; |
| 234 | auto sendFlags = MTPmessages_SendMedia::Flags(0); |
| 235 | if (action.replyTo) { |
| 236 | sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to; |
| 237 | } |
| 238 | const auto clearCloudDraft = action.clearDraft; |
| 239 | if (clearCloudDraft) { |
| 240 | sendFlags |= MTPmessages_SendMedia::Flag::f_clear_draft; |
| 241 | history->clearLocalDraft(topicRootId, monoforumPeerId); |
| 242 | history->clearCloudDraft(topicRootId, monoforumPeerId); |
| 243 | history->startSavingCloudDraft(topicRootId, monoforumPeerId); |
| 244 | } |
| 245 | const auto silentPost = ShouldSendSilent(peer, action.options); |
| 246 | const auto starsPaid = std::min( |
| 247 | peer->starsPerMessageChecked(), |
| 248 | action.options.starsApproved); |
| 249 | if (silentPost) { |
| 250 | sendFlags |= MTPmessages_SendMedia::Flag::f_silent; |
| 251 | } |
| 252 | if (action.options.scheduled) { |
| 253 | sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_date; |
| 254 | if (action.options.scheduleRepeatPeriod) { |
| 255 | sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_repeat_period; |
| 256 | } |
| 257 | } |
| 258 | if (action.options.shortcutId) { |
| 259 | sendFlags |= MTPmessages_SendMedia::Flag::f_quick_reply_shortcut; |
| 260 | } |
| 261 | if (action.options.effectId) { |
| 262 | sendFlags |= MTPmessages_SendMedia::Flag::f_effect; |
| 263 | } |
| 264 | if (action.options.suggest) { |
| 265 | sendFlags |= MTPmessages_SendMedia::Flag::f_suggested_post; |
| 266 | } |
| 267 | if (starsPaid) { |
| 268 | action.options.starsApproved -= starsPaid; |
| 269 | sendFlags |= MTPmessages_SendMedia::Flag::f_allow_paid_stars; |
| 270 | } |
| 271 | const auto sendAs = action.options.sendAs; |
| 272 | if (sendAs) { |
| 273 | sendFlags |= MTPmessages_SendMedia::Flag::f_send_as; |
| 274 | } |
| 275 | auto sentEntities = Api::EntitiesToMTP( |
| 276 | _session, |
| 277 | text.entities, |
no test coverage detected