/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once class PeerData; namespace Main { class Session; struct SendAsPeer { not_null peer; bool premiumRequired = false; friend inline auto operator<=>(SendAsPeer, SendAsPeer) = default; }; class SendAsPeers final { public: explicit SendAsPeers(not_null session); bool shouldChoose(not_null peer); void refresh(not_null peer, bool force = false); [[nodiscard]] const std::vector &list( not_null peer) const; [[nodiscard]] rpl::producer> updated() const; void saveChosen(not_null peer, not_null chosen); void setChosen(not_null peer, PeerId chosenId); [[nodiscard]] PeerId chosen(not_null peer) const; // If !list(peer).empty() then the result will be from that list. [[nodiscard]] not_null resolveChosen( not_null peer) const; [[nodiscard]] static not_null ResolveChosen( not_null peer, const std::vector &list, PeerId chosen); private: void request(not_null peer); const not_null _session; const std::vector _onlyMe; base::flat_map, std::vector> _lists; base::flat_map, crl::time> _lastRequestTime; base::flat_map, PeerId> _chosen; rpl::event_stream> _updates; rpl::lifetime _lifetime; }; } // namespace Main