Support profile color and custom emoji in chat.
This commit is contained in:
parent
16d0c3c61b
commit
7ceccad807
@ -1621,6 +1621,8 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa
|
||||
//@photo Chat photo; may be null
|
||||
//@accent_color_id Identifier of the accent color for message sender name, and backgrounds of chat photo, reply header, and link preview
|
||||
//@background_custom_emoji_id Identifier of a custom emoji to be shown on the reply header background in replies to messages sent by the chat; 0 if none
|
||||
//@profile_accent_color_id Identifier of the profile accent color for the chat's profile; -1 if none
|
||||
//@profile_background_custom_emoji_id Identifier of a custom emoji to be shown on the background of the chat's profile; 0 if none
|
||||
//@permissions Actions that non-administrator chat members are allowed to take in the chat
|
||||
//@last_message Last message in the chat; may be null if none or unknown
|
||||
//@positions Positions of the chat in chat lists
|
||||
@ -1651,7 +1653,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 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 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;
|
||||
@ -6162,7 +6164,9 @@ updateChatPhoto chat_id:int53 photo:chatPhotoInfo = Update;
|
||||
//@chat_id Chat identifier
|
||||
//@accent_color_id The new chat accent color identifier
|
||||
//@background_custom_emoji_id The new identifier of a custom emoji to be shown on the reply header background; 0 if none
|
||||
updateChatAccentColors chat_id:int53 accent_color_id:int32 background_custom_emoji_id:int64 = Update;
|
||||
//@profile_accent_color_id The new chat profile accent color identifier; -1 if none
|
||||
//@profile_background_custom_emoji_id The new identifier of a custom emoji to be shown on the profile background; 0 if none
|
||||
updateChatAccentColors chat_id:int53 accent_color_id:int32 background_custom_emoji_id:int64 profile_accent_color_id:int32 profile_background_custom_emoji_id:int64 = Update;
|
||||
|
||||
//@description Chat permissions were changed @chat_id Chat identifier @permissions The new chat permissions
|
||||
updateChatPermissions chat_id:int53 permissions:chatPermissions = Update;
|
||||
|
@ -5034,6 +5034,8 @@ void ContactsManager::Channel::store(StorerT &storer) const {
|
||||
bool has_max_active_story_id_next_reload_time = max_active_story_id_next_reload_time > Time::now();
|
||||
bool has_accent_color_id = accent_color_id.is_valid();
|
||||
bool has_background_custom_emoji_id = background_custom_emoji_id.is_valid();
|
||||
bool has_profile_accent_color_id = profile_accent_color_id.is_valid();
|
||||
bool has_profile_background_custom_emoji_id = profile_background_custom_emoji_id.is_valid();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(false);
|
||||
STORE_FLAG(false);
|
||||
@ -5075,6 +5077,8 @@ void ContactsManager::Channel::store(StorerT &storer) const {
|
||||
STORE_FLAG(stories_hidden);
|
||||
STORE_FLAG(has_accent_color_id);
|
||||
STORE_FLAG(has_background_custom_emoji_id);
|
||||
STORE_FLAG(has_profile_accent_color_id);
|
||||
STORE_FLAG(has_profile_background_custom_emoji_id);
|
||||
END_STORE_FLAGS();
|
||||
}
|
||||
|
||||
@ -5115,6 +5119,12 @@ void ContactsManager::Channel::store(StorerT &storer) const {
|
||||
if (has_background_custom_emoji_id) {
|
||||
store(background_custom_emoji_id, storer);
|
||||
}
|
||||
if (has_profile_accent_color_id) {
|
||||
store(profile_accent_color_id, storer);
|
||||
}
|
||||
if (has_profile_background_custom_emoji_id) {
|
||||
store(profile_background_custom_emoji_id, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
@ -5142,6 +5152,8 @@ void ContactsManager::Channel::parse(ParserT &parser) {
|
||||
bool has_max_active_story_id_next_reload_time = false;
|
||||
bool has_accent_color_id = false;
|
||||
bool has_background_custom_emoji_id = false;
|
||||
bool has_profile_accent_color_id = false;
|
||||
bool has_profile_background_custom_emoji_id = false;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(left);
|
||||
PARSE_FLAG(kicked);
|
||||
@ -5183,6 +5195,8 @@ void ContactsManager::Channel::parse(ParserT &parser) {
|
||||
PARSE_FLAG(stories_hidden);
|
||||
PARSE_FLAG(has_accent_color_id);
|
||||
PARSE_FLAG(has_background_custom_emoji_id);
|
||||
PARSE_FLAG(has_profile_accent_color_id);
|
||||
PARSE_FLAG(has_profile_background_custom_emoji_id);
|
||||
END_PARSE_FLAGS();
|
||||
}
|
||||
|
||||
@ -5253,6 +5267,12 @@ void ContactsManager::Channel::parse(ParserT &parser) {
|
||||
if (has_background_custom_emoji_id) {
|
||||
parse(background_custom_emoji_id, parser);
|
||||
}
|
||||
if (has_profile_accent_color_id) {
|
||||
parse(profile_accent_color_id, parser);
|
||||
}
|
||||
if (has_profile_background_custom_emoji_id) {
|
||||
parse(profile_background_custom_emoji_id, parser);
|
||||
}
|
||||
|
||||
if (!check_utf8(title)) {
|
||||
LOG(ERROR) << "Have invalid title \"" << title << '"';
|
||||
@ -6001,6 +6021,65 @@ CustomEmojiId ContactsManager::get_secret_chat_background_custom_emoji_id(Secret
|
||||
return get_user_background_custom_emoji_id(c->user_id);
|
||||
}
|
||||
|
||||
int32 ContactsManager::get_user_profile_accent_color_id_object(UserId user_id) const {
|
||||
auto u = get_user(user_id);
|
||||
if (u == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return td_->theme_manager_->get_profile_accent_color_id_object(u->profile_accent_color_id);
|
||||
}
|
||||
|
||||
int32 ContactsManager::get_chat_profile_accent_color_id_object(ChatId chat_id) const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32 ContactsManager::get_channel_profile_accent_color_id_object(ChannelId channel_id) const {
|
||||
auto c = get_channel(channel_id);
|
||||
if (c == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
return td_->theme_manager_->get_profile_accent_color_id_object(c->profile_accent_color_id);
|
||||
}
|
||||
|
||||
int32 ContactsManager::get_secret_chat_profile_accent_color_id_object(SecretChatId secret_chat_id) const {
|
||||
auto c = get_secret_chat(secret_chat_id);
|
||||
if (c == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
return get_user_profile_accent_color_id_object(c->user_id);
|
||||
}
|
||||
|
||||
CustomEmojiId ContactsManager::get_user_profile_background_custom_emoji_id(UserId user_id) const {
|
||||
auto u = get_user(user_id);
|
||||
if (u == nullptr) {
|
||||
return CustomEmojiId();
|
||||
}
|
||||
|
||||
return u->profile_background_custom_emoji_id;
|
||||
}
|
||||
|
||||
CustomEmojiId ContactsManager::get_chat_profile_background_custom_emoji_id(ChatId chat_id) const {
|
||||
return CustomEmojiId();
|
||||
}
|
||||
|
||||
CustomEmojiId ContactsManager::get_channel_profile_background_custom_emoji_id(ChannelId channel_id) const {
|
||||
auto c = get_channel(channel_id);
|
||||
if (c == nullptr) {
|
||||
return CustomEmojiId();
|
||||
}
|
||||
|
||||
return c->profile_background_custom_emoji_id;
|
||||
}
|
||||
|
||||
CustomEmojiId ContactsManager::get_secret_chat_profile_background_custom_emoji_id(SecretChatId secret_chat_id) const {
|
||||
auto c = get_secret_chat(secret_chat_id);
|
||||
if (c == nullptr) {
|
||||
return CustomEmojiId();
|
||||
}
|
||||
return get_user_profile_background_custom_emoji_id(c->user_id);
|
||||
}
|
||||
|
||||
string ContactsManager::get_user_title(UserId user_id) const {
|
||||
auto u = get_user(user_id);
|
||||
if (u == nullptr) {
|
||||
@ -16820,6 +16899,27 @@ void ContactsManager::on_update_channel_background_custom_emoji_id(Channel *c, C
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_channel_profile_accent_color_id(Channel *c, ChannelId channel_id,
|
||||
AccentColorId profile_accent_color_id) {
|
||||
if (!profile_accent_color_id.is_valid()) {
|
||||
profile_accent_color_id = AccentColorId();
|
||||
}
|
||||
if (c->profile_accent_color_id != profile_accent_color_id) {
|
||||
c->profile_accent_color_id = profile_accent_color_id;
|
||||
c->is_accent_color_changed = true;
|
||||
c->need_save_to_database = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_channel_profile_background_custom_emoji_id(
|
||||
Channel *c, ChannelId channel_id, CustomEmojiId profile_background_custom_emoji_id) {
|
||||
if (c->profile_background_custom_emoji_id != profile_background_custom_emoji_id) {
|
||||
c->profile_background_custom_emoji_id = profile_background_custom_emoji_id;
|
||||
c->is_accent_color_changed = true;
|
||||
c->need_save_to_database = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_channel_title(Channel *c, ChannelId channel_id, string &&title) {
|
||||
if (c->title != title) {
|
||||
c->title = std::move(title);
|
||||
|
@ -130,6 +130,16 @@ class ContactsManager final : public Actor {
|
||||
CustomEmojiId get_channel_background_custom_emoji_id(ChannelId channel_id) const;
|
||||
CustomEmojiId get_secret_chat_background_custom_emoji_id(SecretChatId secret_chat_id) const;
|
||||
|
||||
int32 get_user_profile_accent_color_id_object(UserId user_id) const;
|
||||
int32 get_chat_profile_accent_color_id_object(ChatId chat_id) const;
|
||||
int32 get_channel_profile_accent_color_id_object(ChannelId channel_id) const;
|
||||
int32 get_secret_chat_profile_accent_color_id_object(SecretChatId secret_chat_id) const;
|
||||
|
||||
CustomEmojiId get_user_profile_background_custom_emoji_id(UserId user_id) const;
|
||||
CustomEmojiId get_chat_profile_background_custom_emoji_id(ChatId chat_id) const;
|
||||
CustomEmojiId get_channel_profile_background_custom_emoji_id(ChannelId channel_id) const;
|
||||
CustomEmojiId get_secret_chat_profile_background_custom_emoji_id(SecretChatId secret_chat_id) const;
|
||||
|
||||
string get_user_title(UserId user_id) const;
|
||||
string get_chat_title(ChatId chat_id) const;
|
||||
string get_channel_title(ChannelId channel_id) const;
|
||||
@ -993,6 +1003,8 @@ class ContactsManager final : public Actor {
|
||||
DialogPhoto photo;
|
||||
AccentColorId accent_color_id;
|
||||
CustomEmojiId background_custom_emoji_id;
|
||||
AccentColorId profile_accent_color_id;
|
||||
CustomEmojiId profile_background_custom_emoji_id;
|
||||
Usernames usernames;
|
||||
vector<RestrictionReason> restriction_reasons;
|
||||
DialogParticipantStatus status = DialogParticipantStatus::Banned(0);
|
||||
@ -1542,6 +1554,10 @@ class ContactsManager final : public Actor {
|
||||
void on_update_channel_accent_color_id(Channel *c, ChannelId channel_id, AccentColorId accent_color_id);
|
||||
void on_update_channel_background_custom_emoji_id(Channel *c, ChannelId channel_id,
|
||||
CustomEmojiId background_custom_emoji_id);
|
||||
void on_update_channel_profile_accent_color_id(Channel *c, ChannelId channel_id,
|
||||
AccentColorId profile_accent_color_id);
|
||||
void on_update_channel_profile_background_custom_emoji_id(Channel *c, ChannelId channel_id,
|
||||
CustomEmojiId profile_background_custom_emoji_id);
|
||||
static void on_update_channel_title(Channel *c, ChannelId channel_id, string &&title);
|
||||
void on_update_channel_usernames(Channel *c, ChannelId channel_id, Usernames &&usernames);
|
||||
void on_update_channel_status(Channel *c, ChannelId channel_id, DialogParticipantStatus &&status);
|
||||
|
@ -20903,6 +20903,8 @@ td_api::object_ptr<td_api::chat> MessagesManager::get_chat_object(const Dialog *
|
||||
d->dialog_id.get(), get_chat_type_object(d->dialog_id), get_dialog_title(d->dialog_id),
|
||||
get_chat_photo_info_object(td_->file_manager_.get(), get_dialog_photo(d->dialog_id)),
|
||||
get_dialog_accent_color_id_object(d->dialog_id), get_dialog_background_custom_emoji_id(d->dialog_id).get(),
|
||||
get_dialog_profile_accent_color_id_object(d->dialog_id),
|
||||
get_dialog_profile_background_custom_emoji_id(d->dialog_id).get(),
|
||||
get_dialog_default_permissions(d->dialog_id).get_chat_permissions_object(),
|
||||
get_message_object(d->dialog_id, get_message(d, d->last_message_id), "get_chat_object"),
|
||||
get_chat_positions_object(d), get_default_message_sender_object(d), block_list_id.get_block_list_object(),
|
||||
@ -32719,9 +32721,11 @@ void MessagesManager::on_dialog_accent_colors_updated(DialogId dialog_id) {
|
||||
if (d != nullptr && d->is_update_new_chat_sent) {
|
||||
send_closure(
|
||||
G()->td(), &Td::send_update,
|
||||
td_api::make_object<td_api::updateChatAccentColors>(get_chat_id_object(dialog_id, "updateChatAccentColors"),
|
||||
get_dialog_accent_color_id_object(dialog_id),
|
||||
get_dialog_background_custom_emoji_id(dialog_id).get()));
|
||||
td_api::make_object<td_api::updateChatAccentColors>(
|
||||
get_chat_id_object(dialog_id, "updateChatAccentColors"), get_dialog_accent_color_id_object(dialog_id),
|
||||
get_dialog_background_custom_emoji_id(dialog_id).get(),
|
||||
get_dialog_profile_accent_color_id_object(dialog_id),
|
||||
get_dialog_profile_background_custom_emoji_id(dialog_id).get()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -33195,6 +33199,40 @@ CustomEmojiId MessagesManager::get_dialog_background_custom_emoji_id(DialogId di
|
||||
}
|
||||
}
|
||||
|
||||
int32 MessagesManager::get_dialog_profile_accent_color_id_object(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_user_profile_accent_color_id_object(dialog_id.get_user_id());
|
||||
case DialogType::Chat:
|
||||
return td_->contacts_manager_->get_chat_profile_accent_color_id_object(dialog_id.get_chat_id());
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->get_channel_profile_accent_color_id_object(dialog_id.get_channel_id());
|
||||
case DialogType::SecretChat:
|
||||
return td_->contacts_manager_->get_secret_chat_profile_accent_color_id_object(dialog_id.get_secret_chat_id());
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
CustomEmojiId MessagesManager::get_dialog_profile_background_custom_emoji_id(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return td_->contacts_manager_->get_user_profile_background_custom_emoji_id(dialog_id.get_user_id());
|
||||
case DialogType::Chat:
|
||||
return td_->contacts_manager_->get_chat_profile_background_custom_emoji_id(dialog_id.get_chat_id());
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->get_channel_profile_background_custom_emoji_id(dialog_id.get_channel_id());
|
||||
case DialogType::SecretChat:
|
||||
return td_->contacts_manager_->get_secret_chat_profile_background_custom_emoji_id(dialog_id.get_secret_chat_id());
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return CustomEmojiId();
|
||||
}
|
||||
}
|
||||
|
||||
string MessagesManager::get_dialog_title(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
|
@ -2993,6 +2993,10 @@ class MessagesManager final : public Actor {
|
||||
|
||||
CustomEmojiId get_dialog_background_custom_emoji_id(DialogId dialog_id) const;
|
||||
|
||||
int32 get_dialog_profile_accent_color_id_object(DialogId dialog_id) const;
|
||||
|
||||
CustomEmojiId get_dialog_profile_background_custom_emoji_id(DialogId dialog_id) const;
|
||||
|
||||
RestrictedRights get_dialog_default_permissions(DialogId dialog_id) const;
|
||||
|
||||
bool get_dialog_has_protected_content(DialogId dialog_id) const;
|
||||
|
Loading…
Reference in New Issue
Block a user