From 68dea5663269ab9d478584a446528e3add2ad0b5 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 7 Jul 2020 14:19:54 +0300 Subject: [PATCH] Use chatPhoto instead of userProfilePhoto. GitOrigin-RevId: 4027e53be967551620c61a583bfda789a78f9581 --- td/generate/scheme/td_api.tl | 18 +++++++----------- td/generate/scheme/td_api.tlo | Bin 174940 -> 174728 bytes td/telegram/ContactsManager.cpp | 2 +- td/telegram/Photo.cpp | 12 ++---------- td/telegram/Photo.h | 1 - td/telegram/Td.cpp | 5 +++-- 6 files changed, 13 insertions(+), 25 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 11d8772c4..ec7a2e28a 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -308,7 +308,7 @@ game id:int64 short_name:string title:string text:formattedText description:stri poll id:int64 question:string options:vector total_voter_count:int32 recent_voter_user_ids:vector is_anonymous:Bool type:PollType open_period:int32 close_date:int32 is_closed:Bool = Poll; -//@description Describes a user profile photo @id Photo identifier; 0 for an empty photo. Can be used to find a photo in a list of userProfilePhotos +//@description Describes a user profile photo @id Photo identifier; 0 for an empty photo. Can be used to find a photo in a list of user profile photos //@small A small (160x160) user profile photo. The file can be downloaded only before the photo is changed @big A big (640x640) user profile photo. The file can be downloaded only before the photo is changed profilePhoto id:int64 small:file big:file = ProfilePhoto; @@ -344,15 +344,11 @@ botInfo description:string commands:vector = BotInfo; chatLocation location:location address:string = ChatLocation; -//@description Contains full information about a user profile photo @id Unique user profile photo identifier @added_date Point in time (Unix timestamp) when the photo has been added @sizes Available variants of the user photo, in different sizes -userProfilePhoto id:int64 added_date:int32 sizes:vector = UserProfilePhoto; +//@description Describes a chat or user profile photo @id Unique photo identifier @added_date Point in time (Unix timestamp) when the photo has been added @sizes Available variants of the photo, in different size +chatPhoto id:int64 added_date:int32 sizes:vector = ChatPhoto; -//@description Contains part of the list of user photos @total_count Total number of user profile photos @photos A list of photos -userProfilePhotos total_count:int32 photos:vector = UserProfilePhotos; - - -//@description Describes a chat photo @added_date Point in time (Unix timestamp) when the photo has been added @sizes Available variants of the chat photo, in different size -chatPhoto added_date:int32 sizes:vector = ChatPhoto; +//@description Contains a list of chat or user profile photos @total_count Total number of photos @photos List of photos +chatPhotos total_count:int32 photos:vector = ChatPhotos; //@description Represents a user @id User identifier @first_name First name of the user @last_name Last name of the user @username Username of the user @@ -371,7 +367,7 @@ user id:int32 first_name:string last_name:string username:string phone_number:st //@can_be_called True, if the user can be called @has_private_calls True, if the user can't be called due to their privacy settings //@need_phone_number_privacy_exception True, if the current user needs to explicitly allow to share their phone number with the user when the method addContact is used //@bio A short user bio @share_text For bots, the text that is included with the link when users share the bot @group_in_common_count Number of group chats where both the other user and the current user are a member; 0 for the current user @bot_info If the user is a bot, information about the bot; may be null -userFullInfo photo:userProfilePhoto is_blocked:Bool can_be_called:Bool has_private_calls:Bool need_phone_number_privacy_exception:Bool bio:string share_text:string group_in_common_count:int32 bot_info:botInfo = UserFullInfo; +userFullInfo photo:chatPhoto is_blocked:Bool can_be_called:Bool has_private_calls:Bool need_phone_number_privacy_exception:Bool bio:string share_text:string group_in_common_count:int32 bot_info:botInfo = UserFullInfo; //@description Represents a list of users @total_count Approximate total count of users found @user_ids A list of user identifiers users total_count:int32 user_ids:vector = Users; @@ -4011,7 +4007,7 @@ sharePhoneNumber user_id:int32 = Ok; //@description Returns the profile photos of a user. The result of this query may be outdated: some photos might have been deleted already @user_id User identifier @offset The number of photos to skip; must be non-negative @limit The maximum number of photos to be returned; up to 100 -getUserProfilePhotos user_id:int32 offset:int32 limit:int32 = UserProfilePhotos; +getUserProfilePhotos user_id:int32 offset:int32 limit:int32 = ChatPhotos; //@description Returns stickers from the installed sticker sets that correspond to a given emoji. If the emoji is not empty, favorite and recently used stickers may also be returned @emoji String representation of emoji. If empty, returns all known installed stickers @limit The maximum number of stickers to be returned diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 9ee65a4492a6422313d41c6f8f8bbead3d877cf1..173d23a696e2797478bc61a4956e9a7a0131b9aa 100644 GIT binary patch delta 380 zcmca}jjQ7-7w@Cl`c@23z_pRLos(s0E2s428JqzEA^l&Laye%tmIP$vm*f{SOn$&9 zvH1n(97UGSf>%o>cW58jyh3LKBcs~pNWIU(V11hdoaQJ%O!$xlWn4&5*ld#QA|V1Y zm@^q>9s>i2KYhV9Mvcics$(FUepEMzfUSiqD`o)krymewG?;$oF{6qENEaj2!9~t& zIvlob2SG|U=hOuBfKAzcfP?W(8-%%`pRvaX?B4AThZqk?$by{CQ(Bx_SrScJr8!59egVKyipZi`$G5j1YZO?l9W0Z5MgMC{YOU_=RQzFk^a3C{uyL?L7=A=TyivjHP$q(XnrYnRoxv+p-xjiF{=}QOz6nK#{ delta 456 zcmeCU%5~=&7w@Cl`c@23z`c>Tos(rj@|^m~GdKe_3vkU*WI5cGTsL`x_5sem+b8=4 zLW@(2Cf`+17qybpiV_6z0*dm}GILS`GV)9ECkt{&Z!XZ;z{se+SyAt^FvKW ContactsManager::get_user_full_info_object(U CHECK(user_full != nullptr); bool is_bot = is_user_bot(user_id); return make_tl_object( - get_user_profile_photo_object(td_->file_manager_.get(), user_full->photo), user_full->is_blocked, + get_chat_photo_object(td_->file_manager_.get(), user_full->photo), user_full->is_blocked, user_full->can_be_called, user_full->has_private_calls, user_full->need_phone_number_privacy_exception, is_bot ? string() : user_full->about, is_bot ? user_full->about : string(), user_full->common_chat_count, is_bot ? get_bot_info_object(user_id) : nullptr); diff --git a/td/telegram/Photo.cpp b/td/telegram/Photo.cpp index 60b87e5ec..8f525ac1f 100644 --- a/td/telegram/Photo.cpp +++ b/td/telegram/Photo.cpp @@ -654,21 +654,13 @@ tl_object_ptr get_photo_object(FileManager *file_manager, const P get_photo_sizes_object(file_manager, photo.photos)); } -tl_object_ptr get_user_profile_photo_object(FileManager *file_manager, const Photo &photo) { - if (photo.is_empty()) { - return nullptr; - } - - return td_api::make_object(photo.id.get(), photo.date, - get_photo_sizes_object(file_manager, photo.photos)); -} - tl_object_ptr get_chat_photo_object(FileManager *file_manager, const Photo &photo) { if (photo.is_empty()) { return nullptr; } - return td_api::make_object(photo.date, get_photo_sizes_object(file_manager, photo.photos)); + return td_api::make_object(photo.id.get(), photo.date, + get_photo_sizes_object(file_manager, photo.photos)); } void photo_delete_thumbnail(Photo &photo) { diff --git a/td/telegram/Photo.h b/td/telegram/Photo.h index f0ba01e15..c6643d44d 100644 --- a/td/telegram/Photo.h +++ b/td/telegram/Photo.h @@ -126,7 +126,6 @@ Photo get_encrypted_file_photo(FileManager *file_manager, tl_object_ptr web_document, DialogId owner_dialog_id); tl_object_ptr get_photo_object(FileManager *file_manager, const Photo &photo); -tl_object_ptr get_user_profile_photo_object(FileManager *file_manager, const Photo &photo); tl_object_ptr get_chat_photo_object(FileManager *file_manager, const Photo &photo); void photo_delete_thumbnail(Photo &photo); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 6b6f37a6a..4e90f99d5 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -2247,10 +2247,11 @@ class GetUserProfilePhotosRequest : public RequestActor<> { // TODO create function get_user_profile_photos_object auto result = transform(photos.second, [file_manager = td->file_manager_.get()](const Photo *photo) { CHECK(photo != nullptr); - return get_user_profile_photo_object(file_manager, *photo); + CHECK(!photo->is_empty()); + return get_chat_photo_object(file_manager, *photo); }); - send_result(make_tl_object(photos.first, std::move(result))); + send_result(make_tl_object(photos.first, std::move(result))); } public: