Add chatPhotoInfo.has_animation.

GitOrigin-RevId: d209507fdd59dd154c6acd297c6c7496b6356029
This commit is contained in:
levlam 2020-07-08 22:59:31 +03:00
parent 6476e05d1e
commit 8477f329f5
7 changed files with 77 additions and 40 deletions

View File

@ -309,11 +309,16 @@ poll id:int64 question:string options:vector<pollOption> total_voter_count:int32
//@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;
//@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
//@has_animation True, if the photo has animated variant
profilePhoto id:int64 small:file big:file has_animation:Bool = ProfilePhoto;
//@description Contains basic information about the photo of a chat @small A small (160x160) chat photo variant in JPEG format. The file can be downloaded only before the photo is changed @big A big (640x640) chat photo variant in JPEG format. The file can be downloaded only before the photo is changed
chatPhotoInfo small:file big:file = ChatPhotoInfo;
//@description Contains basic information about the photo of a chat
//@small A small (160x160) chat photo variant in JPEG format. The file can be downloaded only before the photo is changed
//@big A big (640x640) chat photo variant in JPEG format. The file can be downloaded only before the photo is changed
//@has_animation True, if the photo has animated variant
chatPhotoInfo small:file big:file has_animation:Bool = ChatPhotoInfo;
//@class UserType @description Represents the type of a user. The following types are possible: regular users, deleted users and bots
@ -377,22 +382,34 @@ inputChatPhotoStatic photo:InputFile = InputChatPhoto;
inputChatPhotoAnimation animation:InputFile main_frame_timestamp:double = InputChatPhoto;
//@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
//@phone_number Phone number of the user @status Current online status of the user @profile_photo Profile photo of the user; may be null
//@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
//@phone_number Phone number of the user
//@status Current online status of the user
//@profile_photo Profile photo of the user; may be null
//@is_contact The user is a contact of the current user
//@is_mutual_contact The user is a contact of the current user and the current user is a contact of the user
//@is_verified True, if the user is verified @is_support True, if the user is Telegram support account
//@is_verified True, if the user is verified
//@is_support True, if the user is Telegram support account
//@restriction_reason If non-empty, it contains a human-readable description of the reason why access to this user must be restricted
//@is_scam True, if many users reported this user as a scam
//@have_access If false, the user is inaccessible, and the only information known about the user is inside this class. It can't be passed to any method except GetUser @type Type of the user @language_code IETF language tag of the user's language; only available to bots
//@have_access If false, the user is inaccessible, and the only information known about the user is inside this class. It can't be passed to any method except GetUser
//@type Type of the user
//@language_code IETF language tag of the user's language; only available to bots
user id:int32 first_name:string last_name:string username:string phone_number:string status:UserStatus profile_photo:profilePhoto is_contact:Bool is_mutual_contact:Bool is_verified:Bool is_support:Bool restriction_reason:string is_scam:Bool have_access:Bool type:UserType language_code:string = User;
//@description Contains full information about a user
//@photo User profile photo; may be null
//@is_blocked True, if the user is blocked by the current user
//@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
//@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
//@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: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
@ -455,8 +472,11 @@ chatMemberStatusLeft = ChatMemberStatus;
chatMemberStatusBanned banned_until_date:int32 = ChatMemberStatus;
//@description A user with information about joining/leaving a chat @user_id User identifier of the chat member @inviter_user_id Identifier of a user that invited/promoted/banned this member in the chat; 0 if unknown
//@joined_chat_date Point in time (Unix timestamp) when the user joined a chat @status Status of the member in the chat @bot_info If the user is a bot, information about the bot; may be null. Can be null even for a bot if the bot is not a chat member
//@description A user with information about joining/leaving a chat @user_id User identifier of the chat member
//@inviter_user_id Identifier of a user that invited/promoted/banned this member in the chat; 0 if unknown
//@joined_chat_date Point in time (Unix timestamp) when the user joined a chat
//@status Status of the member in the chat
//@bot_info If the user is a bot, information about the bot; may be null. Can be null even for a bot if the bot is not a chat member
chatMember user_id:int32 inviter_user_id:int32 joined_chat_date:int32 status:ChatMemberStatus bot_info:botInfo = ChatMember;
//@description Contains a list of chat members @total_count Approximate total count of chat members found @members A list of chat members

Binary file not shown.

View File

