Send update with an empty User for unknown users.

GitOrigin-RevId: 470184a7277bbce3855ecad8acf955369370ff76
This commit is contained in:
levlam 2018-01-26 22:53:20 +03:00
parent aed9a9da6f
commit dc274ea3b5
11 changed files with 123 additions and 83 deletions

View File

@ -178,8 +178,9 @@ void CallbackQueriesManager::on_new_query(int32 flags, int64 callback_query_id,
td_->messages_manager_->force_create_dialog(dialog_id, "on_new_callback_query");
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateNewCallbackQuery>(callback_query_id, sender_user_id.get(), dialog_id.get(),
message_id.get(), chat_instance, std::move(payload)));
make_tl_object<td_api::updateNewCallbackQuery>(
callback_query_id, td_->contacts_manager_->get_user_id_object(sender_user_id), dialog_id.get(),
message_id.get(), chat_instance, std::move(payload)));
}
void CallbackQueriesManager::on_new_inline_query(
@ -203,7 +204,7 @@ void CallbackQueriesManager::on_new_inline_query(
}
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateNewInlineCallbackQuery>(
callback_query_id, sender_user_id.get(),
callback_query_id, td_->contacts_manager_->get_user_id_object(sender_user_id),
InlineQueriesManager::get_inline_message_id(std::move(inline_message_id)), chat_instance,
std::move(payload)));
}

View File

