/* 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; namespace Main { class Session; } // namespace Main namespace Api { class PeerPhoto final { public: using UserPhotoId = PhotoId; explicit PeerPhoto(not_null api); void upload(not_null peer, QImage &&image); void uploadFallback(not_null peer, QImage &&image); void updateSelf(not_null photo); void suggest(not_null peer, QImage &&image); void clear(not_null photo); void clearPersonal(not_null user); void set(not_null peer, not_null photo); void requestUserPhotos(not_null user, UserPhotoId afterId); // Non-personal photo in case a personal photo is set. void registerNonPersonalPhoto( not_null user, not_null photo); void unregisterNonPersonalPhoto(not_null user); [[nodiscard]] PhotoData *nonPersonalPhoto( not_null user) const; private: enum class UploadType { Default, Suggestion, Fallback, }; void ready(const FullMsgId &msgId, const MTPInputFile &file); void upload( not_null peer, QImage &&image, UploadType type); const not_null _session; MTP::Sender _api; struct UploadValue { not_null peer; bool fallback = false; }; base::flat_map _uploads; base::flat_set _suggestions; base::flat_map, mtpRequestId> _userPhotosRequests; base::flat_map< not_null, not_null> _nonPersonalPhotos; }; } // namespace Api