| 727 | } |
| 728 | |
| 729 | bool 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 | |
| 786 | bool WhoReactedExists( |
no test coverage detected