Process updateUserEmojiStatus.

This commit is contained in:
levlam 2022-08-23 18:14:46 +03:00
parent b359a09464
commit ce845b0753
4 changed files with 36 additions and 7 deletions

View File

@ -11761,6 +11761,34 @@ void ContactsManager::register_user_photo(User *u, UserId user_id, const Photo &
}
}
void ContactsManager::on_update_user_emoji_status(UserId user_id,
tl_object_ptr<telegram_api::EmojiStatus> &&emoji_status_ptr) {
if (!user_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << user_id;
return;
}
User *u = get_user_force(user_id);
if (u != nullptr) {
int64 emoji_status = 0;
if (emoji_status_ptr != nullptr && emoji_status_ptr->get_id() == telegram_api::emojiStatus::ID) {
emoji_status = static_cast<const telegram_api::emojiStatus *>(emoji_status_ptr.get())->document_id_;
}
on_update_user_emoji_status(u, user_id, emoji_status);
update_user(u, user_id);
} else {
LOG(INFO) << "Ignore update user emoji status about unknown " << user_id;
}
}
void ContactsManager::on_update_user_emoji_status(User *u, UserId user_id, int64 emoji_status) {
if (u->emoji_status != emoji_status) {
u->emoji_status = emoji_status;
LOG(DEBUG) << "Emoji status has changed for " << user_id;
u->is_changed = true;
}
}
void ContactsManager::on_update_user_is_contact(User *u, UserId user_id, bool is_contact, bool is_mutual_contact) {
UserId my_id = get_my_id();
if (user_id == my_id) {

View File

@ -178,6 +178,7 @@ class ContactsManager final : public Actor {
void on_update_user_name(UserId user_id, string &&first_name, string &&last_name, string &&username);
void on_update_user_phone_number(UserId user_id, string &&phone_number);
void on_update_user_photo(UserId user_id, tl_object_ptr<telegram_api::UserProfilePhoto> &&photo_ptr);
void on_update_user_emoji_status(UserId user_id, tl_object_ptr<telegram_api::EmojiStatus> &&emoji_status_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);
@ -1256,6 +1257,7 @@ class ContactsManager final : public Actor {
void on_update_user_phone_number(User *u, UserId user_id, string &&phone_number);
void on_update_user_photo(User *u, UserId user_id, tl_object_ptr<telegram_api::UserProfilePhoto> &&photo,
const char *source);
void on_update_user_emoji_status(User *u, UserId user_id, int64 emoji_status);
void on_update_user_is_contact(User *u, UserId user_id, bool is_contact, bool is_mutual_contact);
void on_update_user_online(User *u, UserId user_id, tl_object_ptr<telegram_api::UserStatus> &&status);
void on_update_user_local_was_online(User *u, UserId user_id, int32 local_was_online);

View File

@ -3165,11 +3165,15 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserPhone> upda
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserPhoto> update, Promise<Unit> &&promise) {
// TODO update->previous_, update->date_
td_->contacts_manager_->on_update_user_photo(UserId(update->user_id_), std::move(update->photo_));
promise.set_value(Unit());
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserEmojiStatus> update, Promise<Unit> &&promise) {
td_->contacts_manager_->on_update_user_emoji_status(UserId(update->user_id_), std::move(update->emoji_status_));
promise.set_value(Unit());
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updatePeerBlocked> update, Promise<Unit> &&promise) {
td_->messages_manager_->on_update_dialog_is_blocked(DialogId(update->peer_id_), update->blocked_);
promise.set_value(Unit());
@ -3578,10 +3582,6 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateRecentReactions
promise.set_value(Unit());
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserEmojiStatus> update, Promise<Unit> &&promise) {
promise.set_value(Unit());
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateMoveStickerSetToTop> update, Promise<Unit> &&promise) {
promise.set_value(Unit());
}

View File

@ -420,6 +420,7 @@ class UpdatesManager final : public Actor {
void on_update(tl_object_ptr<telegram_api::updateUserName> update, Promise<Unit> &&promise);
void on_update(tl_object_ptr<telegram_api::updateUserPhone> update, Promise<Unit> &&promise);
void on_update(tl_object_ptr<telegram_api::updateUserPhoto> update, Promise<Unit> &&promise);
void on_update(tl_object_ptr<telegram_api::updateUserEmojiStatus> update, Promise<Unit> &&promise);
void on_update(tl_object_ptr<telegram_api::updatePeerBlocked> update, Promise<Unit> &&promise);
void on_update(tl_object_ptr<telegram_api::updateBotCommands> update, Promise<Unit> &&promise);
@ -540,8 +541,6 @@ class UpdatesManager final : public Actor {
void on_update(tl_object_ptr<telegram_api::updateRecentReactions> update, Promise<Unit> &&promise);
void on_update(tl_object_ptr<telegram_api::updateUserEmojiStatus> update, Promise<Unit> &&promise);
void on_update(tl_object_ptr<telegram_api::updateMoveStickerSetToTop> update, Promise<Unit> &&promise);
};