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

Method applyUpdateNoPtsCheck

Telegram/SourceFiles/api/api_updates.cpp:1300–1463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1298}
1299
1300void Updates::applyUpdateNoPtsCheck(const MTPUpdate &update) {
1301 switch (update.type()) {
1302 case mtpc_updateNewMessage: {
1303 auto &d = update.c_updateNewMessage();
1304 auto needToAdd = true;
1305 if (d.vmessage().type() == mtpc_message) { // index forwarded messages to links _overview
1306 const auto &data = d.vmessage().c_message();
1307 if (_session->data().updateExistingMessage(data)) { // already in blocks
1308 LOG(("Skipping message, because it is already in blocks!"));
1309 needToAdd = false;
1310 }
1311 ProcessScheduledMessageWithElapsedTime(_session, needToAdd, data);
1312 }
1313 if (needToAdd) {
1314 _session->data().addNewMessage(
1315 d.vmessage(),
1316 MessageFlags(),
1317 NewMessageType::Unread);
1318 }
1319 } break;
1320
1321 case mtpc_updateReadMessagesContents: {
1322 const auto &d = update.c_updateReadMessagesContents();
1323 auto unknownReadIds = base::flat_set<MsgId>();
1324 for (const auto &msgId : d.vmessages().v) {
1325 if (const auto item = _session->data().nonChannelMessage(msgId.v)) {
1326 if (item->isUnreadMedia() || item->isUnreadMention()) {
1327 item->markMediaAndMentionRead();
1328 _session->data().requestItemRepaint(item);
1329
1330 if (item->out()) {
1331 const auto user = item->history()->peer->asUser();
1332 if (user && !requestingDifference()) {
1333 user->madeAction(base::unixtime::now());
1334 }
1335 }
1336 item->clearMediaAsExpired();
1337 }
1338 } else {
1339 // Perhaps it was an unread mention!
1340 unknownReadIds.insert(msgId.v);
1341 }
1342 }
1343 session().api().unreadThings().mediaAndMentionsRead(unknownReadIds);
1344 } break;
1345
1346 case mtpc_updateReadHistoryInbox: {
1347 const auto &d = update.c_updateReadHistoryInbox();
1348 const auto peer = peerFromMTP(d.vpeer());
1349 if (const auto history = _session->data().historyLoaded(peer)) {
1350 const auto folderId = d.vfolder_id().value_or_empty();
1351 history->applyInboxReadUpdate(
1352 folderId,
1353 d.vmax_id().v,
1354 d.vstill_unread_count().v);
1355 }
1356 } break;
1357

Callers 2

applySkippedUpdatesMethod · 0.80
updateAndApplyMethod · 0.80

Calls 15

peerFromMTPFunction · 0.85
peerFromChannelFunction · 0.85
updateExistingMessageMethod · 0.80
nonChannelMessageMethod · 0.80
isUnreadMediaMethod · 0.80
isUnreadMentionMethod · 0.80
requestItemRepaintMethod · 0.80
asUserMethod · 0.80
madeActionMethod · 0.80
clearMediaAsExpiredMethod · 0.80

Tested by

no test coverage detected