Init photo ID to invalid by default.
GitOrigin-RevId: 072cd8bbd87267e086ed9a280ba5238e5e231a84
This commit is contained in:
parent
b02b578ab9
commit
ef04c17a89
@ -3241,6 +3241,7 @@ template <class StorerT>
|
|||||||
void ContactsManager::UserFull::store(StorerT &storer) const {
|
void ContactsManager::UserFull::store(StorerT &storer) const {
|
||||||
using td::store;
|
using td::store;
|
||||||
bool has_about = !about.empty();
|
bool has_about = !about.empty();
|
||||||
|
bool has_photo = photo.id != -2;
|
||||||
BEGIN_STORE_FLAGS();
|
BEGIN_STORE_FLAGS();
|
||||||
STORE_FLAG(has_about);
|
STORE_FLAG(has_about);
|
||||||
STORE_FLAG(is_blocked);
|
STORE_FLAG(is_blocked);
|
||||||
@ -3248,18 +3249,23 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
|
|||||||
STORE_FLAG(has_private_calls);
|
STORE_FLAG(has_private_calls);
|
||||||
STORE_FLAG(can_pin_messages);
|
STORE_FLAG(can_pin_messages);
|
||||||
STORE_FLAG(need_phone_number_privacy_exception);
|
STORE_FLAG(need_phone_number_privacy_exception);
|
||||||
|
STORE_FLAG(has_photo);
|
||||||
END_STORE_FLAGS();
|
END_STORE_FLAGS();
|
||||||
if (has_about) {
|
if (has_about) {
|
||||||
store(about, storer);
|
store(about, storer);
|
||||||
}
|
}
|
||||||
store(common_chat_count, storer);
|
store(common_chat_count, storer);
|
||||||
store_time(expires_at, storer);
|
store_time(expires_at, storer);
|
||||||
|
if (has_photo) {
|
||||||
|
store(photo, storer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ParserT>
|
template <class ParserT>
|
||||||
void ContactsManager::UserFull::parse(ParserT &parser) {
|
void ContactsManager::UserFull::parse(ParserT &parser) {
|
||||||
using td::parse;
|
using td::parse;
|
||||||
bool has_about;
|
bool has_about;
|
||||||
|
bool has_photo;
|
||||||
BEGIN_PARSE_FLAGS();
|
BEGIN_PARSE_FLAGS();
|
||||||
PARSE_FLAG(has_about);
|
PARSE_FLAG(has_about);
|
||||||
PARSE_FLAG(is_blocked);
|
PARSE_FLAG(is_blocked);
|
||||||
@ -3267,12 +3273,16 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
|
|||||||
PARSE_FLAG(has_private_calls);
|
PARSE_FLAG(has_private_calls);
|
||||||
PARSE_FLAG(can_pin_messages);
|
PARSE_FLAG(can_pin_messages);
|
||||||
PARSE_FLAG(need_phone_number_privacy_exception);
|
PARSE_FLAG(need_phone_number_privacy_exception);
|
||||||
|
PARSE_FLAG(has_photo);
|
||||||
END_PARSE_FLAGS();
|
END_PARSE_FLAGS();
|
||||||
if (has_about) {
|
if (has_about) {
|
||||||
parse(about, parser);
|
parse(about, parser);
|
||||||
}
|
}
|
||||||
parse(common_chat_count, parser);
|
parse(common_chat_count, parser);
|
||||||
parse_time(expires_at, parser);
|
parse_time(expires_at, parser);
|
||||||
|
if (has_photo) {
|
||||||
|
parse(photo, parser);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
@ -9742,7 +9752,6 @@ void ContactsManager::drop_user_photos(UserId user_id, bool is_empty, bool drop_
|
|||||||
if (is_empty) {
|
if (is_empty) {
|
||||||
if (user_full->photo.id != -2) {
|
if (user_full->photo.id != -2) {
|
||||||
user_full->photo = Photo();
|
user_full->photo = Photo();
|
||||||
user_full->photo.id = -2;
|
|
||||||
user_full->is_changed = true;
|
user_full->is_changed = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -9773,7 +9782,6 @@ void ContactsManager::drop_user_full(UserId user_id) {
|
|||||||
user_full->expires_at = 0.0;
|
user_full->expires_at = 0.0;
|
||||||
|
|
||||||
user_full->photo = Photo();
|
user_full->photo = Photo();
|
||||||
user_full->photo.id = -2;
|
|
||||||
user_full->is_blocked = false;
|
user_full->is_blocked = false;
|
||||||
user_full->can_be_called = false;
|
user_full->can_be_called = false;
|
||||||
user_full->has_private_calls = false;
|
user_full->has_private_calls = false;
|
||||||
|
@ -58,6 +58,7 @@ Game::Game(UserId bot_user_id, string short_name) : bot_user_id_(bot_user_id), s
|
|||||||
if (!bot_user_id_.is_valid()) {
|
if (!bot_user_id_.is_valid()) {
|
||||||
bot_user_id_ = UserId();
|
bot_user_id_ = UserId();
|
||||||
}
|
}
|
||||||
|
photo_.id = 0; // to prevent null photo in td_api
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Game::empty() const {
|
bool Game::empty() const {
|
||||||
|
@ -1421,6 +1421,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
|
|||||||
}
|
}
|
||||||
|
|
||||||
Photo new_photo;
|
Photo new_photo;
|
||||||
|
new_photo.id = 0;
|
||||||
PhotoSize thumbnail = get_web_document_photo_size(td_->file_manager_.get(), FileType::Thumbnail, DialogId(),
|
PhotoSize thumbnail = get_web_document_photo_size(td_->file_manager_.get(), FileType::Thumbnail, DialogId(),
|
||||||
std::move(result->thumb_));
|
std::move(result->thumb_));
|
||||||
if (thumbnail.file_id.is_valid() && thumbnail.type != 'v' && thumbnail.type != 'g') {
|
if (thumbnail.file_id.is_valid() && thumbnail.type != 'v' && thumbnail.type != 'g') {
|
||||||
|
@ -1529,6 +1529,8 @@ static Result<InputMessageContent> create_input_message_content(
|
|||||||
|
|
||||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
||||||
message_photo->photo.id = file_view.remote_location().get_id();
|
message_photo->photo.id = file_view.remote_location().get_id();
|
||||||
|
} else {
|
||||||
|
message_photo->photo.id = 0;
|
||||||
}
|
}
|
||||||
message_photo->photo.date = G()->unix_time();
|
message_photo->photo.date = G()->unix_time();
|
||||||
int32 type = 'i';
|
int32 type = 'i';
|
||||||
@ -1673,13 +1675,11 @@ static Result<InputMessageContent> create_input_message_content(
|
|||||||
if (!input_invoice->photo_url_.empty()) {
|
if (!input_invoice->photo_url_.empty()) {
|
||||||
LOG(INFO) << "Can't register url " << input_invoice->photo_url_;
|
LOG(INFO) << "Can't register url " << input_invoice->photo_url_;
|
||||||
}
|
}
|
||||||
message_invoice->photo.id = -2;
|
|
||||||
} else {
|
} else {
|
||||||
auto url = r_http_url.ok().get_url();
|
auto url = r_http_url.ok().get_url();
|
||||||
auto r_invoice_file_id = td->file_manager_->from_persistent_id(url, FileType::Temp);
|
auto r_invoice_file_id = td->file_manager_->from_persistent_id(url, FileType::Temp);
|
||||||
if (r_invoice_file_id.is_error()) {
|
if (r_invoice_file_id.is_error()) {
|
||||||
LOG(INFO) << "Can't register url " << url;
|
LOG(INFO) << "Can't register url " << url;
|
||||||
message_invoice->photo.id = -2;
|
|
||||||
} else {
|
} else {
|
||||||
auto invoice_file_id = r_invoice_file_id.move_as_ok();
|
auto invoice_file_id = r_invoice_file_id.move_as_ok();
|
||||||
|
|
||||||
@ -1689,6 +1689,7 @@ static Result<InputMessageContent> create_input_message_content(
|
|||||||
s.size = input_invoice->photo_size_; // TODO use invoice_file_id size
|
s.size = input_invoice->photo_size_; // TODO use invoice_file_id size
|
||||||
s.file_id = invoice_file_id;
|
s.file_id = invoice_file_id;
|
||||||
|
|
||||||
|
message_invoice->photo.id = 0;
|
||||||
message_invoice->photo.photos.push_back(s);
|
message_invoice->photo.photos.push_back(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3258,7 +3258,6 @@ Status NotificationManager::process_push_notification_payload(string payload, bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
Photo attached_photo;
|
Photo attached_photo;
|
||||||
attached_photo.id = -2;
|
|
||||||
Document attached_document;
|
Document attached_document;
|
||||||
if (has_json_object_field(custom, "attachb64")) {
|
if (has_json_object_field(custom, "attachb64")) {
|
||||||
TRY_RESULT(attachb64, get_json_object_string_field(custom, "attachb64", false));
|
TRY_RESULT(attachb64, get_json_object_string_field(custom, "attachb64", false));
|
||||||
@ -3510,8 +3509,6 @@ class NotificationManager::AddMessagePushNotificationLogEvent {
|
|||||||
}
|
}
|
||||||
if (has_photo) {
|
if (has_photo) {
|
||||||
td::parse(photo_, parser);
|
td::parse(photo_, parser);
|
||||||
} else {
|
|
||||||
photo_.id = -2;
|
|
||||||
}
|
}
|
||||||
if (has_document) {
|
if (has_document) {
|
||||||
td::parse(document_, parser);
|
td::parse(document_, parser);
|
||||||
@ -3681,8 +3678,6 @@ class NotificationManager::EditMessagePushNotificationLogEvent {
|
|||||||
}
|
}
|
||||||
if (has_photo) {
|
if (has_photo) {
|
||||||
td::parse(photo_, parser);
|
td::parse(photo_, parser);
|
||||||
} else {
|
|
||||||
photo_.id = -2;
|
|
||||||
}
|
}
|
||||||
if (has_document) {
|
if (has_document) {
|
||||||
td::parse(document_, parser);
|
td::parse(document_, parser);
|
||||||
|
@ -575,6 +575,7 @@ Photo get_encrypted_file_photo(FileManager *file_manager, tl_object_ptr<telegram
|
|||||||
file_manager->set_encryption_key(file_id, FileEncryptionKey{photo->key_.as_slice(), photo->iv_.as_slice()});
|
file_manager->set_encryption_key(file_id, FileEncryptionKey{photo->key_.as_slice(), photo->iv_.as_slice()});
|
||||||
|
|
||||||
Photo res;
|
Photo res;
|
||||||
|
res.id = 0;
|
||||||
res.date = 0;
|
res.date = 0;
|
||||||
|
|
||||||
if (!photo->thumb_.empty()) {
|
if (!photo->thumb_.empty()) {
|
||||||
@ -594,9 +595,7 @@ Photo get_encrypted_file_photo(FileManager *file_manager, tl_object_ptr<telegram
|
|||||||
|
|
||||||
Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::Photo> &&photo, DialogId owner_dialog_id) {
|
Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::Photo> &&photo, DialogId owner_dialog_id) {
|
||||||
if (photo == nullptr || photo->get_id() == telegram_api::photoEmpty::ID) {
|
if (photo == nullptr || photo->get_id() == telegram_api::photoEmpty::ID) {
|
||||||
Photo result;
|
return Photo();
|
||||||
result.id = -2;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
CHECK(photo->get_id() == telegram_api::photo::ID);
|
CHECK(photo->get_id() == telegram_api::photo::ID);
|
||||||
return get_photo(file_manager, move_tl_object_as<telegram_api::photo>(photo), owner_dialog_id);
|
return get_photo(file_manager, move_tl_object_as<telegram_api::photo>(photo), owner_dialog_id);
|
||||||
@ -638,9 +637,7 @@ Photo get_web_document_photo(FileManager *file_manager, tl_object_ptr<telegram_a
|
|||||||
DialogId owner_dialog_id) {
|
DialogId owner_dialog_id) {
|
||||||
PhotoSize s = get_web_document_photo_size(file_manager, FileType::Photo, owner_dialog_id, std::move(web_document));
|
PhotoSize s = get_web_document_photo_size(file_manager, FileType::Photo, owner_dialog_id, std::move(web_document));
|
||||||
Photo photo;
|
Photo photo;
|
||||||
if (!s.file_id.is_valid() || s.type == 'v' || s.type == 'g') {
|
if (s.file_id.is_valid() && s.type != 'v' && s.type != 'g') {
|
||||||
photo.id = -2;
|
|
||||||
} else {
|
|
||||||
photo.id = 0;
|
photo.id = 0;
|
||||||
photo.photos.push_back(s);
|
photo.photos.push_back(s);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ struct PhotoSize {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Photo {
|
struct Photo {
|
||||||
int64 id = 0;
|
int64 id = -2;
|
||||||
int32 date = 0;
|
int32 date = 0;
|
||||||
string minithumbnail;
|
string minithumbnail;
|
||||||
vector<PhotoSize> photos;
|
vector<PhotoSize> photos;
|
||||||
|
@ -423,8 +423,6 @@ class RelatedArticle {
|
|||||||
}
|
}
|
||||||
if (has_photo) {
|
if (has_photo) {
|
||||||
parse(photo, parser);
|
parse(photo, parser);
|
||||||
} else {
|
|
||||||
photo.id = -2;
|
|
||||||
}
|
}
|
||||||
if (has_author) {
|
if (has_author) {
|
||||||
parse(author, parser);
|
parse(author, parser);
|
||||||
@ -2019,9 +2017,7 @@ unique_ptr<WebPageBlock> get_web_page_block(Td *td, tl_object_ptr<telegram_api::
|
|||||||
auto page_block = move_tl_object_as<telegram_api::pageBlockPhoto>(page_block_ptr);
|
auto page_block = move_tl_object_as<telegram_api::pageBlockPhoto>(page_block_ptr);
|
||||||
auto it = photos.find(page_block->photo_id_);
|
auto it = photos.find(page_block->photo_id_);
|
||||||
Photo photo;
|
Photo photo;
|
||||||
if (it == photos.end()) {
|
if (it != photos.end()) {
|
||||||
photo.id = -2;
|
|
||||||
} else {
|
|
||||||
photo = it->second;
|
photo = it->second;
|
||||||
}
|
}
|
||||||
string url;
|
string url;
|
||||||
@ -2071,9 +2067,7 @@ unique_ptr<WebPageBlock> get_web_page_block(Td *td, tl_object_ptr<telegram_api::
|
|||||||
? photos.find(page_block->poster_photo_id_)
|
? photos.find(page_block->poster_photo_id_)
|
||||||
: photos.end();
|
: photos.end();
|
||||||
Photo poster_photo;
|
Photo poster_photo;
|
||||||
if (it == photos.end()) {
|
if (it != photos.end()) {
|
||||||
poster_photo.id = -2;
|
|
||||||
} else {
|
|
||||||
poster_photo = it->second;
|
poster_photo = it->second;
|
||||||
}
|
}
|
||||||
Dimensions dimensions;
|
Dimensions dimensions;
|
||||||
@ -2088,9 +2082,7 @@ unique_ptr<WebPageBlock> get_web_page_block(Td *td, tl_object_ptr<telegram_api::
|
|||||||
auto page_block = move_tl_object_as<telegram_api::pageBlockEmbedPost>(page_block_ptr);
|
auto page_block = move_tl_object_as<telegram_api::pageBlockEmbedPost>(page_block_ptr);
|
||||||
auto it = photos.find(page_block->author_photo_id_);
|
auto it = photos.find(page_block->author_photo_id_);
|
||||||
Photo author_photo;
|
Photo author_photo;
|
||||||
if (it == photos.end()) {
|
if (it != photos.end()) {
|
||||||
author_photo.id = -2;
|
|
||||||
} else {
|
|
||||||
author_photo = it->second;
|
author_photo = it->second;
|
||||||
}
|
}
|
||||||
return td::make_unique<WebPageBlockEmbeddedPost>(
|
return td::make_unique<WebPageBlockEmbeddedPost>(
|
||||||
@ -2215,9 +2207,7 @@ unique_ptr<WebPageBlock> get_web_page_block(Td *td, tl_object_ptr<telegram_api::
|
|||||||
auto it = (related_article->flags_ & telegram_api::pageRelatedArticle::PHOTO_ID_MASK) != 0
|
auto it = (related_article->flags_ & telegram_api::pageRelatedArticle::PHOTO_ID_MASK) != 0
|
||||||
? photos.find(related_article->photo_id_)
|
? photos.find(related_article->photo_id_)
|
||||||
: photos.end();
|
: photos.end();
|
||||||
if (it == photos.end()) {
|
if (it != photos.end()) {
|
||||||
article.photo.id = -2;
|
|
||||||
} else {
|
|
||||||
article.photo = it->second;
|
article.photo = it->second;
|
||||||
}
|
}
|
||||||
article.author = std::move(related_article->author_);
|
article.author = std::move(related_article->author_);
|
||||||
|
@ -358,8 +358,6 @@ class WebPagesManager::WebPage {
|
|||||||
}
|
}
|
||||||
if (has_photo) {
|
if (has_photo) {
|
||||||
parse(photo, parser);
|
parse(photo, parser);
|
||||||
} else {
|
|
||||||
photo.id = -2;
|
|
||||||
}
|
}
|
||||||
if (has_embed) {
|
if (has_embed) {
|
||||||
parse(embed_url, parser);
|
parse(embed_url, parser);
|
||||||
|
Loading…
Reference in New Issue
Block a user