Add Chat.emoji_status.
This commit is contained in:
parent
8e85ef9e40
commit
5cb6ca27cc
@ -1648,6 +1648,7 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa
|
||||
//@notification_settings Notification settings for the chat
|
||||
//@available_reactions Types of reaction, available in the chat
|
||||
//@message_auto_delete_time Current message auto-delete or self-destruct timer setting for the chat, in seconds; 0 if disabled. Self-destruct timer in secret chats starts after the message or its content is viewed. Auto-delete timer in other chats starts from the send date
|
||||
//@emoji_status Emoji status to be shown along with chat title; may be null
|
||||
//@background Background set for the chat; may be null if none
|
||||
//@theme_name If non-empty, name of a theme, set for the chat
|
||||
//@action_bar Information about actions which must be possible to do through the chat action bar; may be null if none
|
||||
@ -1656,7 +1657,7 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa
|
||||
//@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
|
||||
//@draft_message A draft of a message in the chat; may be null if none
|
||||
//@client_data Application-specific data associated with the chat. (For example, the chat scroll position or local chat notification settings can be stored here.) Persistent if the message database is used
|
||||
chat id:int53 type:ChatType title:string photo:chatPhotoInfo accent_color_id:int32 background_custom_emoji_id:int64 profile_accent_color_id:int32 profile_background_custom_emoji_id:int64 permissions:chatPermissions last_message:message positions:vector<chatPosition> message_sender_id:MessageSender block_list:BlockList has_protected_content:Bool is_translatable:Bool is_marked_as_unread:Bool view_as_topics:Bool has_scheduled_messages:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 unread_reaction_count:int32 notification_settings:chatNotificationSettings available_reactions:ChatAvailableReactions message_auto_delete_time:int32 background:chatBackground theme_name:string action_bar:ChatActionBar video_chat:videoChat pending_join_requests:chatJoinRequestsInfo reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat;
|
||||
chat id:int53 type:ChatType title:string photo:chatPhotoInfo accent_color_id:int32 background_custom_emoji_id:int64 profile_accent_color_id:int32 profile_background_custom_emoji_id:int64 permissions:chatPermissions last_message:message positions:vector<chatPosition> message_sender_id:MessageSender block_list:BlockList has_protected_content:Bool is_translatable:Bool is_marked_as_unread:Bool view_as_topics:Bool has_scheduled_messages:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 unread_reaction_count:int32 notification_settings:chatNotificationSettings available_reactions:ChatAvailableReactions message_auto_delete_time:int32 emoji_status:emojiStatus background:chatBackground theme_name:string action_bar:ChatActionBar video_chat:videoChat pending_join_requests:chatJoinRequestsInfo reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat;
|
||||
|
||||
//@description Represents a list of chats @total_count Approximate total number of chats found @chat_ids List of chat identifiers
|
||||
chats total_count:int32 chat_ids:vector<int53> = Chats;
|
||||
@ -6250,6 +6251,11 @@ updateChatAvailableReactions chat_id:int53 available_reactions:ChatAvailableReac
|
||||
//@positions The new chat positions in the chat lists
|
||||
updateChatDraftMessage chat_id:int53 draft_message:draftMessage positions:vector<chatPosition> = Update;
|
||||
|
||||
//@description Chat accent colors has changed
|
||||
//@chat_id Chat identifier
|
||||
//@emoji_status The new chat emoji status; may be null
|
||||
updateChatEmojiStatus chat_id:int53 emoji_status:emojiStatus = Update;
|
||||
|
||||
//@description The message sender that is selected to send messages in a chat has changed @chat_id Chat identifier @message_sender_id New value of message_sender_id; may be null if the user can't change message sender
|
||||
updateChatMessageSender chat_id:int53 message_sender_id:MessageSender = Update;
|
||||
|
||||
|
@ -6129,6 +6129,31 @@ RestrictedRights ContactsManager::get_secret_chat_default_permissions(SecretChat
|
||||
false, false, ChannelType::Unknown);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::emojiStatus> ContactsManager::get_user_emoji_status_object(UserId user_id) const {
|
||||
auto u = get_user(user_id);
|
||||
if (u == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return u->last_sent_emoji_status.get_emoji_status_object();
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::emojiStatus> ContactsManager::get_chat_emoji_status_object(ChatId chat_id) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::emojiStatus> ContactsManager::get_channel_emoji_status_object(ChannelId channel_id) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::emojiStatus> ContactsManager::get_secret_chat_emoji_status_object(
|
||||
SecretChatId secret_chat_id) const {
|
||||
auto c = get_secret_chat(secret_chat_id);
|
||||
if (c == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return get_user_emoji_status_object(c->user_id);
|
||||
}
|
||||
|
||||
bool ContactsManager::get_chat_has_protected_content(ChatId chat_id) const {
|
||||
auto c = get_chat(chat_id);
|
||||
if (c == nullptr) {
|
||||
@ -12548,11 +12573,18 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo
|
||||
}
|
||||
}
|
||||
u->is_changed = true;
|
||||
|
||||
auto messages_manager = td_->messages_manager_.get();
|
||||
messages_manager->on_dialog_emoji_status_updated(DialogId(user_id));
|
||||
for_each_secret_chat_with_user(user_id, [messages_manager](SecretChatId secret_chat_id) {
|
||||
messages_manager->on_dialog_emoji_status_updated(DialogId(secret_chat_id));
|
||||
});
|
||||
u->is_emoji_status_changed = false;
|
||||
} else if (u->is_emoji_status_changed) {
|
||||
LOG(DEBUG) << "Emoji status for " << user_id << " has changed";
|
||||
u->need_save_to_database = true;
|
||||
u->is_emoji_status_changed = false;
|
||||
}
|
||||
u->is_emoji_status_changed = false;
|
||||
|
||||
if (u->is_deleted) {
|
||||
td_->inline_queries_manager_->remove_recent_inline_bot(user_id, Promise<>());
|
||||
@ -20092,8 +20124,7 @@ tl_object_ptr<td_api::user> ContactsManager::get_user_object(UserId user_id, con
|
||||
type = make_tl_object<td_api::userTypeRegular>();
|
||||
}
|
||||
|
||||
auto emoji_status =
|
||||
!u->last_sent_emoji_status.is_empty() ? u->last_sent_emoji_status.get_emoji_status_object() : nullptr;
|
||||
auto emoji_status = u->last_sent_emoji_status.get_emoji_status_object();
|
||||
auto have_access = user_id == get_my_id() || have_input_peer_user(u, user_id, AccessRights::Know);
|
||||
auto accent_color_id = u->accent_color_id.is_valid() ? u->accent_color_id : AccentColorId(user_id);
|
||||
return td_api::make_object<td_api::user>(
|
||||
|
@ -150,6 +150,11 @@ class ContactsManager final : public Actor {
|
||||
RestrictedRights get_channel_default_permissions(ChannelId channel_id) const;
|
||||
RestrictedRights get_secret_chat_default_permissions(SecretChatId secret_chat_id) const;
|
||||
|
||||
td_api::object_ptr<td_api::emojiStatus> get_user_emoji_status_object(UserId user_id) const;
|
||||
td_api::object_ptr<td_api::emojiStatus> get_chat_emoji_status_object(ChatId chat_id) const;
|
||||
td_api::object_ptr<td_api::emojiStatus> get_channel_emoji_status_object(ChannelId channel_id) const;
|
||||
td_api::object_ptr<td_api::emojiStatus> get_secret_chat_emoji_status_object(SecretChatId secret_chat_id) const;
|
||||
|
||||
bool get_chat_has_protected_content(ChatId chat_id) const;
|
||||
bool get_channel_has_protected_content(ChannelId channel_id) const;
|
||||
|
||||
|
@ -20914,9 +20914,10 @@ td_api::object_ptr<td_api::chat> MessagesManager::get_chat_object(const Dialog *
|
||||
d->server_unread_count + d->local_unread_count, d->last_read_inbox_message_id.get(),
|
||||
d->last_read_outbox_message_id.get(), d->unread_mention_count, d->unread_reaction_count,
|
||||
get_chat_notification_settings_object(&d->notification_settings), std::move(available_reactions),
|
||||
d->message_ttl.get_message_auto_delete_time_object(), get_chat_background_object(d), get_dialog_theme_name(d),
|
||||
get_chat_action_bar_object(d), get_video_chat_object(d), get_chat_join_requests_info_object(d),
|
||||
d->reply_markup_message_id.get(), std::move(draft_message), d->client_data);
|
||||
d->message_ttl.get_message_auto_delete_time_object(), get_dialog_emoji_status_object(d->dialog_id),
|
||||
get_chat_background_object(d), get_dialog_theme_name(d), get_chat_action_bar_object(d), get_video_chat_object(d),
|
||||
get_chat_join_requests_info_object(d), d->reply_markup_message_id.get(), std::move(draft_message),
|
||||
d->client_data);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::chat> MessagesManager::get_chat_object(DialogId dialog_id) {
|
||||
@ -32741,6 +32742,16 @@ void MessagesManager::on_dialog_title_updated(DialogId dialog_id) {
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesManager::on_dialog_emoji_status_updated(DialogId dialog_id) {
|
||||
auto d = get_dialog(dialog_id); // called from update_user, must not create the dialog
|
||||
if (d != nullptr && d->is_update_new_chat_sent) {
|
||||
send_closure(
|
||||
G()->td(), &Td::send_update,
|
||||
td_api::make_object<td_api::updateChatEmojiStatus>(get_chat_id_object(dialog_id, "updateChatEmojiStatus"),
|
||||
get_dialog_emoji_status_object(dialog_id)));
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesManager::on_dialog_default_permissions_updated(DialogId dialog_id) {
|
||||
auto d = get_dialog(dialog_id); // called from update_user, must not create the dialog
|
||||
if (d != nullptr && d->is_update_new_chat_sent) {
|
||||
@ -33269,6 +33280,23 @@ RestrictedRights MessagesManager::get_dialog_default_permissions(DialogId dialog
|
||||
}
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::emojiStatus> MessagesManager::get_dialog_emoji_status_object(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_user_emoji_status_object(dialog_id.get_user_id());
|
||||
case DialogType::Chat:
|
||||
return td_->contacts_manager_->get_chat_emoji_status_object(dialog_id.get_chat_id());
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->get_channel_emoji_status_object(dialog_id.get_channel_id());
|
||||
case DialogType::SecretChat:
|
||||
return td_->contacts_manager_->get_secret_chat_emoji_status_object(dialog_id.get_secret_chat_id());
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool MessagesManager::get_dialog_has_protected_content(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
|
@ -897,6 +897,7 @@ class MessagesManager final : public Actor {
|
||||
void on_dialog_photo_updated(DialogId dialog_id);
|
||||
void on_dialog_accent_colors_updated(DialogId dialog_id);
|
||||
void on_dialog_title_updated(DialogId dialog_id);
|
||||
void on_dialog_emoji_status_updated(DialogId dialog_id);
|
||||
void on_dialog_usernames_updated(DialogId dialog_id, const Usernames &old_usernames, const Usernames &new_usernames);
|
||||
void on_dialog_usernames_received(DialogId dialog_id, const Usernames &usernames, bool from_database);
|
||||
void on_dialog_default_permissions_updated(DialogId dialog_id);
|
||||
@ -3002,6 +3003,8 @@ class MessagesManager final : public Actor {
|
||||
|
||||
RestrictedRights get_dialog_default_permissions(DialogId dialog_id) const;
|
||||
|
||||
td_api::object_ptr<td_api::emojiStatus> get_dialog_emoji_status_object(DialogId dialog_id) const;
|
||||
|
||||
bool get_dialog_has_protected_content(DialogId dialog_id) const;
|
||||
|
||||
bool get_dialog_view_as_topics(const Dialog *d) const;
|
||||
|
Loading…
Reference in New Issue
Block a user