mirror of https://github.com/procxx/kepka.git
parent
d0994019ca
commit
a586b18dfb
|
@ -2633,7 +2633,9 @@ void ApiWrap::resolveWebPages() {
|
||||||
if (!ids.isEmpty()) {
|
if (!ids.isEmpty()) {
|
||||||
requestId = request(MTPmessages_GetMessages(
|
requestId = request(MTPmessages_GetMessages(
|
||||||
MTP_vector<MTPInputMessage>(ids)
|
MTP_vector<MTPInputMessage>(ids)
|
||||||
)).done([=](const MTPmessages_Messages &result, mtpRequestId requestId) {
|
)).done([=](
|
||||||
|
const MTPmessages_Messages &result,
|
||||||
|
mtpRequestId requestId) {
|
||||||
gotWebPages(nullptr, result, requestId);
|
gotWebPages(nullptr, result, requestId);
|
||||||
}).afterDelay(kSmallDelayMs).send();
|
}).afterDelay(kSmallDelayMs).send();
|
||||||
}
|
}
|
||||||
|
@ -2642,7 +2644,9 @@ void ApiWrap::resolveWebPages() {
|
||||||
reqsByIndex[i.value().first] = request(MTPchannels_GetMessages(
|
reqsByIndex[i.value().first] = request(MTPchannels_GetMessages(
|
||||||
i.key()->inputChannel,
|
i.key()->inputChannel,
|
||||||
MTP_vector<MTPInputMessage>(i.value().second)
|
MTP_vector<MTPInputMessage>(i.value().second)
|
||||||
)).done([=, channel = i.key()](const MTPmessages_Messages &result, mtpRequestId requestId) {
|
)).done([=, channel = i.key()](
|
||||||
|
const MTPmessages_Messages &result,
|
||||||
|
mtpRequestId requestId) {
|
||||||
gotWebPages(channel, result, requestId);
|
gotWebPages(channel, result, requestId);
|
||||||
}).afterDelay(kSmallDelayMs).send();
|
}).afterDelay(kSmallDelayMs).send();
|
||||||
}
|
}
|
||||||
|
@ -2957,58 +2961,8 @@ void ApiWrap::refreshFileReference(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &msgs, mtpRequestId req) {
|
void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &result, mtpRequestId req) {
|
||||||
const QVector<MTPMessage> *v = 0;
|
WebPageData::ApplyChanges(&session(), channel, result);
|
||||||
switch (msgs.type()) {
|
|
||||||
case mtpc_messages_messages: {
|
|
||||||
auto &d = msgs.c_messages_messages();
|
|
||||||
_session->data().processUsers(d.vusers());
|
|
||||||
_session->data().processChats(d.vchats());
|
|
||||||
v = &d.vmessages().v;
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case mtpc_messages_messagesSlice: {
|
|
||||||
auto &d = msgs.c_messages_messagesSlice();
|
|
||||||
_session->data().processUsers(d.vusers());
|
|
||||||
_session->data().processChats(d.vchats());
|
|
||||||
v = &d.vmessages().v;
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case mtpc_messages_channelMessages: {
|
|
||||||
auto &d = msgs.c_messages_channelMessages();
|
|
||||||
if (channel) {
|
|
||||||
channel->ptsReceived(d.vpts().v);
|
|
||||||
} else {
|
|
||||||
LOG(("API Error: received messages.channelMessages when no channel was passed! (ApiWrap::gotWebPages)"));
|
|
||||||
}
|
|
||||||
_session->data().processUsers(d.vusers());
|
|
||||||
_session->data().processChats(d.vchats());
|
|
||||||
v = &d.vmessages().v;
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case mtpc_messages_messagesNotModified: {
|
|
||||||
LOG(("API Error: received messages.messagesNotModified! (ApiWrap::gotWebPages)"));
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!v) return;
|
|
||||||
|
|
||||||
auto indices = base::flat_map<uint64, int>(); // copied from feedMsgs
|
|
||||||
for (auto i = 0, l = v->size(); i != l; ++i) {
|
|
||||||
const auto msgId = IdFromMessage(v->at(i));
|
|
||||||
indices.emplace((uint64(uint32(msgId)) << 32) | uint64(i), i);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto &[position, index] : indices) {
|
|
||||||
const auto item = _session->data().addNewMessage(
|
|
||||||
v->at(index),
|
|
||||||
MTPDmessage_ClientFlags(),
|
|
||||||
NewMessageType::Existing);
|
|
||||||
if (item) {
|
|
||||||
_session->data().requestItemResize(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto i = _webPagesPending.begin(); i != _webPagesPending.cend();) {
|
for (auto i = _webPagesPending.begin(); i != _webPagesPending.cend();) {
|
||||||
if (i.value() == req) {
|
if (i.value() == req) {
|
||||||
if (i.key()->pendingTill > 0) {
|
if (i.key()->pendingTill > 0) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
|
#include "data/data_channel.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "ui/image/image.h"
|
#include "ui/image/image.h"
|
||||||
#include "ui/text/text_entity.h"
|
#include "ui/text/text_entity.h"
|
||||||
|
@ -240,3 +241,45 @@ void WebPageData::replaceDocumentGoodThumbnail() {
|
||||||
document->setGoodThumbnailPhoto(photo);
|
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_photo.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
|
|
||||||
|
class ChannelData;
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
enum class WebPageType {
|
enum class WebPageType {
|
||||||
Photo,
|
Photo,
|
||||||
Video,
|
Video,
|
||||||
|
@ -50,6 +56,11 @@ struct WebPageData {
|
||||||
const QString &newAuthor,
|
const QString &newAuthor,
|
||||||
int newPendingTill);
|
int newPendingTill);
|
||||||
|
|
||||||
|
static void ApplyChanges(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
ChannelData *channel,
|
||||||
|
const MTPmessages_Messages &result);
|
||||||
|
|
||||||
WebPageId id = 0;
|
WebPageId id = 0;
|
||||||
WebPageType type = WebPageType::Article;
|
WebPageType type = WebPageType::Article;
|
||||||
QString url;
|
QString url;
|
||||||
|
|
Loading…
Reference in New Issue