@ -13791,10 +13791,9 @@ td_api::object_ptr<td_api::UserStatus> ContactsManager::get_user_status_object(U
}
td_api::object_ptr<td_api::updateUser> ContactsManager::get_update_unknown_user_object(UserId user_id) {
return td_api::make_object<td_api::updateUser>(
td_api::make_object<td_api::user>(user_id.get(), "", "", "", "", td_api::make_object<td_api::userStatusEmpty>(),
get_profile_photo_object(nullptr, nullptr), false, false, false, false, "",
false, false, td_api::make_object<td_api::userTypeUnknown>(), ""));
return td_api::make_object<td_api::updateUser>(td_api::make_object<td_api::user>(
user_id.get(), "", "", "", "", td_api::make_object<td_api::userStatusEmpty>(), nullptr, false, false, false,
false, "", false, false, td_api::make_object<td_api::userTypeUnknown>(), ""));
}
int32 ContactsManager::get_user_id_object(UserId user_id, const char *source) const {
@ -13826,9 +13825,9 @@ tl_object_ptr<td_api::user> ContactsManager::get_user_object(UserId user_id, con
return make_tl_object<td_api::user>(
user_id.get(), u->first_name, u->last_name, u->username, u->phone_number, get_user_status_object(user_id, u),
get_profile_photo_object(td_->file_manager_.get(), &u->photo), u->is_contact, u->is_mutual_contact,
u->is_verified, u->is_support, get_restriction_reason_description(u->restriction_reasons), u->is_scam,
u->is_received, std::move(type), u->language_code);
get_profile_photo_object(td_->file_manager_.get(), u->photo), u->is_contact, u->is_mutual_contact, u->is_verified,
u->is_support, get_restriction_reason_description(u->restriction_reasons), u->is_scam, u->is_received,
std::move(type), u->language_code);
}
vector<int32> ContactsManager::get_user_ids_object(const vector<UserId> &user_ids, const char *source) const {

View File

@ -165,7 +165,7 @@ ProfilePhoto get_profile_photo(FileManager *file_manager, UserId user_id, int64
auto profile_photo = move_tl_object_as<telegram_api::userProfilePhoto>(profile_photo_ptr);
auto dc_id = DcId::create(profile_photo->dc_id_);
result.is_animated = (profile_photo->flags_ & telegram_api::userProfilePhoto::HAS_VIDEO_MASK) != 0;
result.has_animation = (profile_photo->flags_ & telegram_api::userProfilePhoto::HAS_VIDEO_MASK) != 0;
result.id = profile_photo->photo_id_;
result.small_file_id =
register_photo(file_manager, {DialogId(user_id), user_access_hash, false}, result.id, 0, "",
@ -184,13 +184,13 @@ ProfilePhoto get_profile_photo(FileManager *file_manager, UserId user_id, int64
}
tl_object_ptr<td_api::profilePhoto> get_profile_photo_object(FileManager *file_manager,
const ProfilePhoto *profile_photo) {
if (profile_photo == nullptr || !profile_photo->small_file_id.is_valid()) {
const ProfilePhoto &profile_photo) {
if (!profile_photo.small_file_id.is_valid()) {
return nullptr;
}
return td_api::make_object<td_api::profilePhoto>(profile_photo->id,
file_manager->get_file_object(profile_photo->small_file_id),
file_manager->get_file_object(profile_photo->big_file_id));
return td_api::make_object<td_api::profilePhoto>(
profile_photo.id, file_manager->get_file_object(profile_photo.small_file_id),
file_manager->get_file_object(profile_photo.big_file_id), profile_photo.has_animation);
}
bool operator==(const ProfilePhoto &lhs, const ProfilePhoto &rhs) {
@ -208,7 +208,7 @@ bool operator==(const ProfilePhoto &lhs, const ProfilePhoto &rhs) {
<< ", second profilePhoto: " << rhs;
return false;
}
return lhs.is_animated == rhs.is_animated && !id_differs;
return lhs.has_animation == rhs.has_animation && !id_differs;
}
bool operator!=(const ProfilePhoto &lhs, const ProfilePhoto &rhs) {
@ -218,7 +218,7 @@ bool operator!=(const ProfilePhoto &lhs, const ProfilePhoto &rhs) {
StringBuilder &operator<<(StringBuilder &string_builder, const ProfilePhoto &profile_photo) {
return string_builder << "<id = " << profile_photo.id << ", small_file_id = " << profile_photo.small_file_id
<< ", big_file_id = " << profile_photo.big_file_id
<< ", is_animated = " << profile_photo.is_animated << ">";
<< ", has_animation = " << profile_photo.has_animation << ">";
}
DialogPhoto get_dialog_photo(FileManager *file_manager, DialogId dialog_id, int64 dialog_access_hash,
@ -233,7 +233,7 @@ DialogPhoto get_dialog_photo(FileManager *file_manager, DialogId dialog_id, int6
auto chat_photo = move_tl_object_as<telegram_api::chatPhoto>(chat_photo_ptr);
auto dc_id = DcId::create(chat_photo->dc_id_);
result.is_animated = (chat_photo->flags_ & telegram_api::chatPhoto::HAS_VIDEO_MASK) != 0;
result.has_animation = (chat_photo->flags_ & telegram_api::chatPhoto::HAS_VIDEO_MASK) != 0;
result.small_file_id =
register_photo(file_manager, {dialog_id, dialog_access_hash, false}, 0, 0, "",
std::move(chat_photo->photo_small_), DialogId(), 0, dc_id, PhotoFormat::Jpeg);
@ -256,7 +256,8 @@ tl_object_ptr<td_api::chatPhotoInfo> get_chat_photo_info_object(FileManager *fil
return nullptr;
}
return td_api::make_object<td_api::chatPhotoInfo>(file_manager->get_file_object(dialog_photo->small_file_id),
file_manager->get_file_object(dialog_photo->big_file_id));
file_manager->get_file_object(dialog_photo->big_file_id),
dialog_photo->has_animation);
}
vector<FileId> dialog_photo_get_file_ids(const DialogPhoto &dialog_photo) {
@ -280,7 +281,7 @@ DialogPhoto as_dialog_photo(const Photo &photo) {
result.big_file_id = size.file_id;
}
}
result.is_animated = !photo.animations.empty();
result.has_animation = !photo.animations.empty();
if (!result.small_file_id.is_valid() || !result.big_file_id.is_valid()) {
LOG(ERROR) << "Failed to convert " << photo << " to chat photo";
return DialogPhoto();
@ -291,7 +292,7 @@ DialogPhoto as_dialog_photo(const Photo &photo) {
bool operator==(const DialogPhoto &lhs, const DialogPhoto &rhs) {
return lhs.small_file_id == rhs.small_file_id && lhs.big_file_id == rhs.big_file_id &&
lhs.is_animated == rhs.is_animated;
lhs.has_animation == rhs.has_animation;
}
bool operator!=(const DialogPhoto &lhs, const DialogPhoto &rhs) {
@ -301,7 +302,7 @@ bool operator!=(const DialogPhoto &lhs, const DialogPhoto &rhs) {
StringBuilder &operator<<(StringBuilder &string_builder, const DialogPhoto &dialog_photo) {
return string_builder << "<small_file_id = " << dialog_photo.small_file_id
<< ", big_file_id = " << dialog_photo.big_file_id
<< ", is_animated = " << dialog_photo.is_animated << ">";
<< ", has_animation = " << dialog_photo.has_animation << ">";
}
PhotoSize get_secret_thumbnail_photo_size(FileManager *file_manager, BufferSlice bytes, DialogId owner_dialog_id,

View File

@ -36,7 +36,7 @@ struct Dimensions {
struct DialogPhoto {
FileId small_file_id;
FileId big_file_id;
bool is_animated = false;
bool has_animation = false;
};
struct ProfilePhoto : public DialogPhoto {
@ -82,7 +82,7 @@ td_api::object_ptr<td_api::minithumbnail> get_minithumbnail_object(const string
ProfilePhoto get_profile_photo(FileManager *file_manager, UserId user_id, int64 user_access_hash,
tl_object_ptr<telegram_api::UserProfilePhoto> &&profile_photo_ptr);
tl_object_ptr<td_api::profilePhoto> get_profile_photo_object(FileManager *file_manager,
const ProfilePhoto *profile_photo);
const ProfilePhoto &profile_photo);
bool operator==(const ProfilePhoto &lhs, const ProfilePhoto &rhs);
bool operator!=(const ProfilePhoto &lhs, const ProfilePhoto &rhs);

View File

@ -6,9 +6,9 @@
//
#pragma once
#include "td/telegram/Photo.h"
#include "td/telegram/files/FileId.hpp"
#include "td/telegram/Photo.h"
#include "td/telegram/Version.h"
#include "td/utils/logging.h"
#include "td/utils/tl_helpers.h"
@ -30,14 +30,30 @@ void parse(Dimensions &dimensions, ParserT &parser) {
template <class StorerT>
void store(const DialogPhoto &dialog_photo, StorerT &storer) {
store(dialog_photo.small_file_id, storer);
store(dialog_photo.big_file_id, storer);
bool has_file_ids = dialog_photo.small_file_id.is_valid() || dialog_photo.big_file_id.is_valid();
BEGIN_STORE_FLAGS();
STORE_FLAG(has_file_ids);
STORE_FLAG(dialog_photo.has_animation);
END_STORE_FLAGS();
if (has_file_ids) {
store(dialog_photo.small_file_id, storer);
store(dialog_photo.big_file_id, storer);
}
}
template <class ParserT>
void parse(DialogPhoto &dialog_photo, ParserT &parser) {
parse(dialog_photo.small_file_id, parser);
parse(dialog_photo.big_file_id, parser);
bool has_file_ids = true;
if (parser.version() >= static_cast<int32>(Version::AddDialogPhotoHasAnimation)) {
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_file_ids);
PARSE_FLAG(dialog_photo.has_animation);
END_PARSE_FLAGS();
}
if (has_file_ids) {
parse(dialog_photo.small_file_id, parser);
parse(dialog_photo.big_file_id, parser);
}
}
template <class StorerT>

View File

@ -38,6 +38,7 @@ enum class Version : int32 {
SupportPolls2_0,
AddDiceEmoji,
AddAnimationStickers,
AddDialogPhotoHasAnimation,
Next
};