MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / processReceivedRichMessage

Method processReceivedRichMessage

Telegram/SourceFiles/iv/iv_instance.cpp:1603–1652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1601}
1602
1603auto Instance::processReceivedRichMessage(
1604 not_null<Main::Session*> session,
1605 FullMsgId itemId,
1606 const RichMessageGeneration &generation,
1607 const MTPmessages_Messages &result)
1608-> ProcessReceivedRichMessageResult {
1609 const auto owner = &session->data();
1610 auto processed = ProcessReceivedRichMessageResult();
1611 auto page = std::shared_ptr<const RichPage>();
1612 result.match([&](const MTPDmessages_messagesNotModified &) {
1613 LOG(("API Error: received messages.messagesNotModified!"));
1614 }, [&](const auto &data) {
1615 owner->processUsers(data.vusers());
1616 owner->processChats(data.vchats());
1617 for (const auto &message : data.vmessages().v) {
1618 if (message.type() != mtpc_message) {
1619 continue;
1620 }
1621 const auto &parsed = message.c_message();
1622 if (MsgId(parsed.vid().v) != itemId.msg) {
1623 continue;
1624 }
1625 const auto richMessage = parsed.vrich_message();
1626 page = richMessage ? ParseRichPage(session, *richMessage) : nullptr;
1627 break;
1628 }
1629 });
1630 const auto peer = owner->peer(itemId.peer);
1631 result.match([&](const MTPDmessages_channelMessages &data) {
1632 if (const auto channel = peer->asChannel()) {
1633 channel->ptsReceived(data.vpts().v);
1634 } else {
1635 LOG(("App Error: received messages.channelMessages!"));
1636 }
1637 }, [](const auto &) {});
1638 result.match([&](const MTPDmessages_messagesNotModified &) {
1639 }, [&](const auto &data) {
1640 peer->processTopics(data.vtopics());
1641 });
1642 const auto current = owner->message(itemId);
1643 if (!current
1644 || !MatchesRichMessageGeneration(not_null{ current }, generation)) {
1645 return processed;
1646 }
1647 if (page) {
1648 current->setFullRichPage(page);
1649 }
1650 processed.page = std::move(page);
1651 return processed;
1652}
1653
1654void Instance::finishRichMessageRequest(
1655 not_null<Main::Session*> session,

Callers

nothing calls this directly

Calls 13

ParseRichPageFunction · 0.85
processUsersMethod · 0.80
processChatsMethod · 0.80
asChannelMethod · 0.80
ptsReceivedMethod · 0.80
processTopicsMethod · 0.80
setFullRichPageMethod · 0.80
MsgIdClass · 0.50
dataMethod · 0.45
typeMethod · 0.45
peerMethod · 0.45

Tested by

no test coverage detected