| 243 | |
| 244 | template <typename DoneCallback, typename FailCallback> |
| 245 | mtpRequestId SuggestMessageOrMedia( |
| 246 | not_null<HistoryItem*> item, |
| 247 | const TextWithEntities &textWithEntities, |
| 248 | Data::WebPageDraft webpage, |
| 249 | SendOptions options, |
| 250 | DoneCallback &&done, |
| 251 | FailCallback &&fail, |
| 252 | std::optional<MTPInputMedia> inputMedia) { |
| 253 | const auto wasMedia = item->media(); |
| 254 | if (!inputMedia && wasMedia && wasMedia->allowsEditCaption()) { |
| 255 | if (const auto photo = wasMedia->photo()) { |
| 256 | inputMedia = MTP_inputMediaPhoto( |
| 257 | MTP_flags(0), |
| 258 | photo->mtpInput(), |
| 259 | MTPint(), // ttl_seconds |
| 260 | MTPInputDocument()); // video |
| 261 | } else if (const auto document = wasMedia->document()) { |
| 262 | inputMedia = MTP_inputMediaDocument( |
| 263 | MTP_flags(0), |
| 264 | document->mtpInput(), |
| 265 | MTPInputPhoto(), // video_cover |
| 266 | MTPint(), // video_timestamp |
| 267 | MTPint(), // ttl_seconds |
| 268 | MTPstring()); // query |
| 269 | } |
| 270 | } |
| 271 | if (inputMedia) { |
| 272 | return SuggestMedia( |
| 273 | item, |
| 274 | textWithEntities, |
| 275 | webpage, |
| 276 | options, |
| 277 | std::move(done), |
| 278 | std::move(fail), |
| 279 | inputMedia); |
| 280 | } |
| 281 | return SuggestMessage( |
| 282 | item, |
| 283 | textWithEntities, |
| 284 | webpage, |
| 285 | options, |
| 286 | std::move(done), |
| 287 | std::move(fail)); |
| 288 | } |
| 289 | |
| 290 | template <typename DoneCallback, typename FailCallback> |
| 291 | mtpRequestId EditMessage( |
no test coverage detected