Add td_api::setAccentColor.
This commit is contained in:
parent
74fc996843
commit
28bdceaaef
@ -772,7 +772,7 @@ usernames active_usernames:vector<string> disabled_usernames:vector<string> edit
|
|||||||
//@status Current online status of the user
|
//@status Current online status of the user
|
||||||
//@profile_photo Profile photo of the user; may be null
|
//@profile_photo Profile photo of the user; may be null
|
||||||
//@accent_color_id Identifier of the accent color for name, and backgrounds of profile photo, reply header, and link preview
|
//@accent_color_id Identifier of the accent color for name, and backgrounds of profile photo, reply header, and link preview
|
||||||
//@background_custom_emoji_id Identifier of a custom emoji to be shown on the reply header background. For Telegram Premium users only
|
//@background_custom_emoji_id Identifier of a custom emoji to be shown on the reply header background; 0 if none. For Telegram Premium users only
|
||||||
//@emoji_status Emoji status to be shown instead of the default Telegram Premium badge; may be null. For Telegram Premium users only
|
//@emoji_status Emoji status to be shown instead of the default Telegram Premium badge; may be null. For Telegram Premium users only
|
||||||
//@is_contact The user is a contact of the current user
|
//@is_contact The user is a contact of the current user
|
||||||
//@is_mutual_contact The user is a contact of the current user and the current user is a contact of the user
|
//@is_mutual_contact The user is a contact of the current user and the current user is a contact of the user
|
||||||
@ -1572,7 +1572,7 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa
|
|||||||
//@title Chat title
|
//@title Chat title
|
||||||
//@photo Chat photo; may be null
|
//@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
|
//@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
|
//@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
|
||||||
//@permissions Actions that non-administrator chat members are allowed to take in the chat
|
//@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
|
//@last_message Last message in the chat; may be null if none or unknown
|
||||||
//@positions Positions of the chat in chat lists
|
//@positions Positions of the chat in chat lists
|
||||||
@ -4199,7 +4199,7 @@ chatEventActiveUsernamesChanged old_usernames:vector<string> new_usernames:vecto
|
|||||||
//@description The chat accent color was changed @old_accent_color_id Previous identifier of chat accent color @new_accent_color_id New identifier of chat accent color
|
//@description The chat accent color was changed @old_accent_color_id Previous identifier of chat accent color @new_accent_color_id New identifier of chat accent color
|
||||||
chatEventAccentColorChanged old_accent_color_id:accentColorId new_accent_color_id:accentColorId = ChatEventAction;
|
chatEventAccentColorChanged old_accent_color_id:accentColorId new_accent_color_id:accentColorId = ChatEventAction;
|
||||||
|
|
||||||
//@description The chat's custom emoji for reply background was changed @old_background_custom_emoji_id Previous identifier of the custom emoji @new_background_custom_emoji_id New identifier of the custom emoji
|
//@description The chat's custom emoji for reply background was changed @old_background_custom_emoji_id Previous identifier of the custom emoji; 0 if none @new_background_custom_emoji_id New identifier of the custom emoji; 0 if none
|
||||||
chatEventBackgroundCustomEmojiChanged old_background_custom_emoji_id:int64 new_background_custom_emoji_id:int64 = ChatEventAction;
|
chatEventBackgroundCustomEmojiChanged old_background_custom_emoji_id:int64 new_background_custom_emoji_id:int64 = ChatEventAction;
|
||||||
|
|
||||||
//@description The has_protected_content setting of a channel was toggled @has_protected_content New value of has_protected_content
|
//@description The has_protected_content setting of a channel was toggled @has_protected_content New value of has_protected_content
|
||||||
@ -8525,6 +8525,11 @@ setProfilePhoto photo:InputChatPhoto is_public:Bool = Ok;
|
|||||||
//@description Deletes a profile photo @profile_photo_id Identifier of the profile photo to delete
|
//@description Deletes a profile photo @profile_photo_id Identifier of the profile photo to delete
|
||||||
deleteProfilePhoto profile_photo_id:int64 = Ok;
|
deleteProfilePhoto profile_photo_id:int64 = Ok;
|
||||||
|
|
||||||
|
//@description Changes accent color and background custom emoji for the current user; for Telegram Premium users only
|
||||||
|
//@accent_color_id Identifier of the accent color to use
|
||||||
|
//@background_custom_emoji_id Identifier of a custom emoji to be shown on the reply header background; 0 if none
|
||||||
|
setAccentColor accent_color_id:int32 background_custom_emoji_id:int64 = Ok;
|
||||||
|
|
||||||
//@description Changes the first and last name of the current user @first_name The new value of the first name for the current user; 1-64 characters @last_name The new value of the optional last name for the current user; 0-64 characters
|
//@description Changes the first and last name of the current user @first_name The new value of the first name for the current user; 1-64 characters @last_name The new value of the optional last name for the current user; 0-64 characters
|
||||||
setName first_name:string last_name:string = Ok;
|
setName first_name:string last_name:string = Ok;
|
||||||
|
|
||||||
|
@ -772,6 +772,42 @@ class DeleteProfilePhotoQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class UpdateColorQuery final : public Td::ResultHandler {
|
||||||
|
Promise<Unit> promise_;
|
||||||
|
AccentColorId accent_color_id_;
|
||||||
|
CustomEmojiId background_custom_emoji_id_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit UpdateColorQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void send(AccentColorId accent_color_id, CustomEmojiId background_custom_emoji_id) {
|
||||||
|
accent_color_id_ = accent_color_id;
|
||||||
|
background_custom_emoji_id_ = background_custom_emoji_id;
|
||||||
|
int32 flags = 0;
|
||||||
|
if (background_custom_emoji_id.is_valid()) {
|
||||||
|
flags |= telegram_api::account_updateColor::BACKGROUND_EMOJI_ID_MASK;
|
||||||
|
}
|
||||||
|
send_query(G()->net_query_creator().create(
|
||||||
|
telegram_api::account_updateColor(flags, accent_color_id.get(), background_custom_emoji_id.get()), {{"me"}}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(BufferSlice packet) final {
|
||||||
|
auto result_ptr = fetch_result<telegram_api::account_updateColor>(packet);
|
||||||
|
if (result_ptr.is_error()) {
|
||||||
|
return on_error(result_ptr.move_as_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(DEBUG) << "Receive result for UpdateColorQuery: " << result_ptr.ok();
|
||||||
|
td_->contacts_manager_->on_update_accent_color_success(accent_color_id_, background_custom_emoji_id_);
|
||||||
|
promise_.set_value(Unit());
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_error(Status status) final {
|
||||||
|
promise_.set_error(std::move(status));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class UpdateProfileQuery final : public Td::ResultHandler {
|
class UpdateProfileQuery final : public Td::ResultHandler {
|
||||||
Promise<Unit> promise_;
|
Promise<Unit> promise_;
|
||||||
int32 flags_;
|
int32 flags_;
|
||||||
@ -7574,6 +7610,15 @@ void ContactsManager::delete_profile_photo(int64 profile_photo_id, bool is_recur
|
|||||||
td_->create_handler<DeleteProfilePhotoQuery>(std::move(promise))->send(profile_photo_id);
|
td_->create_handler<DeleteProfilePhotoQuery>(std::move(promise))->send(profile_photo_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContactsManager::set_accent_color(AccentColorId accent_color_id, CustomEmojiId background_custom_emoji_id,
|
||||||
|
Promise<Unit> &&promise) {
|
||||||
|
if (!accent_color_id.is_valid()) {
|
||||||
|
return promise.set_error(Status::Error(400, "Invalid accent color identifier specified"));
|
||||||
|
}
|
||||||
|
|
||||||
|
td_->create_handler<UpdateColorQuery>(std::move(promise))->send(accent_color_id, background_custom_emoji_id);
|
||||||
|
}
|
||||||
|
|
||||||
void ContactsManager::set_name(const string &first_name, const string &last_name, Promise<Unit> &&promise) {
|
void ContactsManager::set_name(const string &first_name, const string &last_name, Promise<Unit> &&promise) {
|
||||||
auto new_first_name = clean_name(first_name, MAX_NAME_LENGTH);
|
auto new_first_name = clean_name(first_name, MAX_NAME_LENGTH);
|
||||||
auto new_last_name = clean_name(last_name, MAX_NAME_LENGTH);
|
auto new_last_name = clean_name(last_name, MAX_NAME_LENGTH);
|
||||||
@ -7621,6 +7666,18 @@ void ContactsManager::set_bio(const string &bio, Promise<Unit> &&promise) {
|
|||||||
td_->create_handler<UpdateProfileQuery>(std::move(promise))->send(flags, "", "", new_bio);
|
td_->create_handler<UpdateProfileQuery>(std::move(promise))->send(flags, "", "", new_bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContactsManager::on_update_accent_color_success(AccentColorId accent_color_id,
|
||||||
|
CustomEmojiId background_custom_emoji_id) {
|
||||||
|
auto user_id = get_my_id();
|
||||||
|
User *u = get_user_force(user_id, "on_update_accent_color_success");
|
||||||
|
if (u == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
on_update_user_accent_color_id(u, user_id, accent_color_id);
|
||||||
|
on_update_user_background_custom_emoji_id(u, user_id, background_custom_emoji_id);
|
||||||
|
update_user(u, user_id);
|
||||||
|
}
|
||||||
|
|
||||||
void ContactsManager::on_update_profile_success(int32 flags, const string &first_name, const string &last_name,
|
void ContactsManager::on_update_profile_success(int32 flags, const string &first_name, const string &last_name,
|
||||||
const string &about) {
|
const string &about) {
|
||||||
CHECK(flags != 0);
|
CHECK(flags != 0);
|
||||||
|
@ -197,6 +197,7 @@ class ContactsManager final : public Actor {
|
|||||||
void on_get_channel_full_failed(ChannelId channel_id);
|
void on_get_channel_full_failed(ChannelId channel_id);
|
||||||
|
|
||||||
void on_update_profile_success(int32 flags, const string &first_name, const string &last_name, const string &about);
|
void on_update_profile_success(int32 flags, const string &first_name, const string &last_name, const string &about);
|
||||||
|
void on_update_accent_color_success(AccentColorId accent_color_id, CustomEmojiId background_custom_emoji_id);
|
||||||
|
|
||||||
void on_update_user_name(UserId user_id, string &&first_name, string &&last_name, Usernames &&usernames);
|
void on_update_user_name(UserId user_id, string &&first_name, string &&last_name, Usernames &&usernames);
|
||||||
void on_update_user_phone_number(UserId user_id, string &&phone_number);
|
void on_update_user_phone_number(UserId user_id, string &&phone_number);
|
||||||
@ -426,6 +427,9 @@ class ContactsManager final : public Actor {
|
|||||||
|
|
||||||
void delete_profile_photo(int64 profile_photo_id, bool is_recursive, Promise<Unit> &&promise);
|
void delete_profile_photo(int64 profile_photo_id, bool is_recursive, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void set_accent_color(AccentColorId accent_color_id, CustomEmojiId background_custom_emoji_id,
|
||||||
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
void set_name(const string &first_name, const string &last_name, Promise<Unit> &&promise);
|
void set_name(const string &first_name, const string &last_name, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void set_bio(const string &bio, Promise<Unit> &&promise);
|
void set_bio(const string &bio, Promise<Unit> &&promise);
|
||||||
|
@ -7562,6 +7562,13 @@ void Td::on_request(uint64 id, const td_api::getUserProfilePhotos &request) {
|
|||||||
std::move(promise));
|
std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, const td_api::setAccentColor &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
contacts_manager_->set_accent_color(AccentColorId(request.accent_color_id_),
|
||||||
|
CustomEmojiId(request.background_custom_emoji_id_), std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::setSupergroupUsername &request) {
|
void Td::on_request(uint64 id, td_api::setSupergroupUsername &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CLEAN_INPUT_STRING(request.username_);
|
CLEAN_INPUT_STRING(request.username_);
|
||||||
|
@ -1275,6 +1275,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, const td_api::getUserProfilePhotos &request);
|
void on_request(uint64 id, const td_api::getUserProfilePhotos &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, const td_api::setAccentColor &request);
|
||||||
|
|
||||||
void on_request(uint64 id, td_api::setSupergroupUsername &request);
|
void on_request(uint64 id, td_api::setSupergroupUsername &request);
|
||||||
|
|
||||||
void on_request(uint64 id, td_api::toggleSupergroupUsernameIsActive &request);
|
void on_request(uint64 id, td_api::toggleSupergroupUsernameIsActive &request);
|
||||||
|
@ -5827,6 +5827,11 @@ class CliClient final : public Actor {
|
|||||||
int64 profile_photo_id;
|
int64 profile_photo_id;
|
||||||
get_args(args, profile_photo_id);
|
get_args(args, profile_photo_id);
|
||||||
send_request(td_api::make_object<td_api::deleteProfilePhoto>(profile_photo_id));
|
send_request(td_api::make_object<td_api::deleteProfilePhoto>(profile_photo_id));
|
||||||
|
} else if (op == "sac") {
|
||||||
|
int32 accent_color_id;
|
||||||
|
CustomEmojiId background_custom_emoji_id;
|
||||||
|
get_args(args, accent_color_id, background_custom_emoji_id);
|
||||||
|
send_request(td_api::make_object<td_api::setAccentColor>(accent_color_id, background_custom_emoji_id));
|
||||||
} else if (op == "gns") {
|
} else if (op == "gns") {
|
||||||
int64 notification_sound_id;
|
int64 notification_sound_id;
|
||||||
get_args(args, notification_sound_id);
|
get_args(args, notification_sound_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user