@ -5816,9 +5816,9 @@ void ContactsManager::update_user_full(UserFull *user_full, UserId user_id) {
if (user_full->is_changed) {
user_full->is_changed = false;
if (user_full->is_inited) {
send_closure(
G()->td(), &Td::send_update,
make_tl_object<td_api::updateUserFullInfo>(user_id.get(), get_user_full_info_object(user_id, user_full)));
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateUserFullInfo>(get_user_id_object(user_id),
get_user_full_info_object(user_id, user_full)));
}
}
}
@ -6598,8 +6598,9 @@ tl_object_ptr<td_api::chatMember> ContactsManager::get_chat_member_object(
const DialogParticipant &dialog_participant) const {
UserId participant_user_id = dialog_participant.user_id;
return make_tl_object<td_api::chatMember>(
participant_user_id.get(), dialog_participant.inviter_user_id.get(), dialog_participant.joined_date,
dialog_participant.status.get_chat_member_status_object(), get_bot_info_object(participant_user_id));
get_user_id_object(participant_user_id), get_user_id_object(dialog_participant.inviter_user_id),
dialog_participant.joined_date, dialog_participant.status.get_chat_member_status_object(),
get_bot_info_object(participant_user_id));
}
bool ContactsManager::on_get_channel_error(ChannelId channel_id, const Status &status, const string &source) {
@ -8941,6 +8942,20 @@ tl_object_ptr<td_api::UserStatus> ContactsManager::get_user_status_object(const
}
}
int32 ContactsManager::get_user_id_object(UserId user_id) const {
if (user_id.is_valid() && get_user(user_id) == nullptr && unknown_users_.count(user_id) == 0) {
LOG(ERROR) << "Have no info about " << user_id;
unknown_users_.insert(user_id);
send_closure(G()->td(), &Td::send_update,
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(td_->file_manager_.get(), nullptr),
get_link_state_object(LinkState::Unknown), get_link_state_object(LinkState::Unknown), false, "",
false, td_api::make_object<td_api::userTypeUnknown>(), "")));
}
return user_id.get();
}
tl_object_ptr<td_api::user> ContactsManager::get_user_object(UserId user_id) const {
return get_user_object(user_id, get_user(user_id));
}
@ -8966,11 +8981,12 @@ tl_object_ptr<td_api::user> ContactsManager::get_user_object(UserId user_id, con
u->language_code);
}
vector<int32> ContactsManager::get_user_ids_object(const vector<UserId> &user_ids) {
return transform(user_ids, [](UserId user_id) { return user_id.get(); });
vector<int32> ContactsManager::get_user_ids_object(const vector<UserId> &user_ids) const {
return transform(user_ids, [this](UserId user_id) { return get_user_id_object(user_id); });
}
tl_object_ptr<td_api::users> ContactsManager::get_users_object(int32 total_count, const vector<UserId> &user_ids) {
tl_object_ptr<td_api::users> ContactsManager::get_users_object(int32 total_count,
const vector<UserId> &user_ids) const {
if (total_count == -1) {
total_count = narrow_cast<int32>(user_ids.size());
}
@ -9012,7 +9028,7 @@ tl_object_ptr<td_api::basicGroupFullInfo> ContactsManager::get_basic_group_full_
const ChatFull *chat_full) const {
CHECK(chat_full != nullptr);
return make_tl_object<td_api::basicGroupFullInfo>(
chat_full->creator_user_id.get(),
get_user_id_object(chat_full->creator_user_id),
transform(chat_full->participants,
[this](const DialogParticipant &chat_participant) { return get_chat_member_object(chat_participant); }),
chat_full->invite_link);
@ -9074,7 +9090,7 @@ tl_object_ptr<td_api::secretChat> ContactsManager::get_secret_chat_object(Secret
}
get_user_force(secret_chat->user_id);
return td_api::make_object<td_api::secretChat>(
secret_chat_id.get(), secret_chat->user_id.get(), get_secret_chat_state_object(secret_chat->state),
secret_chat_id.get(), get_user_id_object(secret_chat->user_id), get_secret_chat_state_object(secret_chat->state),
secret_chat->is_outbound, secret_chat->ttl, secret_chat->key_hash, secret_chat->layer);
}

View File

@ -362,11 +362,13 @@ class ContactsManager : public Actor {
vector<UserId> get_dialog_administrators(DialogId chat_id, int left_tries, Promise<Unit> &&promise);
int32 get_user_id_object(UserId user_id) const;
tl_object_ptr<td_api::user> get_user_object(UserId user_id) const;
static vector<int32> get_user_ids_object(const vector<UserId> &user_ids);
vector<int32> get_user_ids_object(const vector<UserId> &user_ids) const;
static tl_object_ptr<td_api::users> get_users_object(int32 total_count, const vector<UserId> &user_ids);
tl_object_ptr<td_api::users> get_users_object(int32 total_count, const vector<UserId> &user_ids) const;
tl_object_ptr<td_api::userFullInfo> get_user_full_info_object(UserId user_id) const;
@ -977,6 +979,7 @@ class ContactsManager : public Actor {
std::unordered_map<UserId, User, UserIdHash> users_;
std::unordered_map<UserId, UserFull, UserIdHash> users_full_;
mutable std::unordered_set<UserId, UserIdHash> unknown_users_;
std::unordered_map<ChatId, Chat, ChatIdHash> chats_;
std::unordered_map<ChatId, ChatFull, ChatIdHash> chats_full_;

View File

@ -332,7 +332,7 @@ bool InlineQueriesManager::register_inline_message_content(
switch (inline_message->get_id()) {
case telegram_api::botInlineMessageText::ID: {
auto inline_message_text = move_tl_object_as<telegram_api::botInlineMessageText>(inline_message);
auto entities = get_message_entities(std::move(inline_message_text->entities_));
auto entities = get_message_entities(td_->contacts_manager_.get(), std::move(inline_message_text->entities_));
auto status =
MessagesManager::fix_text_message(inline_message_text->message_, entities, nullptr, false, true, true, false);
if (status.is_error()) {
@ -1733,9 +1733,10 @@ void InlineQueriesManager::on_new_query(int64 query_id, UserId sender_user_id, L
LOG(ERROR) << "Receive new inline query";
return;
}
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateNewInlineQuery>(query_id, sender_user_id.get(),
user_location.get_location_object(), query, offset));
send_closure(
G()->td(), &Td::send_update,
make_tl_object<td_api::updateNewInlineQuery>(query_id, td_->contacts_manager_->get_user_id_object(sender_user_id),
user_location.get_location_object(), query, offset));
}
void InlineQueriesManager::on_chosen_result(
@ -1752,8 +1753,8 @@ void InlineQueriesManager::on_chosen_result(
}
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateNewChosenInlineResult>(
user_id.get(), user_location.get_location_object(), query, result_id,
get_inline_message_id(std::move(input_bot_inline_message_id))));
td_->contacts_manager_->get_user_id_object(user_id), user_location.get_location_object(), query,
result_id, get_inline_message_id(std::move(input_bot_inline_message_id))));
}
bool InlineQueriesManager::update_bot_usage(UserId bot_user_id) {

View File

@ -1573,7 +1573,8 @@ vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entiti
return result;
}
vector<MessageEntity> get_message_entities(vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities) {
vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manager,
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities) {
vector<MessageEntity> entities;
entities.reserve(server_entities.size());
for (auto &entity : server_entities) {
@ -1650,6 +1651,10 @@ vector<MessageEntity> get_message_entities(vector<tl_object_ptr<telegram_api::Me
LOG(ERROR) << "Receive invalid " << user_id << " in MentionName";
continue;
}
if (!contacts_manager->have_user(user_id)) {
LOG(ERROR) << "Receive unknown " << user_id << " in MentionName";
continue;
}
entities.emplace_back(entity_mention_name->offset_, entity_mention_name->length_, user_id);
break;
}

View File

@ -135,7 +135,8 @@ vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(co
vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entities(
const vector<MessageEntity> &entities);
vector<MessageEntity> get_message_entities(vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities);
vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manager,
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities);
vector<MessageEntity> get_message_entities(vector<tl_object_ptr<secret_api::MessageEntity>> &&secret_entities);

View File

@ -8151,7 +8151,7 @@ tl_object_ptr<td_api::MessageContent> MessagesManager::get_message_content_objec
case MessageChatCreate::ID: {
const MessageChatCreate *m = static_cast<const MessageChatCreate *>(content);
return make_tl_object<td_api::messageBasicGroupChatCreate>(
m->title, ContactsManager::get_user_ids_object(m->participant_user_ids));
m->title, td_->contacts_manager_->get_user_ids_object(m->participant_user_ids));
}
case MessageChatChangeTitle::ID: {
const MessageChatChangeTitle *m = static_cast<const MessageChatChangeTitle *>(content);
@ -8167,13 +8167,13 @@ tl_object_ptr<td_api::MessageContent> MessagesManager::get_message_content_objec
return make_tl_object<td_api::messageUnsupported>();
case MessageChatAddUsers::ID: {
const MessageChatAddUsers *m = static_cast<const MessageChatAddUsers *>(content);
return make_tl_object<td_api::messageChatAddMembers>(ContactsManager::get_user_ids_object(m->user_ids));
return make_tl_object<td_api::messageChatAddMembers>(td_->contacts_manager_->get_user_ids_object(m->user_ids));
}
case MessageChatJoinedByLink::ID:
return make_tl_object<td_api::messageChatJoinByLink>();
case MessageChatDeleteUser::ID: {
const MessageChatDeleteUser *m = static_cast<const MessageChatDeleteUser *>(content);
return make_tl_object<td_api::messageChatDeleteMember>(m->user_id.get());
return make_tl_object<td_api::messageChatDeleteMember>(td_->contacts_manager_->get_user_id_object(m->user_id));
}
case MessageChatMigrateTo::ID: {
const MessageChatMigrateTo *m = static_cast<const MessageChatMigrateTo *>(content);
@ -9842,7 +9842,8 @@ void MessagesManager::on_get_dialogs(vector<tl_object_ptr<telegram_api::dialog>>
dialog->unread_mentions_count_ = 0;
}
need_update_dialog_pos |= update_dialog_draft_message(d, get_draft_message(std::move(dialog->draft_)), true, false);
need_update_dialog_pos |= update_dialog_draft_message(
d, get_draft_message(td_->contacts_manager_.get(), std::move(dialog->draft_)), true, false);
if (is_new) {
bool has_pts = (dialog->flags_ & DIALOG_FLAG_HAS_PTS) != 0;
if (last_message_id.is_valid()) {
@ -11882,7 +11883,8 @@ tl_object_ptr<td_api::ChatType> MessagesManager::get_chat_type_object(DialogId d
case DialogType::SecretChat: {
auto secret_chat_id = dialog_id.get_secret_chat_id();
auto user_id = td_->contacts_manager_->get_secret_chat_user_id(secret_chat_id);
return make_tl_object<td_api::chatTypeSecret>(secret_chat_id.get(), user_id.get());
return make_tl_object<td_api::chatTypeSecret>(secret_chat_id.get(),
td_->contacts_manager_->get_user_id_object(user_id));
}
case DialogType::None:
default:
@ -12106,7 +12108,7 @@ void MessagesManager::reset_all_notification_settings() {
}
unique_ptr<DraftMessage> MessagesManager::get_draft_message(
tl_object_ptr<telegram_api::DraftMessage> &&draft_message_ptr) {
ContactsManager *contacts_manager, tl_object_ptr<telegram_api::DraftMessage> &&draft_message_ptr) {
if (draft_message_ptr == nullptr) {
return nullptr;
}
@ -12127,7 +12129,7 @@ unique_ptr<DraftMessage> MessagesManager::get_draft_message(
}
}
auto entities = get_message_entities(std::move(draft->entities_));
auto entities = get_message_entities(contacts_manager, std::move(draft->entities_));
auto status = fix_text_message(draft->message_, entities, nullptr, true, true, true, true);
if (status.is_error()) {
LOG(ERROR) << "Receive error " << status << " while parsing draft " << draft->message_;
@ -13441,13 +13443,15 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
}
}
return make_tl_object<td_api::message>(
message->message_id.get(), message->sender_user_id.get(), dialog_id.get(), std::move(sending_state), is_outgoing,
can_edit_message(dialog_id, message, false, true), can_forward_message(dialog_id, message), can_delete_for_self,
can_delete_for_all_users, message->is_channel_post, message->contains_unread_mention, message->date,
message->edit_date, get_message_forward_info_object(message->forward_info), message->reply_to_message_id.get(),
message->ttl, message->ttl_expires_at != 0 ? std::max(message->ttl_expires_at - Time::now(), 1e-3) : message->ttl,
message->via_bot_user_id.get(), message->author_signature, message->views, message->media_album_id,
get_message_content_object(message->content.get()), get_reply_markup_object(message->reply_markup));
message->message_id.get(), td_->contacts_manager_->get_user_id_object(message->sender_user_id), dialog_id.get(),
std::move(sending_state), is_outgoing, can_edit_message(dialog_id, message, false, true),
can_forward_message(dialog_id, message), can_delete_for_self, can_delete_for_all_users, message->is_channel_post,
message->contains_unread_mention, message->date, message->edit_date,
get_message_forward_info_object(message->forward_info), message->reply_to_message_id.get(), message->ttl,
message->ttl_expires_at != 0 ? std::max(message->ttl_expires_at - Time::now(), 1e-3) : message->ttl,
td_->contacts_manager_->get_user_id_object(message->via_bot_user_id), message->author_signature, message->views,
message->media_album_id, get_message_content_object(message->content.get()),
get_reply_markup_object(message->reply_markup));
}
tl_object_ptr<td_api::messages> MessagesManager::get_messages_object(int32 total_count, DialogId dialog_id,
@ -17022,7 +17026,8 @@ void MessagesManager::on_get_game_high_scores(int64 random_id,
LOG(ERROR) << "Receive wrong score = " << score;
continue;
}
result->scores_.push_back(make_tl_object<td_api::gameHighScore>(position, user_id.get(), score));
result->scores_.push_back(
make_tl_object<td_api::gameHighScore>(position, td_->contacts_manager_->get_user_id_object(user_id), score));
}
}
@ -17112,7 +17117,7 @@ unique_ptr<MessagesManager::MessageForwardInfo> MessagesManager::get_message_for
}
tl_object_ptr<td_api::MessageForwardInfo> MessagesManager::get_message_forward_info_object(
const unique_ptr<MessageForwardInfo> &forward_info) {
const unique_ptr<MessageForwardInfo> &forward_info) const {
if (forward_info == nullptr) {
return nullptr;
}
@ -17122,9 +17127,9 @@ tl_object_ptr<td_api::MessageForwardInfo> MessagesManager::get_message_forward_i
forward_info->dialog_id.get(), forward_info->author_signature, forward_info->date,
forward_info->message_id.get(), forward_info->from_dialog_id.get(), forward_info->from_message_id.get());
}
return make_tl_object<td_api::messageForwardedFromUser>(forward_info->sender_user_id.get(), forward_info->date,
forward_info->from_dialog_id.get(),
forward_info->from_message_id.get());
return make_tl_object<td_api::messageForwardedFromUser>(
td_->contacts_manager_->get_user_id_object(forward_info->sender_user_id), forward_info->date,
forward_info->from_dialog_id.get(), forward_info->from_message_id.get());
}
Result<unique_ptr<ReplyMarkup>> MessagesManager::get_dialog_reply_markup(
@ -18386,7 +18391,7 @@ void MessagesManager::on_update_dialog_draft_message(DialogId dialog_id,
LOG(INFO) << "Ignore update chat draft in unknown " << dialog_id;
return;
}
update_dialog_draft_message(d, get_draft_message(std::move(draft_message)), true, true);
update_dialog_draft_message(d, get_draft_message(td_->contacts_manager_.get(), std::move(draft_message)), true, true);
}
bool MessagesManager::update_dialog_draft_message(Dialog *d, unique_ptr<DraftMessage> &&draft_message, bool from_update,
@ -19426,7 +19431,7 @@ tl_object_ptr<td_api::ChatEventAction> MessagesManager::get_chat_event_action_ob
case telegram_api::channelAdminLogEventActionParticipantInvite::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantInvite>(action_ptr);
auto member = td_->contacts_manager_->get_dialog_participant(ChannelId(), std::move(action->participant_));
return make_tl_object<td_api::chatEventMemberInvited>(member.user_id.get(),
return make_tl_object<td_api::chatEventMemberInvited>(td_->contacts_manager_->get_user_id_object(member.user_id),
member.status.get_chat_member_status_object());
}
case telegram_api::channelAdminLogEventActionParticipantToggleBan::ID: {
@ -19439,9 +19444,9 @@ tl_object_ptr<td_api::ChatEventAction> MessagesManager::get_chat_event_action_ob
LOG(ERROR) << old_member.user_id << " VS " << new_member.user_id;
return nullptr;
}
return make_tl_object<td_api::chatEventMemberRestricted>(old_member.user_id.get(),
old_member.status.get_chat_member_status_object(),
new_member.status.get_chat_member_status_object());
return make_tl_object<td_api::chatEventMemberRestricted>(
td_->contacts_manager_->get_user_id_object(old_member.user_id),
old_member.status.get_chat_member_status_object(), new_member.status.get_chat_member_status_object());
}
case telegram_api::channelAdminLogEventActionParticipantToggleAdmin::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantToggleAdmin>(action_ptr);
@ -19453,9 +19458,9 @@ tl_object_ptr<td_api::ChatEventAction> MessagesManager::get_chat_event_action_ob
LOG(ERROR) << old_member.user_id << " VS " << new_member.user_id;
return nullptr;
}
return make_tl_object<td_api::chatEventMemberPromoted>(old_member.user_id.get(),
old_member.status.get_chat_member_status_object(),
new_member.status.get_chat_member_status_object());
return make_tl_object<td_api::chatEventMemberPromoted>(
td_->contacts_manager_->get_user_id_object(old_member.user_id),
old_member.status.get_chat_member_status_object(), new_member.status.get_chat_member_status_object());
}
case telegram_api::channelAdminLogEventActionChangeTitle::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeTitle>(action_ptr);
@ -19569,8 +19574,8 @@ void MessagesManager::on_get_event_log(int64 random_id,
if (action == nullptr) {
continue;
}
result->events_.push_back(
make_tl_object<td_api::chatEvent>(event->id_, event->date_, user_id.get(), std::move(action)));
result->events_.push_back(make_tl_object<td_api::chatEvent>(
event->id_, event->date_, td_->contacts_manager_->get_user_id_object(user_id), std::move(action)));
}
}
@ -20191,7 +20196,7 @@ unique_ptr<MessageContent> MessagesManager::get_message_content(
string message_text, tl_object_ptr<telegram_api::MessageMedia> &&media,
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities, DialogId owner_dialog_id,
bool is_content_read, UserId via_bot_user_id, int32 *ttl, int32 send_date) const {
auto entities = get_message_entities(std::move(server_entities));
auto entities = get_message_entities(td_->contacts_manager_.get(), std::move(server_entities));
auto status = fix_text_message(message_text, entities, nullptr, true, true, true, false);
if (status.is_error()) {
if (send_date > 1497000000) { // approximate fix date

View File

@ -2175,7 +2175,8 @@ class MessagesManager : public Actor {
NotificationSettings *get_notification_settings(NotificationSettingsScope scope, bool force);
static unique_ptr<DraftMessage> get_draft_message(tl_object_ptr<telegram_api::DraftMessage> &&draft_message_ptr);
static unique_ptr<DraftMessage> get_draft_message(ContactsManager *contacts_manager,
tl_object_ptr<telegram_api::DraftMessage> &&draft_message_ptr);
static string get_media_caption(const string &message_text, string &&caption);
@ -2232,8 +2233,8 @@ class MessagesManager : public Actor {
unique_ptr<MessageForwardInfo> get_message_forward_info(
tl_object_ptr<telegram_api::messageFwdHeader> &&forward_header);
static tl_object_ptr<td_api::MessageForwardInfo> get_message_forward_info_object(
const unique_ptr<MessageForwardInfo> &forward_info);
tl_object_ptr<td_api::MessageForwardInfo> get_message_forward_info_object(
const unique_ptr<MessageForwardInfo> &forward_info) const;
void ttl_read_history_inbox(DialogId dialog_id, MessageId from_message_id, MessageId till_message_id,
double timestamp);

View File

@ -415,8 +415,9 @@ class GetPaymentReceiptQuery : public Td::ResultHandler {
}
promise_.set_value(make_tl_object<td_api::paymentReceipt>(
payment_receipt->date_, payments_provider_user_id.get(), convert_invoice(std::move(payment_receipt->invoice_)),
convert_order_info(std::move(payment_receipt->info_)),
payment_receipt->date_,
G()->td().get_actor_unsafe()->contacts_manager_->get_user_id_object(payments_provider_user_id),
convert_invoice(std::move(payment_receipt->invoice_)), convert_order_info(std::move(payment_receipt->info_)),
convert_shipping_option(std::move(payment_receipt->shipping_)),
std::move(payment_receipt->credentials_title_)));
}

View File

@ -229,7 +229,7 @@ class GetRecentMeUrlsQuery : public Td::ResultHandler {
result = nullptr;
break;
}
result->type_ = make_tl_object<td_api::tMeUrlTypeUser>(user_id.get());
result->type_ = make_tl_object<td_api::tMeUrlTypeUser>(td->contacts_manager_->get_user_id_object(user_id));
break;
}
case telegram_api::recentMeUrlChat::ID: {
@ -1947,7 +1947,7 @@ class GetChatAdministratorsRequest : public RequestActor<> {
}
void do_send_result() override {
send_result(ContactsManager::get_users_object(-1, user_ids_));
send_result(td->contacts_manager_->get_users_object(-1, user_ids_));
}
public:
@ -2075,7 +2075,8 @@ class ImportContactsRequest : public RequestActor<> {
CHECK(imported_contacts_.first.size() == contacts_.size());
CHECK(imported_contacts_.second.size() == contacts_.size());
send_result(make_tl_object<td_api::importedContacts>(
transform(imported_contacts_.first, [](UserId user_id) { return user_id.get(); }),
transform(imported_contacts_.first,
[this](UserId user_id) { return td->contacts_manager_->get_user_id_object(user_id); }),
std::move(imported_contacts_.second)));
}
@ -2097,7 +2098,7 @@ class SearchContactsRequest : public RequestActor<> {
}
void do_send_result() override {
send_result(ContactsManager::get_users_object(user_ids_.first, user_ids_.second));
send_result(td->contacts_manager_->get_users_object(user_ids_.first, user_ids_.second));
}
public:
@ -2155,7 +2156,8 @@ class ChangeImportedContactsRequest : public RequestActor<> {
CHECK(imported_contacts_.first.size() == contacts_size_);
CHECK(imported_contacts_.second.size() == contacts_size_);
send_result(make_tl_object<td_api::importedContacts>(
transform(imported_contacts_.first, [](UserId user_id) { return user_id.get(); }),
transform(imported_contacts_.first,
[this](UserId user_id) { return td->contacts_manager_->get_user_id_object(user_id); }),
std::move(imported_contacts_.second)));
}
@ -2189,7 +2191,7 @@ class GetRecentInlineBotsRequest : public RequestActor<> {
}
void do_send_result() override {
send_result(ContactsManager::get_users_object(-1, user_ids_));
send_result(td->contacts_manager_->get_users_object(-1, user_ids_));
}
public:

View File

@ -1464,9 +1464,10 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserTyping> upd
LOG(DEBUG) << "Ignore user typing in unknown " << dialog_id;
return;
}
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateUserChatAction>(dialog_id.get(), user_id.get(),
convertSendMessageAction(std::move(update->action_))));
send_closure(
G()->td(), &Td::send_update,
make_tl_object<td_api::updateUserChatAction>(dialog_id.get(), td_->contacts_manager_->get_user_id_object(user_id),
convertSendMessageAction(std::move(update->action_))));
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChatUserTyping> update, bool /*force_apply*/) {
@ -1485,9 +1486,10 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChatUserTyping>
return;
}
}
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateUserChatAction>(dialog_id.get(), user_id.get(),
convertSendMessageAction(std::move(update->action_))));
send_closure(
G()->td(), &Td::send_update,
make_tl_object<td_api::updateUserChatAction>(dialog_id.get(), td_->contacts_manager_->get_user_id_object(user_id),
convertSendMessageAction(std::move(update->action_))));
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateEncryptedChatTyping> update, bool /*force_apply*/) {
@ -1505,9 +1507,10 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateEncryptedChatTy
return;
}
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateUserChatAction>(dialog_id.get(), user_id.get(),
make_tl_object<td_api::chatActionTyping>()));
send_closure(
G()->td(), &Td::send_update,
make_tl_object<td_api::updateUserChatAction>(dialog_id.get(), td_->contacts_manager_->get_user_id_object(user_id),
make_tl_object<td_api::chatActionTyping>()));
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserStatus> update, bool /*force_apply*/) {
@ -1663,11 +1666,12 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBotShippingQuer
}
CHECK(update->shipping_address_ != nullptr);
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateNewShippingQuery>(
update->query_id_, user_id.get(), update->payload_.as_slice().str(),
get_shipping_address_object(get_shipping_address(
std::move(update->shipping_address_))))); // TODO use convert_shipping_address
send_closure(
G()->td(), &Td::send_update,
make_tl_object<td_api::updateNewShippingQuery>(
update->query_id_, td_->contacts_manager_->get_user_id_object(user_id), update->payload_.as_slice().str(),
get_shipping_address_object(
get_shipping_address(std::move(update->shipping_address_))))); // TODO use convert_shipping_address
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBotPrecheckoutQuery> update, bool /*force_apply*/) {
@ -1677,11 +1681,11 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBotPrecheckoutQ
return;
}
send_closure(
G()->td(), &Td::send_update,
make_tl_object<td_api::updateNewPreCheckoutQuery>(
update->query_id_, user_id.get(), update->currency_, update->total_amount_, update->payload_.as_slice().str(),
update->shipping_option_id_, get_order_info_object(get_order_info(std::move(update->info_)))));
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateNewPreCheckoutQuery>(
update->query_id_, td_->contacts_manager_->get_user_id_object(user_id), update->currency_,
update->total_amount_, update->payload_.as_slice().str(), update->shipping_option_id_,
get_order_info_object(get_order_info(std::move(update->info_)))));
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBotWebhookJSON> update, bool /*force_apply*/) {