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

Method feedUpdate

Telegram/SourceFiles/api/api_updates.cpp:1592–2847  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1590}
1591
1592void Updates::feedUpdate(const MTPUpdate &update) {
1593 switch (update.type()) {
1594
1595 // New messages.
1596 case mtpc_updateNewMessage: {
1597 auto &d = update.c_updateNewMessage();
1598 if (!requestingDifference()) {
1599 const auto peerId = PeerFromMessage(d.vmessage());
1600 const auto peer = session().data().peerLoaded(peerId);
1601 if (peerId && !peer) {
1602 MTP_LOG(0, ("getDifference "
1603 "{ good - getting peer for updateNewMessage }%1"
1604 ).arg(_session->mtp().isTestMode() ? " TESTMODE" : ""));
1605 return getDifference();
1606 }
1607 }
1608 updateAndApply(d.vpts().v, d.vpts_count().v, update);
1609 } break;
1610
1611 case mtpc_updateNewChannelMessage: {
1612 auto &d = update.c_updateNewChannelMessage();
1613 auto channel = session().data().channelLoaded(peerToChannel(PeerFromMessage(d.vmessage())));
1614 {
1615 // Todo delete.
1616 const auto messageId = IdFromMessage(d.vmessage());
1617 if (const auto history = channel ? session().data().historyLoaded(channel) : nullptr) {
1618 if (history->isUnknownMessageDeleted(messageId)) {
1619 LOG(("Unknown message deleted detected for channel %1, message %2")
1620 .arg(channel->id.value & PeerId::kChatTypeMask)
1621 .arg(messageId.bare));
1622 }
1623 }
1624 }
1625 if (!requestingDifference() && !channel) {
1626 MTP_LOG(0, ("getDifference "
1627 "{ good - after not all data loaded in updateNewChannelMessage }%1"
1628 ).arg(_session->mtp().isTestMode() ? " TESTMODE" : ""));
1629 if (!_byMinChannelTimer.isActive()) { // getDifference after timeout
1630 _byMinChannelTimer.callOnce(PtsWaiter::kWaitForSkippedTimeout);
1631 }
1632 return;
1633 }
1634 if (channel && !_handlingChannelDifference) {
1635 if (channel->ptsRequesting()) { // skip global updates while getting channel difference
1636 MTP_LOG(0, ("Skipping new channel message because getting the difference."));
1637 return;
1638 }
1639 channel->ptsUpdateAndApply(d.vpts().v, d.vpts_count().v, update);
1640 } else {
1641 applyUpdateNoPtsCheck(update);
1642 }
1643 } break;
1644
1645 case mtpc_updateMessageID: {
1646 const auto &d = update.c_updateMessageID();
1647 const auto randomId = d.vrandom_id().v;
1648 if (const auto id = session().data().messageIdByRandomId(randomId)) {
1649 const auto newId = d.vid().v;

Callers

nothing calls this directly

Calls 15

PeerFromMessageFunction · 0.85
peerToChannelFunction · 0.85
IdFromMessageFunction · 0.85
AppClass · 0.85
peerFromMTPFunction · 0.85
peerFromChannelFunction · 0.85
peerFromUserFunction · 0.85
peerFromChatFunction · 0.85
LastseenFromMTPFunction · 0.85
qsFunction · 0.85
FormatPhoneFunction · 0.85

Tested by

no test coverage detected