mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
@@ -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();
|
||||
}
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user