| 98 | } |
| 99 | |
| 100 | MTPInputMedia PrepareUploadedDocument( |
| 101 | not_null<HistoryItem*> item, |
| 102 | RemoteFileInfo info) { |
| 103 | if (!item || !item->media() || !item->media()->document()) { |
| 104 | return MTP_inputMediaEmpty(); |
| 105 | } |
| 106 | using Flag = MTPDinputMediaUploadedDocument::Flag; |
| 107 | const auto spoiler = item->media() && item->media()->hasSpoiler(); |
| 108 | const auto ttlSeconds = item->media() |
| 109 | ? item->media()->ttlSeconds() |
| 110 | : 0; |
| 111 | const auto flags = (spoiler ? Flag::f_spoiler : Flag()) |
| 112 | | (info.thumb ? Flag::f_thumb : Flag()) |
| 113 | | (item->groupId() ? Flag::f_nosound_video : Flag()) |
| 114 | | (info.forceFile ? Flag::f_force_file : Flag()) |
| 115 | | (info.attachedStickers.empty() ? Flag::f_stickers : Flag()) |
| 116 | | (ttlSeconds ? Flag::f_ttl_seconds : Flag()) |
| 117 | | (info.videoCover ? Flag::f_video_cover : Flag()); |
| 118 | const auto document = item->media()->document(); |
| 119 | return MTP_inputMediaUploadedDocument( |
| 120 | MTP_flags(flags), |
| 121 | info.file, |
| 122 | info.thumb.value_or(MTPInputFile()), |
| 123 | MTP_string(document->mimeString()), |
| 124 | ComposeSendingDocumentAttributes(document), |
| 125 | MTP_vector<MTPInputDocument>( |
| 126 | ranges::to<QVector<MTPInputDocument>>(info.attachedStickers)), |
| 127 | info.videoCover.value_or(MTPInputPhoto()), |
| 128 | MTP_int(0), // video_timestamp |
| 129 | MTP_int(ttlSeconds)); |
| 130 | } |
| 131 | |
| 132 | bool HasAttachedStickers(MTPInputMedia media) { |
| 133 | return media.match([&](const MTPDinputMediaUploadedPhoto &photo) -> bool { |
no test coverage detected