2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Fix pending web pages applying.

Fixes #7091.
This commit is contained in:
John Preston
2020-06-05 13:03:45 +04:00
parent d0994019ca
commit a586b18dfb
3 changed files with 62 additions and 54 deletions

View File

@@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwidget.h"
#include "data/data_session.h"
#include "data/data_photo.h"
#include "data/data_channel.h"
#include "data/data_document.h"
#include "ui/image/image.h"
#include "ui/text/text_entity.h"
@@ -240,3 +241,45 @@ void WebPageData::replaceDocumentGoodThumbnail() {
document->setGoodThumbnailPhoto(photo);
}
}
void WebPageData::ApplyChanges(
not_null<Main::Session*> session,
ChannelData *channel,
const MTPmessages_Messages &result) {
result.match([&](
const MTPDmessages_channelMessages &data) {
if (channel) {
channel->ptsReceived(data.vpts().v);
} else {
LOG(("API Error: received messages.channelMessages "
"when no channel was passed! (WebPageData::ApplyChanges)"));
}
}, [&](const auto &) {
});
const auto list = result.match([](
const MTPDmessages_messagesNotModified &) {
LOG(("API Error: received messages.messagesNotModified! "
"(WebPageData::ApplyChanges)"));
return static_cast<const QVector<MTPMessage>*>(nullptr);
}, [&](const auto &data) {
session->data().processUsers(data.vusers());
session->data().processChats(data.vchats());
return &data.vmessages().v;
});
if (!list) {
return;
}
for (const auto &message : *list) {
message.match([&](const MTPDmessage &data) {
if (const auto media = data.vmedia()) {
media->match([&](const MTPDmessageMediaWebPage &data) {
session->data().processWebpage(data.vwebpage());
}, [&](const auto &) {
});
}
}, [&](const auto &) {
});
}
session->data().sendWebPageGamePollNotifications();
}

View File

@@ -10,6 +10,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_photo.h"
#include "data/data_document.h"
class ChannelData;
namespace Main {
class Session;
} // namespace Main
enum class WebPageType {
Photo,
Video,
@@ -50,6 +56,11 @@ struct WebPageData {
const QString &newAuthor,
int newPendingTill);
static void ApplyChanges(
not_null<Main::Session*> session,
ChannelData *channel,
const MTPmessages_Messages &result);
WebPageId id = 0;
WebPageType type = WebPageType::Article;
QString url;