| 100 | |
| 101 | template <typename DoneCallback, typename FailCallback> |
| 102 | mtpRequestId SuggestMessage( |
| 103 | not_null<HistoryItem*> item, |
| 104 | const TextWithEntities &textWithEntities, |
| 105 | Data::WebPageDraft webpage, |
| 106 | SendOptions options, |
| 107 | DoneCallback &&done, |
| 108 | FailCallback &&fail) { |
| 109 | Expects(options.suggest.exists); |
| 110 | Expects(!options.scheduled); |
| 111 | |
| 112 | const auto session = &item->history()->session(); |
| 113 | const auto api = &session->api(); |
| 114 | |
| 115 | const auto thread = item->history()->amMonoforumAdmin() |
| 116 | ? item->savedSublist() |
| 117 | : (Data::Thread*)item->history(); |
| 118 | auto action = SendAction(thread, options); |
| 119 | action.replyTo = FullReplyTo{ |
| 120 | .messageId = item->fullId(), |
| 121 | .monoforumPeerId = (item->history()->amMonoforumAdmin() |
| 122 | ? item->sublistPeerId() |
| 123 | : PeerId()), |
| 124 | }; |
| 125 | |
| 126 | auto message = MessageToSend(std::move(action)); |
| 127 | message.textWithTags = TextWithTags{ |
| 128 | textWithEntities.text, |
| 129 | TextUtilities::ConvertEntitiesToTextTags(textWithEntities.entities) |
| 130 | }; |
| 131 | message.webPage = webpage; |
| 132 | api->sendMessage(std::move(message)); |
| 133 | |
| 134 | const auto requestId = -1; |
| 135 | crl::on_main(session, [=] { |
| 136 | const auto type = u"MESSAGE_NOT_MODIFIED"_q; |
| 137 | if constexpr (ErrorWithId<FailCallback>) { |
| 138 | fail(type, requestId); |
| 139 | } else if constexpr (ErrorWithoutId<FailCallback>) { |
| 140 | fail(type); |
| 141 | } else if constexpr (WithoutCallback<FailCallback>) { |
| 142 | fail(); |
| 143 | } else { |
| 144 | t_bad_callback(fail); |
| 145 | } |
| 146 | }); |
| 147 | return requestId; |
| 148 | } |
| 149 | |
| 150 | template <typename DoneCallback, typename FailCallback> |
| 151 | mtpRequestId SuggestMedia( |
no test coverage detected