Return back UserFull.is_blocked.

GitOrigin-RevId: 98bc31a64c4c644fd6bb9e6e895d521b17df5afa
This commit is contained in:
levlam 2020-10-17 23:38:07 +03:00
parent 9558b06021
commit 9fb26c4ea2
5 changed files with 43 additions and 14 deletions

View File

@ -406,6 +406,7 @@ user id:int32 first_name:string last_name:string username:string phone_number:st
//@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
//@supports_video_calls True, if a video call can be created with the user
//@has_private_calls True, if the user can't be called due to their privacy settings
@ -413,7 +414,7 @@ user id:int32 first_name:string last_name:string username:string phone_number:st
//@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 can_be_called:Bool supports_video_calls: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;
userFullInfo photo:chatPhoto is_blocked:Bool can_be_called:Bool supports_video_calls: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
users total_count:int32 user_ids:vector<int32> = Users;

Binary file not shown.

View File

@ -3317,7 +3317,7 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
bool has_photo = !photo.is_empty();
BEGIN_STORE_FLAGS();
STORE_FLAG(has_about);
STORE_FLAG(false);
STORE_FLAG(is_blocked);
STORE_FLAG(can_be_called);
STORE_FLAG(has_private_calls);
STORE_FLAG(can_pin_messages);
@ -3340,10 +3340,9 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
using td::parse;
bool has_about;
bool has_photo;
bool legacy_is_blocked;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_about);
PARSE_FLAG(legacy_is_blocked);
PARSE_FLAG(is_blocked);
PARSE_FLAG(can_be_called);
PARSE_FLAG(has_private_calls);
PARSE_FLAG(can_pin_messages);
@ -3359,10 +3358,6 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
if (has_photo) {
parse(photo, parser);
}
if (legacy_is_blocked) {
LOG(DEBUG) << "Ignore legacy is_blocked flag";
}
}
template <class StorerT>
@ -9164,10 +9159,6 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
td_->messages_manager_->on_update_dialog_notify_settings(DialogId(user_id), std::move(user_full->notify_settings_),
"on_get_user_full");
{
bool is_blocked = (user_full->flags_ & USER_FULL_FLAG_IS_BLOCKED) != 0;
td_->messages_manager_->on_update_dialog_is_blocked(DialogId(user_id), is_blocked);
}
{
MessageId pinned_message_id;
if ((user_full->flags_ & USER_FULL_FLAG_HAS_PINNED_MESSAGE) != 0) {
@ -9188,6 +9179,12 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
UserFull *user = add_user_full(user_id);
user->expires_at = Time::now() + USER_FULL_EXPIRE_TIME;
{
bool is_blocked = (user_full->flags_ & USER_FULL_FLAG_IS_BLOCKED) != 0;
on_update_user_full_is_blocked(user, user_id, is_blocked);
td_->messages_manager_->on_update_dialog_is_blocked(DialogId(user_id), is_blocked);
}
on_update_user_full_common_chat_count(user, user_id, user_full->common_chats_count_);
on_update_user_full_need_phone_number_privacy_exception(
user, user_id, (user_full->settings_->flags_ & telegram_api::peerSettings::NEED_CONTACTS_EXCEPTION_MASK) != 0);
@ -9970,6 +9967,29 @@ void ContactsManager::on_update_user_local_was_online(User *u, UserId user_id, i
}
}
void ContactsManager::on_update_user_is_blocked(UserId user_id, bool is_blocked) {
if (!user_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << user_id;
return;
}
UserFull *user_full = get_user_full_force(user_id);
if (user_full == nullptr) {
return;
}
on_update_user_full_is_blocked(user_full, user_id, is_blocked);
update_user_full(user_full, user_id);
}
void ContactsManager::on_update_user_full_is_blocked(UserFull *user_full, UserId user_id, bool is_blocked) {
CHECK(user_full != nullptr);
if (user_full->is_blocked != is_blocked) {
LOG(INFO) << "Receive update user full is blocked with " << user_id << " and is_blocked = " << is_blocked;
user_full->is_blocked = is_blocked;
user_full->is_changed = true;
}
}
void ContactsManager::on_update_user_common_chat_count(UserId user_id, int32 common_chat_count) {
LOG(INFO) << "Receive " << common_chat_count << " common chat count with " << user_id;
if (!user_id.is_valid()) {
@ -10245,6 +10265,7 @@ void ContactsManager::drop_user_full(UserId user_id) {
user_full->expires_at = 0.0;
user_full->photo = Photo();
user_full->is_blocked = false;
user_full->can_be_called = false;
user_full->supports_video_calls = false;
user_full->has_private_calls = false;
@ -14135,8 +14156,9 @@ tl_object_ptr<td_api::userFullInfo> ContactsManager::get_user_full_info_object(U
bool is_bot = is_user_bot(user_id);
return make_tl_object<td_api::userFullInfo>(
get_chat_photo_object(td_->file_manager_.get(), user_full->photo), user_full->can_be_called,
user_full->supports_video_calls, user_full->has_private_calls, user_full->need_phone_number_privacy_exception,
is_bot ? string() : user_full->about, is_bot ? user_full->about : string(), user_full->common_chat_count,
user_full->is_blocked, user_full->supports_video_calls, user_full->has_private_calls,
user_full->need_phone_number_privacy_exception, is_bot ? string() : user_full->about,
is_bot ? user_full->about : string(), user_full->common_chat_count,
is_bot ? get_bot_info_object(user_id) : nullptr);
}

View File

@ -174,6 +174,7 @@ class ContactsManager : public Actor {
void on_update_user_photo(UserId user_id, tl_object_ptr<telegram_api::UserProfilePhoto> &&photo_ptr);
void on_update_user_online(UserId user_id, tl_object_ptr<telegram_api::UserStatus> &&status);
void on_update_user_local_was_online(UserId user_id, int32 local_was_online);
void on_update_user_is_blocked(UserId user_id, bool is_blocked);
void on_update_user_common_chat_count(UserId user_id, int32 common_chat_count);
void on_update_user_need_phone_number_privacy_exception(UserId user_id, bool need_phone_number_privacy_exception);
@ -680,6 +681,7 @@ class ContactsManager : public Actor {
int32 common_chat_count = 0;
bool is_blocked = false;
bool can_be_called = false;
bool supports_video_calls = false;
bool has_private_calls = false;
@ -1154,6 +1156,7 @@ class ContactsManager : public Actor {
void register_user_photo(User *u, UserId user_id, const Photo &photo);
void on_update_user_full_is_blocked(UserFull *user_full, UserId user_id, bool is_blocked);
void on_update_user_full_common_chat_count(UserFull *user_full, UserId user_id, int32 common_chat_count);
void on_update_user_full_need_phone_number_privacy_exception(UserFull *user_full, UserId user_id,
bool need_phone_number_privacy_exception);

View File

@ -28145,6 +28145,9 @@ void MessagesManager::on_update_dialog_is_blocked(DialogId dialog_id, bool is_bl
LOG(ERROR) << "Receive pinned message in invalid " << dialog_id;
return;
}
if (dialog_id.get_type() == DialogType::User) {
td_->contacts_manager_->on_update_user_is_blocked(dialog_id.get_user_id(), is_blocked);
}
auto d = get_dialog_force(dialog_id);
if (d == nullptr) {