Pass UserId to Contact::Contact.

This commit is contained in:
levlam 2021-03-29 08:20:54 +03:00
parent f5ab187bb2
commit b5655ddab6
5 changed files with 15 additions and 12 deletions

View File

@ -17,7 +17,7 @@
namespace td { namespace td {
Contact::Contact(string phone_number, string first_name, string last_name, string vcard, int32 user_id) Contact::Contact(string phone_number, string first_name, string last_name, string vcard, UserId user_id)
: phone_number_(std::move(phone_number)) : phone_number_(std::move(phone_number))
, first_name_(std::move(first_name)) , first_name_(std::move(first_name))
, last_name_(std::move(last_name)) , last_name_(std::move(last_name))
@ -96,7 +96,8 @@ Result<Contact> process_input_message_contact(tl_object_ptr<td_api::InputMessage
return Status::Error(400, "vCard must be encoded in UTF-8"); return Status::Error(400, "vCard must be encoded in UTF-8");
} }
return Contact(contact->phone_number_, contact->first_name_, contact->last_name_, contact->vcard_, contact->user_id_); return Contact(contact->phone_number_, contact->first_name_, contact->last_name_, contact->vcard_,
UserId(contact->user_id_));
} }
} // namespace td } // namespace td

View File

@ -40,7 +40,7 @@ class Contact {
public: public:
Contact() = default; Contact() = default;
Contact(string phone_number, string first_name, string last_name, string vcard, int32 user_id); Contact(string phone_number, string first_name, string last_name, string vcard, UserId user_id);
void set_user_id(UserId user_id); void set_user_id(UserId user_id);

View File

@ -5322,7 +5322,8 @@ std::pair<vector<UserId>, vector<int32>> ContactsManager::import_contacts(
td_->create_handler<ImportContactsQuery>(std::move(promise)) td_->create_handler<ImportContactsQuery>(std::move(promise))
->send(transform(contacts, ->send(transform(contacts,
[](const tl_object_ptr<td_api::contact> &contact) { [](const tl_object_ptr<td_api::contact> &contact) {
return Contact(contact->phone_number_, contact->first_name_, contact->last_name_, string(), 0); return Contact(contact->phone_number_, contact->first_name_, contact->last_name_, string(),
UserId());
}), }),
random_id); random_id);
return {}; return {};
@ -5512,7 +5513,7 @@ std::pair<vector<UserId>, vector<int32>> ContactsManager::change_imported_contac
auto new_contacts = transform(std::move(contacts), [](tl_object_ptr<td_api::contact> &&contact) { auto new_contacts = transform(std::move(contacts), [](tl_object_ptr<td_api::contact> &&contact) {
return Contact(std::move(contact->phone_number_), std::move(contact->first_name_), std::move(contact->last_name_), return Contact(std::move(contact->phone_number_), std::move(contact->first_name_), std::move(contact->last_name_),
string(), 0); string(), UserId());
}); });
vector<size_t> new_contacts_unique_id(new_contacts.size()); vector<size_t> new_contacts_unique_id(new_contacts.size());

View File

@ -1423,10 +1423,10 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
auto inline_message_contact = auto inline_message_contact =
static_cast<const telegram_api::botInlineMessageMediaContact *>(result->send_message_.get()); static_cast<const telegram_api::botInlineMessageMediaContact *>(result->send_message_.get());
Contact c(inline_message_contact->phone_number_, inline_message_contact->first_name_, Contact c(inline_message_contact->phone_number_, inline_message_contact->first_name_,
inline_message_contact->last_name_, inline_message_contact->vcard_, 0); inline_message_contact->last_name_, inline_message_contact->vcard_, UserId());
contact->contact_ = c.get_contact_object(); contact->contact_ = c.get_contact_object();
} else { } else {
Contact c(std::move(result->description_), std::move(result->title_), string(), string(), 0); Contact c(std::move(result->description_), std::move(result->title_), string(), string(), UserId());
contact->contact_ = c.get_contact_object(); contact->contact_ = c.get_contact_object();
} }
contact->thumbnail_ = register_thumbnail(std::move(result->thumb_)); contact->thumbnail_ = register_thumbnail(std::move(result->thumb_));

View File

@ -1514,7 +1514,7 @@ InlineMessageContent create_inline_message_content(Td *td, FileId file_id,
auto inline_message_contact = move_tl_object_as<telegram_api::botInlineMessageMediaContact>(inline_message); auto inline_message_contact = move_tl_object_as<telegram_api::botInlineMessageMediaContact>(inline_message);
result.message_content = make_unique<MessageContact>( result.message_content = make_unique<MessageContact>(
Contact(std::move(inline_message_contact->phone_number_), std::move(inline_message_contact->first_name_), Contact(std::move(inline_message_contact->phone_number_), std::move(inline_message_contact->first_name_),
std::move(inline_message_contact->last_name_), std::move(inline_message_contact->vcard_), 0)); std::move(inline_message_contact->last_name_), std::move(inline_message_contact->vcard_), UserId()));
reply_markup = std::move(inline_message_contact->reply_markup_); reply_markup = std::move(inline_message_contact->reply_markup_);
break; break;
} }
@ -3915,7 +3915,7 @@ unique_ptr<MessageContent> get_secret_message_content(
} }
return make_unique<MessageContact>( return make_unique<MessageContact>(
Contact(std::move(message_contact->phone_number_), std::move(message_contact->first_name_), Contact(std::move(message_contact->phone_number_), std::move(message_contact->first_name_),
std::move(message_contact->last_name_), string(), message_contact->user_id_)); std::move(message_contact->last_name_), string(), UserId(message_contact->user_id_)));
} }
case secret_api::decryptedMessageMediaWebPage::ID: { case secret_api::decryptedMessageMediaWebPage::ID: {
auto media_web_page = move_tl_object_as<secret_api::decryptedMessageMediaWebPage>(media); auto media_web_page = move_tl_object_as<secret_api::decryptedMessageMediaWebPage>(media);
@ -4082,9 +4082,10 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
td->contacts_manager_->get_user_id_object(UserId(message_contact->user_id_), td->contacts_manager_->get_user_id_object(UserId(message_contact->user_id_),
"MessageMediaContact"); // to ensure updateUser "MessageMediaContact"); // to ensure updateUser
} }
return make_unique<MessageContact>(Contact( return make_unique<MessageContact>(
std::move(message_contact->phone_number_), std::move(message_contact->first_name_), Contact(std::move(message_contact->phone_number_), std::move(message_contact->first_name_),
std::move(message_contact->last_name_), std::move(message_contact->vcard_), message_contact->user_id_)); std::move(message_contact->last_name_), std::move(message_contact->vcard_),
UserId(message_contact->user_id_)));
} }
case telegram_api::messageMediaDocument::ID: { case telegram_api::messageMediaDocument::ID: {
auto message_document = move_tl_object_as<telegram_api::messageMediaDocument>(media); auto message_document = move_tl_object_as<telegram_api::messageMediaDocument>(media);