/* 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 #include "mtproto/sender.h" class ApiWrap; class PeerData; class UserData; class ChannelData; namespace Main { class Session; } // namespace Main namespace Api { inline constexpr auto kCommunityRequestCreated = "COMMUNITY_REQUEST_CREATED"_cs; inline constexpr auto kCommunityPeersTooMuch = "COMMUNITY_PEERS_TOO_MUCH"_cs; struct CommunityPeerRequest { not_null peer; UserData *requestedBy = nullptr; TimeId date = 0; bool visible = false; }; struct CommunityPeerRequestsSlice { std::vector list; QString nextOffset; int totalCount = 0; }; struct CommunityParticipantJoinedChats { std::vector> creatorChats; std::vector> joinedChats; }; enum class PeerLinkAction { Visible, Hidden, Deleted, }; class Communities final { public: explicit Communities(not_null api); void create( const QString &title, const QString &about, not_null peer, bool hidden, Fn)> done, Fn fail); void addPeerLink( not_null community, not_null peer, bool visible, Fn done, Fn fail); void removePeerLink( not_null community, not_null peer, Fn done, Fn fail); void requestJoinedCommunities( Fn> &)> done); void toggleCollapsedInDialogs( not_null community, bool collapsed); void requestPeerLinkRequests( not_null community, const QString &offset, int limit, Fn done); void togglePeerLinkRequestApproval( not_null community, not_null peer, bool reject, Fn done, Fn fail); void toggleAllPeerLinkRequestApproval( not_null community, bool reject, Fn done, Fn fail); void toggleParticipantBanned( not_null community, not_null participant, bool unban, Fn done, Fn fail); void requestParticipantJoinedChats( not_null community, not_null participant, Fn done); private: void togglePeerLink( not_null community, not_null peer, PeerLinkAction action, Fn done, Fn fail); const not_null _session; MTP::Sender _api; base::flat_set> _collapseRequests; base::flat_map< not_null, mtpRequestId> _peerLinkRequestsRequests; mtpRequestId _joinedRequestId = 0; }; [[nodiscard]] int CommunityPeersLimit(not_null session); [[nodiscard]] int CommunityBotPeersLimit(not_null session); [[nodiscard]] QString CommunityPeersLimitToast(not_null peer); } // namespace Api