| 1816 | } |
| 1817 | |
| 1818 | void ApiWrap::appendChatsSlice( |
| 1819 | ChatsProcess &process, |
| 1820 | std::vector<Data::DialogInfo> &to, |
| 1821 | std::vector<Data::DialogInfo> &&from, |
| 1822 | int splitIndex) { |
| 1823 | Expects(_settings != nullptr); |
| 1824 | |
| 1825 | const auto types = _settings->types; |
| 1826 | const auto goodByTypes = [&](const Data::DialogInfo &info) { |
| 1827 | return ((types & SettingsFromDialogsType(info.type)) != 0); |
| 1828 | }; |
| 1829 | auto filtered = ranges::views::all( |
| 1830 | from |
| 1831 | ) | ranges::views::filter([&](const Data::DialogInfo &info) { |
| 1832 | if (goodByTypes(info)) { |
| 1833 | return true; |
| 1834 | } else if (info.migratedToChannelId |
| 1835 | && (((types & Settings::Type::PublicGroups) != 0) |
| 1836 | || ((types & Settings::Type::PrivateGroups) != 0))) { |
| 1837 | return true; |
| 1838 | } |
| 1839 | return false; |
| 1840 | }); |
| 1841 | to.reserve(to.size() + from.size()); |
| 1842 | for (auto &info : filtered) { |
| 1843 | const auto nextIndex = to.size(); |
| 1844 | if (info.migratedToChannelId) { |
| 1845 | const auto toPeerId = PeerId(info.migratedToChannelId); |
| 1846 | const auto i = process.indexByPeer.find(toPeerId); |
| 1847 | if (i != process.indexByPeer.end() |
| 1848 | && Data::AddMigrateFromSlice( |
| 1849 | to[i->second], |
| 1850 | info, |
| 1851 | splitIndex, |
| 1852 | int(_splits.size()))) { |
| 1853 | continue; |
| 1854 | } else if (!goodByTypes(info)) { |
| 1855 | continue; |
| 1856 | } |
| 1857 | } |
| 1858 | const auto &[i, ok] = process.indexByPeer.emplace( |
| 1859 | info.peerId, |
| 1860 | nextIndex); |
| 1861 | if (ok) { |
| 1862 | to.push_back(std::move(info)); |
| 1863 | } |
| 1864 | to[i->second].splits.push_back(splitIndex); |
| 1865 | to[i->second].messagesCountPerSplit.push_back(0); |
| 1866 | } |
| 1867 | } |
| 1868 | |
| 1869 | void ApiWrap::requestMessagesSlice() { |
| 1870 | Expects(_chatProcess != nullptr); |
nothing calls this directly
no test coverage detected