| 34 | } |
| 35 | |
| 36 | void TodoLists::create( |
| 37 | const TodoListData &data, |
| 38 | SendAction action, |
| 39 | Fn<void()> done, |
| 40 | Fn<void(QString)> fail) { |
| 41 | _session->api().sendAction(action); |
| 42 | |
| 43 | const auto history = action.history; |
| 44 | const auto peer = history->peer; |
| 45 | const auto topicRootId = action.replyTo.messageId |
| 46 | ? action.replyTo.topicRootId |
| 47 | : 0; |
| 48 | const auto monoforumPeerId = action.replyTo.monoforumPeerId; |
| 49 | auto sendFlags = MTPmessages_SendMedia::Flags(0); |
| 50 | if (action.replyTo) { |
| 51 | sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to; |
| 52 | } |
| 53 | const auto clearCloudDraft = action.clearDraft; |
| 54 | if (clearCloudDraft) { |
| 55 | sendFlags |= MTPmessages_SendMedia::Flag::f_clear_draft; |
| 56 | history->clearLocalDraft(topicRootId, monoforumPeerId); |
| 57 | history->clearCloudDraft(topicRootId, monoforumPeerId); |
| 58 | history->startSavingCloudDraft(topicRootId, monoforumPeerId); |
| 59 | } |
| 60 | const auto silentPost = ShouldSendSilent(peer, action.options); |
| 61 | const auto starsPaid = std::min( |
| 62 | peer->starsPerMessageChecked(), |
| 63 | action.options.starsApproved); |
| 64 | if (silentPost) { |
| 65 | sendFlags |= MTPmessages_SendMedia::Flag::f_silent; |
| 66 | } |
| 67 | if (action.options.scheduled) { |
| 68 | sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_date; |
| 69 | if (action.options.scheduleRepeatPeriod) { |
| 70 | sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_repeat_period; |
| 71 | } |
| 72 | } |
| 73 | if (action.options.shortcutId) { |
| 74 | sendFlags |= MTPmessages_SendMedia::Flag::f_quick_reply_shortcut; |
| 75 | } |
| 76 | if (action.options.effectId) { |
| 77 | sendFlags |= MTPmessages_SendMedia::Flag::f_effect; |
| 78 | } |
| 79 | if (action.options.suggest) { |
| 80 | sendFlags |= MTPmessages_SendMedia::Flag::f_suggested_post; |
| 81 | } |
| 82 | if (starsPaid) { |
| 83 | action.options.starsApproved -= starsPaid; |
| 84 | sendFlags |= MTPmessages_SendMedia::Flag::f_allow_paid_stars; |
| 85 | } |
| 86 | const auto sendAs = action.options.sendAs; |
| 87 | if (sendAs) { |
| 88 | sendFlags |= MTPmessages_SendMedia::Flag::f_send_as; |
| 89 | } |
| 90 | auto &histories = history->owner().histories(); |
| 91 | const auto randomId = base::RandomValue<uint64>(); |
| 92 | histories.sendPreparedMessage( |
| 93 | history, |
nothing calls this directly
no test coverage detected