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

Function WhoReadExists

Telegram/SourceFiles/api/api_who_reacted.cpp:729–784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

727}
728
729bool WhoReadExists(not_null<HistoryItem*> item) {
730 if (!item->out()) {
731 return false;
732 }
733 const auto type = DetectSeenType(item);
734 const auto thread = item->topic()
735 ? (Data::Thread*)item->topic()
736 : item->history();
737 const auto unseen = (type == Ui::WhoReadType::Seen)
738 ? item->unread(thread)
739 : item->isUnreadMedia();
740 if (unseen) {
741 return false;
742 }
743 const auto history = item->history();
744 const auto peer = history->peer;
745 if (const auto user = peer->asUser()) {
746 if (user->isSelf()
747 || user->isBot()
748 || user->isServiceUser()
749 || user->readDatesPrivate()) {
750 return false;
751 }
752 const auto &appConfig = peer->session().appConfig();
753 const auto expirePeriod = appConfig.get<int>(
754 "pm_read_date_expire_period",
755 7 * 86400);
756 if (item->date() + int64(expirePeriod) <= int64(base::unixtime::now())) {
757 return false;
758 }
759 return true;
760 }
761 const auto chat = peer->asChat();
762 const auto megagroup = peer->asMegagroup();
763 if ((!chat && !megagroup)
764 || (megagroup
765 && (megagroup->flags() & ChannelDataFlag::ParticipantsHidden))
766 || (megagroup && megagroup->isMonoforum())) {
767 return false;
768 }
769 const auto &appConfig = peer->session().appConfig();
770 const auto expirePeriod = appConfig.get<int>(
771 "chat_read_mark_expire_period",
772 7 * 86400);
773 if (item->date() + int64(expirePeriod) <= int64(base::unixtime::now())) {
774 return false;
775 }
776 const auto maxCount = appConfig.get<int>(
777 "chat_read_mark_size_threshold",
778 50);
779 const auto count = megagroup ? megagroup->membersCount() : chat->count;
780 if (count <= 0 || count > maxCount) {
781 return false;
782 }
783 return true;
784}
785
786bool WhoReactedExists(

Callers 2

WhoReactedFunction · 0.85
WhoReactedExistsFunction · 0.85

Calls 15

DetectSeenTypeFunction · 0.85
unreadMethod · 0.80
isUnreadMediaMethod · 0.80
asUserMethod · 0.80
isSelfMethod · 0.80
isServiceUserMethod · 0.80
readDatesPrivateMethod · 0.80
asChatMethod · 0.80
asMegagroupMethod · 0.80
membersCountMethod · 0.80
outMethod · 0.45
topicMethod · 0.45

Tested by

no test coverage detected