diff --git a/Telegram/SourceFiles/api/api_sending.cpp b/Telegram/SourceFiles/api/api_sending.cpp index 0a97d3e4f..dc305ed1b 100644 --- a/Telegram/SourceFiles/api/api_sending.cpp +++ b/Telegram/SourceFiles/api/api_sending.cpp @@ -63,7 +63,8 @@ void SendExistingMedia( MessageToSend &&message, not_null media, Fn inputMedia, - Data::FileOrigin origin) { + Data::FileOrigin origin, + std::optional localMessageId) { const auto history = message.action.history; const auto peer = history->peer; const auto session = &history->session(); @@ -75,7 +76,9 @@ void SendExistingMedia( const auto newId = FullMsgId( peer->id, - session->data().nextLocalMessageId()); + localMessageId + ? (*localMessageId) + : session->data().nextLocalMessageId()); const auto randomId = base::RandomValue(); auto flags = NewMessageFlags(peer); @@ -185,7 +188,8 @@ void SendExistingMedia( void SendExistingDocument( MessageToSend &&message, - not_null document) { + not_null document, + std::optional localMessageId) { const auto inputMedia = [=] { return MTP_inputMediaDocument( MTP_flags(0), @@ -197,7 +201,8 @@ void SendExistingDocument( std::move(message), document, inputMedia, - document->stickerOrGifOrigin()); + document->stickerOrGifOrigin(), + std::move(localMessageId)); if (document->sticker()) { document->owner().stickers().incrementSticker(document); @@ -206,7 +211,8 @@ void SendExistingDocument( void SendExistingPhoto( MessageToSend &&message, - not_null photo) { + not_null photo, + std::optional localMessageId) { const auto inputMedia = [=] { return MTP_inputMediaPhoto( MTP_flags(0), @@ -217,7 +223,8 @@ void SendExistingPhoto( std::move(message), photo, inputMedia, - Data::FileOrigin()); + Data::FileOrigin(), + std::move(localMessageId)); } bool SendDice(MessageToSend &message) { diff --git a/Telegram/SourceFiles/api/api_sending.h b/Telegram/SourceFiles/api/api_sending.h index 8fe38b4e6..e17c66f3e 100644 --- a/Telegram/SourceFiles/api/api_sending.h +++ b/Telegram/SourceFiles/api/api_sending.h @@ -23,11 +23,13 @@ struct SendAction; void SendExistingDocument( MessageToSend &&message, - not_null document); + not_null document, + std::optional localMessageId = std::nullopt); void SendExistingPhoto( MessageToSend &&message, - not_null photo); + not_null photo, + std::optional localMessageId = std::nullopt); bool SendDice(MessageToSend &message);