Fix file reference refresh in stickers / GIFs.

Fixes #6592.
This commit is contained in:
John Preston 2019-09-30 13:25:09 +03:00
parent f75bfb4369
commit 0c30bbf40a
1 changed files with 17 additions and 10 deletions

View File

@ -29,13 +29,14 @@ template <typename MediaData>
void SendExistingMedia( void SendExistingMedia(
Api::MessageToSend &&message, Api::MessageToSend &&message,
not_null<MediaData*> media, not_null<MediaData*> media,
const MTPInputMedia &inputMedia, Fn<MTPInputMedia()> inputMedia,
Data::FileOrigin origin) { Data::FileOrigin origin) {
const auto history = message.action.history; const auto history = message.action.history;
const auto peer = history->peer; const auto peer = history->peer;
const auto session = &history->session(); const auto session = &history->session();
const auto api = &session->api(); const auto api = &session->api();
media->refreshFileReference("blabla");
message.action.clearDraft = false; message.action.clearDraft = false;
message.action.generateLocal = true; message.action.generateLocal = true;
api->sendAction(message.action); api->sendAction(message.action);
@ -115,7 +116,7 @@ void SendExistingMedia(
MTP_flags(sendFlags), MTP_flags(sendFlags),
peer->input, peer->input,
MTP_int(replyTo), MTP_int(replyTo),
inputMedia, inputMedia(),
MTP_string(captionText), MTP_string(captionText),
MTP_long(randomId), MTP_long(randomId),
MTPReplyMarkup(), MTPReplyMarkup(),
@ -154,13 +155,16 @@ void SendExistingMedia(
void SendExistingDocument( void SendExistingDocument(
Api::MessageToSend &&message, Api::MessageToSend &&message,
not_null<DocumentData*> document) { not_null<DocumentData*> document) {
const auto inputMedia = [=] {
return MTP_inputMediaDocument(
MTP_flags(0),
document->mtpInput(),
MTPint());
};
SendExistingMedia( SendExistingMedia(
std::move(message), std::move(message),
document, document,
MTP_inputMediaDocument( inputMedia,
MTP_flags(0),
document->mtpInput(),
MTPint()),
document->stickerOrGifOrigin()); document->stickerOrGifOrigin());
if (document->sticker()) { if (document->sticker()) {
@ -174,13 +178,16 @@ void SendExistingDocument(
void SendExistingPhoto( void SendExistingPhoto(
Api::MessageToSend &&message, Api::MessageToSend &&message,
not_null<PhotoData*> photo) { not_null<PhotoData*> photo) {
const auto inputMedia = [=] {
return MTP_inputMediaPhoto(
MTP_flags(0),
photo->mtpInput(),
MTPint());
};
SendExistingMedia( SendExistingMedia(
std::move(message), std::move(message),
photo, photo,
MTP_inputMediaPhoto( inputMedia,
MTP_flags(0),
photo->mtpInput(),
MTPint()),
Data::FileOrigin()); Data::FileOrigin());
} }