Add mtpeer.access_hash parsing in push notifications.
GitOrigin-RevId: bba57f1a73627383a2e363c821475cdc6a3dcaad
This commit is contained in:
parent
0afbff7256
commit
078417d423
@ -5080,10 +5080,10 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
|
||||
bool is_received = (flags & USER_FLAG_IS_INACCESSIBLE) == 0;
|
||||
|
||||
User *u = add_user(user_id, "on_get_user");
|
||||
if ((have_access_hash || u->access_hash == -1) && u->access_hash != user->access_hash_) {
|
||||
LOG(DEBUG) << "Access hash has changed for " << user_id << " from " << u->access_hash << " to "
|
||||
<< user->access_hash_;
|
||||
u->access_hash = user->access_hash_;
|
||||
auto access_hash = have_access_hash ? user->access_hash_ : -1;
|
||||
if (have_access_hash && u->access_hash != access_hash) {
|
||||
LOG(DEBUG) << "Access hash has changed for " << user_id << " from " << u->access_hash << " to " << access_hash;
|
||||
u->access_hash = access_hash;
|
||||
u->is_changed = true;
|
||||
}
|
||||
if (is_received) {
|
||||
@ -5135,13 +5135,6 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
|
||||
LOG_IF(ERROR, need_location_bot && !is_inline_bot)
|
||||
<< "Receive not inline bot " << user_id << " which needs user location from " << source;
|
||||
|
||||
if (is_received && !u->is_received) {
|
||||
u->is_received = true;
|
||||
|
||||
LOG(DEBUG) << "Receive " << user_id;
|
||||
u->need_send_update = true;
|
||||
}
|
||||
|
||||
if (is_deleted) {
|
||||
// just in case
|
||||
is_verified = false;
|
||||
@ -5163,7 +5156,7 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
|
||||
can_join_groups != u->can_join_groups || can_read_all_group_messages != u->can_read_all_group_messages ||
|
||||
restriction_reason != u->restriction_reason || is_inline_bot != u->is_inline_bot ||
|
||||
inline_query_placeholder != u->inline_query_placeholder || need_location_bot != u->need_location_bot) {
|
||||
LOG_IF(ERROR, is_bot != u->is_bot && !is_deleted && !u->is_deleted)
|
||||
LOG_IF(ERROR, is_bot != u->is_bot && !is_deleted && !u->is_deleted && u->is_received)
|
||||
<< "User.is_bot has changed for " << user_id << "/" << u->username << " from " << source << " from "
|
||||
<< u->is_bot << " to " << is_bot;
|
||||
u->is_verified = is_verified;
|
||||
@ -5186,6 +5179,13 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
|
||||
u->is_changed = true;
|
||||
}
|
||||
|
||||
if (is_received && !u->is_received) {
|
||||
u->is_received = true;
|
||||
|
||||
LOG(DEBUG) << "Receive " << user_id;
|
||||
u->need_send_update = true;
|
||||
}
|
||||
|
||||
if (is_deleted != u->is_deleted) {
|
||||
u->is_deleted = is_deleted;
|
||||
|
||||
@ -6249,6 +6249,15 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo
|
||||
if (!from_database) {
|
||||
save_user(u, user_id, from_binlog);
|
||||
}
|
||||
|
||||
if (!u->is_received && u->access_hash != -1 && !u->is_repaired) {
|
||||
u->is_repaired = true;
|
||||
auto input_user = get_input_user(user_id);
|
||||
CHECK(input_user != nullptr);
|
||||
vector<tl_object_ptr<telegram_api::InputUser>> users;
|
||||
users.push_back(std::move(input_user));
|
||||
td_->create_handler<GetUsersQuery>(Promise<Unit>())->send(std::move(users));
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::update_chat(Chat *c, ChatId chat_id, bool from_binlog, bool from_database) {
|
||||
|
@ -494,6 +494,7 @@ class ContactsManager : public Actor {
|
||||
bool need_location_bot = false;
|
||||
|
||||
bool is_photo_inited = false;
|
||||
bool is_repaired = false;
|
||||
|
||||
bool is_name_changed = true;
|
||||
bool is_username_changed = true;
|
||||
|
@ -2849,7 +2849,7 @@ Status NotificationManager::process_push_notification_payload(string payload, Pr
|
||||
}
|
||||
announcement_message_text = field_value.second.get_string().str();
|
||||
} else if (field_value.first == "google.sent_time") {
|
||||
TRY_RESULT(google_sent_time, get_json_object_long_field(json_value.get_object(), "google.sent_time"));
|
||||
TRY_RESULT(google_sent_time, get_json_object_long_field(data, "google.sent_time"));
|
||||
google_sent_time /= 1000;
|
||||
if (sent_date - 28 * 86400 <= google_sent_time && google_sent_time <= sent_date + 5) {
|
||||
sent_date = narrow_cast<int32>(google_sent_time);
|
||||
@ -3062,6 +3062,37 @@ Status NotificationManager::process_push_notification_payload(string payload, Pr
|
||||
// chat title or sender name for PINNED_*
|
||||
loc_args.erase(loc_args.begin());
|
||||
|
||||
if (sender_user_id.is_valid() && !td_->contacts_manager_->have_user_force(sender_user_id)) {
|
||||
int64 sender_access_hash = -1;
|
||||
telegram_api::object_ptr<telegram_api::UserProfilePhoto> sender_photo;
|
||||
TRY_RESULT(mtpeer, get_json_object_field(custom, "mtpeer", JsonValue::Type::Object));
|
||||
if (mtpeer.type() != JsonValue::Type::Null) {
|
||||
TRY_RESULT(ah, get_json_object_string_field(mtpeer.get_object(), "ah"));
|
||||
if (!ah.empty()) {
|
||||
TRY_RESULT(sender_access_hash_safe, to_integer_safe<int64>(ah));
|
||||
sender_access_hash = sender_access_hash_safe;
|
||||
}
|
||||
TRY_RESULT(ph, get_json_object_field(mtpeer.get_object(), "ph", JsonValue::Type::Object));
|
||||
if (ph.type() != JsonValue::Type::Null) {
|
||||
// TODO parse photo
|
||||
}
|
||||
}
|
||||
|
||||
int32 flags = telegram_api::user::FIRST_NAME_MASK | telegram_api::user::MIN_MASK;
|
||||
if (sender_access_hash != -1) {
|
||||
flags |= telegram_api::user::ACCESS_HASH_MASK;
|
||||
}
|
||||
if (sender_photo != nullptr) {
|
||||
flags |= telegram_api::user::PHOTO_MASK;
|
||||
}
|
||||
auto user = telegram_api::make_object<telegram_api::user>(
|
||||
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, sender_user_id.get(), sender_access_hash, sender_name, string(), string(),
|
||||
string(), std::move(sender_photo), nullptr, 0, string(), string(), string());
|
||||
td_->contacts_manager_->on_get_user(std::move(user), "process_push_notification_payload");
|
||||
}
|
||||
|
||||
if (loc_args.size() > 1) {
|
||||
return Status::Error("Receive too much arguments");
|
||||
}
|
||||
@ -3218,7 +3249,7 @@ void NotificationManager::process_message_push_notification(DialogId dialog_id,
|
||||
CHECK(logevent_id != 0);
|
||||
}
|
||||
|
||||
if (sender_user_id.is_valid() && !td_->contacts_manager_->have_user(sender_user_id)) {
|
||||
if (sender_user_id.is_valid() && !td_->contacts_manager_->have_user_force(sender_user_id)) {
|
||||
int32 flags = telegram_api::user::FIRST_NAME_MASK | telegram_api::user::MIN_MASK;
|
||||
auto user = telegram_api::make_object<telegram_api::user>(
|
||||
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
|
Reference in New Issue
Block a user