Add td_api::setChatEmojiStatus.
This commit is contained in:
parent
b1db06d627
commit
c4efc0e2e0
@ -7909,6 +7909,11 @@ setChatProfileAccentColor chat_id:int53 profile_accent_color_id:int32 profile_ba
|
|||||||
//@message_auto_delete_time New time value, in seconds; unless the chat is secret, it must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren't deleted automatically
|
//@message_auto_delete_time New time value, in seconds; unless the chat is secret, it must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren't deleted automatically
|
||||||
setChatMessageAutoDeleteTime chat_id:int53 message_auto_delete_time:int32 = Ok;
|
setChatMessageAutoDeleteTime chat_id:int53 message_auto_delete_time:int32 = Ok;
|
||||||
|
|
||||||
|
//@description Changes the emoji status of a chat. Supported only for channels with enough boost level. Requires can_change_info administrator right
|
||||||
|
//@chat_id Chat identifier
|
||||||
|
//@emoji_status New emoji status; pass null to remove emoji status
|
||||||
|
setChatEmojiStatus chat_id:int53 emoji_status:emojiStatus = Ok;
|
||||||
|
|
||||||
//@description Changes the chat members permissions. Supported only for basic groups and supergroups. Requires can_restrict_members administrator right
|
//@description Changes the chat members permissions. Supported only for basic groups and supergroups. Requires can_restrict_members administrator right
|
||||||
//@chat_id Chat identifier
|
//@chat_id Chat identifier
|
||||||
//@permissions New non-administrator members permissions in the chat
|
//@permissions New non-administrator members permissions in the chat
|
||||||
|
@ -1086,7 +1086,7 @@ class UpdateEmojiStatusQuery final : public Td::ResultHandler {
|
|||||||
explicit UpdateEmojiStatusQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
explicit UpdateEmojiStatusQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(EmojiStatus emoji_status) {
|
void send(const EmojiStatus &emoji_status) {
|
||||||
send_query(G()->net_query_creator().create(
|
send_query(G()->net_query_creator().create(
|
||||||
telegram_api::account_updateEmojiStatus(emoji_status.get_input_emoji_status()), {{"me"}}));
|
telegram_api::account_updateEmojiStatus(emoji_status.get_input_emoji_status()), {{"me"}}));
|
||||||
}
|
}
|
||||||
@ -1379,6 +1379,48 @@ class UpdateChannelColorQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class UpdateChannelEmojiStatusQuery final : public Td::ResultHandler {
|
||||||
|
Promise<Unit> promise_;
|
||||||
|
ChannelId channel_id_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit UpdateChannelEmojiStatusQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void send(ChannelId channel_id, const EmojiStatus &emoji_status) {
|
||||||
|
channel_id_ = channel_id;
|
||||||
|
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
|
||||||
|
CHECK(input_channel != nullptr);
|
||||||
|
send_query(G()->net_query_creator().create(
|
||||||
|
telegram_api::channels_updateEmojiStatus(std::move(input_channel), emoji_status.get_input_emoji_status()),
|
||||||
|
{{channel_id}}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(BufferSlice packet) final {
|
||||||
|
auto result_ptr = fetch_result<telegram_api::channels_updateEmojiStatus>(packet);
|
||||||
|
if (result_ptr.is_error()) {
|
||||||
|
return on_error(result_ptr.move_as_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto ptr = result_ptr.move_as_ok();
|
||||||
|
LOG(INFO) << "Receive result for UpdateChannelEmojiStatusQuery: " << to_string(ptr);
|
||||||
|
td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_error(Status status) final {
|
||||||
|
if (status.message() == "CHAT_NOT_MODIFIED") {
|
||||||
|
if (!td_->auth_manager_->is_bot()) {
|
||||||
|
promise_.set_value(Unit());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "UpdateChannelEmojiStatusQuery");
|
||||||
|
get_recent_emoji_statuses(td_, Auto());
|
||||||
|
}
|
||||||
|
promise_.set_error(std::move(status));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class SetChannelStickerSetQuery final : public Td::ResultHandler {
|
class SetChannelStickerSetQuery final : public Td::ResultHandler {
|
||||||
Promise<Unit> promise_;
|
Promise<Unit> promise_;
|
||||||
ChannelId channel_id_;
|
ChannelId channel_id_;
|
||||||
@ -8167,7 +8209,7 @@ void ContactsManager::reorder_bot_usernames(UserId bot_user_id, vector<string> &
|
|||||||
td_->create_handler<ReorderBotUsernamesQuery>(std::move(promise))->send(bot_user_id, std::move(usernames));
|
td_->create_handler<ReorderBotUsernamesQuery>(std::move(promise))->send(bot_user_id, std::move(usernames));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::set_emoji_status(EmojiStatus emoji_status, Promise<Unit> &&promise) {
|
void ContactsManager::set_emoji_status(const EmojiStatus &emoji_status, Promise<Unit> &&promise) {
|
||||||
if (!td_->option_manager_->get_option_boolean("is_premium")) {
|
if (!td_->option_manager_->get_option_boolean("is_premium")) {
|
||||||
return promise.set_error(Status::Error(400, "The method is available only to Telegram Premium users"));
|
return promise.set_error(Status::Error(400, "The method is available only to Telegram Premium users"));
|
||||||
}
|
}
|
||||||
@ -8337,6 +8379,24 @@ void ContactsManager::set_channel_profile_accent_color(ChannelId channel_id, Acc
|
|||||||
->send(channel_id, true, profile_accent_color_id, profile_background_custom_emoji_id);
|
->send(channel_id, true, profile_accent_color_id, profile_background_custom_emoji_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContactsManager::set_channel_emoji_status(ChannelId channel_id, const EmojiStatus &emoji_status,
|
||||||
|
Promise<Unit> &&promise) {
|
||||||
|
const auto *c = get_channel(channel_id);
|
||||||
|
if (c == nullptr) {
|
||||||
|
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||||
|
}
|
||||||
|
if (c->is_megagroup) {
|
||||||
|
return promise.set_error(Status::Error(400, "Emoji status can be changed only in channel chats"));
|
||||||
|
}
|
||||||
|
if (!get_channel_status(c).can_change_info_and_settings()) {
|
||||||
|
return promise.set_error(Status::Error(400, "Not enough rights in the channel"));
|
||||||
|
}
|
||||||
|
|
||||||
|
add_recent_emoji_status(td_, emoji_status);
|
||||||
|
|
||||||
|
td_->create_handler<UpdateChannelEmojiStatusQuery>(std::move(promise))->send(channel_id, emoji_status);
|
||||||
|
}
|
||||||
|
|
||||||
void ContactsManager::set_channel_sticker_set(ChannelId channel_id, StickerSetId sticker_set_id,
|
void ContactsManager::set_channel_sticker_set(ChannelId channel_id, StickerSetId sticker_set_id,
|
||||||
Promise<Unit> &&promise) {
|
Promise<Unit> &&promise) {
|
||||||
auto c = get_channel(channel_id);
|
auto c = get_channel(channel_id);
|
||||||
|
@ -466,7 +466,7 @@ class ContactsManager final : public Actor {
|
|||||||
|
|
||||||
void reorder_bot_usernames(UserId bot_user_id, vector<string> &&usernames, Promise<Unit> &&promise);
|
void reorder_bot_usernames(UserId bot_user_id, vector<string> &&usernames, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void set_emoji_status(EmojiStatus emoji_status, Promise<Unit> &&promise);
|
void set_emoji_status(const EmojiStatus &emoji_status, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void set_chat_description(ChatId chat_id, const string &description, Promise<Unit> &&promise);
|
void set_chat_description(ChatId chat_id, const string &description, Promise<Unit> &&promise);
|
||||||
|
|
||||||
@ -485,6 +485,8 @@ class ContactsManager final : public Actor {
|
|||||||
void set_channel_profile_accent_color(ChannelId channel_id, AccentColorId profile_accent_color_id,
|
void set_channel_profile_accent_color(ChannelId channel_id, AccentColorId profile_accent_color_id,
|
||||||
CustomEmojiId profile_background_custom_emoji_id, Promise<Unit> &&promise);
|
CustomEmojiId profile_background_custom_emoji_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void set_channel_emoji_status(ChannelId channel_id, const EmojiStatus &emoji_status, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void set_channel_sticker_set(ChannelId channel_id, StickerSetId sticker_set_id, Promise<Unit> &&promise);
|
void set_channel_sticker_set(ChannelId channel_id, StickerSetId sticker_set_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void toggle_channel_sign_messages(ChannelId channel_id, bool sign_messages, Promise<Unit> &&promise);
|
void toggle_channel_sign_messages(ChannelId channel_id, bool sign_messages, Promise<Unit> &&promise);
|
||||||
|
@ -34309,6 +34309,32 @@ void MessagesManager::set_dialog_message_ttl(DialogId dialog_id, int32 ttl, Prom
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessagesManager::set_dialog_emoji_status(DialogId dialog_id, const EmojiStatus &emoji_status,
|
||||||
|
Promise<Unit> &&promise) {
|
||||||
|
if (!have_dialog_force(dialog_id, "set_dialog_emoji_status")) {
|
||||||
|
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (dialog_id.get_type()) {
|
||||||
|
case DialogType::User:
|
||||||
|
if (dialog_id == get_my_dialog_id()) {
|
||||||
|
return td_->contacts_manager_->set_emoji_status(emoji_status, std::move(promise));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DialogType::Chat:
|
||||||
|
break;
|
||||||
|
case DialogType::Channel:
|
||||||
|
return td_->contacts_manager_->set_channel_emoji_status(dialog_id.get_channel_id(), emoji_status,
|
||||||
|
std::move(promise));
|
||||||
|
case DialogType::SecretChat:
|
||||||
|
break;
|
||||||
|
case DialogType::None:
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
promise.set_error(Status::Error(400, "Can't change emoji status in the chat"));
|
||||||
|
}
|
||||||
|
|
||||||
void MessagesManager::set_dialog_permissions(DialogId dialog_id,
|
void MessagesManager::set_dialog_permissions(DialogId dialog_id,
|
||||||
const td_api::object_ptr<td_api::chatPermissions> &permissions,
|
const td_api::object_ptr<td_api::chatPermissions> &permissions,
|
||||||
Promise<Unit> &&promise) {
|
Promise<Unit> &&promise) {
|
||||||
|
@ -113,6 +113,7 @@ class Dependencies;
|
|||||||
class DialogActionBar;
|
class DialogActionBar;
|
||||||
class DialogFilter;
|
class DialogFilter;
|
||||||
class DraftMessage;
|
class DraftMessage;
|
||||||
|
class EmojiStatus;
|
||||||
struct InputMessageContent;
|
struct InputMessageContent;
|
||||||
class MessageContent;
|
class MessageContent;
|
||||||
struct MessageReactions;
|
struct MessageReactions;
|
||||||
@ -575,6 +576,8 @@ class MessagesManager final : public Actor {
|
|||||||
td_api::object_ptr<td_api::ChatAvailableReactions> &&available_reactions_ptr,
|
td_api::object_ptr<td_api::ChatAvailableReactions> &&available_reactions_ptr,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void set_dialog_emoji_status(DialogId dialog_id, const EmojiStatus &emoji_status, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void set_dialog_permissions(DialogId dialog_id, const td_api::object_ptr<td_api::chatPermissions> &permissions,
|
void set_dialog_permissions(DialogId dialog_id, const td_api::object_ptr<td_api::chatPermissions> &permissions,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
@ -6535,6 +6535,13 @@ void Td::on_request(uint64 id, const td_api::setChatMessageAutoDeleteTime &reque
|
|||||||
std::move(promise));
|
std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, const td_api::setChatEmojiStatus &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
messages_manager_->set_dialog_emoji_status(DialogId(request.chat_id_), EmojiStatus(request.emoji_status_),
|
||||||
|
std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::setChatPermissions &request) {
|
void Td::on_request(uint64 id, const td_api::setChatPermissions &request) {
|
||||||
CREATE_OK_REQUEST_PROMISE();
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
messages_manager_->set_dialog_permissions(DialogId(request.chat_id_), request.permissions_, std::move(promise));
|
messages_manager_->set_dialog_permissions(DialogId(request.chat_id_), request.permissions_, std::move(promise));
|
||||||
|
@ -1015,6 +1015,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, const td_api::setChatMessageAutoDeleteTime &request);
|
void on_request(uint64 id, const td_api::setChatMessageAutoDeleteTime &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, const td_api::setChatEmojiStatus &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::setChatPermissions &request);
|
void on_request(uint64 id, const td_api::setChatPermissions &request);
|
||||||
|
|
||||||
void on_request(uint64 id, td_api::setChatBackground &request);
|
void on_request(uint64 id, td_api::setChatBackground &request);
|
||||||
|
@ -5368,6 +5368,17 @@ class CliClient final : public Actor {
|
|||||||
int32 auto_delete_time;
|
int32 auto_delete_time;
|
||||||
get_args(args, chat_id, auto_delete_time);
|
get_args(args, chat_id, auto_delete_time);
|
||||||
send_request(td_api::make_object<td_api::setChatMessageAutoDeleteTime>(chat_id, auto_delete_time));
|
send_request(td_api::make_object<td_api::setChatMessageAutoDeleteTime>(chat_id, auto_delete_time));
|
||||||
|
} else if (op == "sces") {
|
||||||
|
ChatId chat_id;
|
||||||
|
CustomEmojiId custom_emoji_id;
|
||||||
|
int32 expiration_date;
|
||||||
|
get_args(args, chat_id, custom_emoji_id, expiration_date);
|
||||||
|
send_request(td_api::make_object<td_api::setChatEmojiStatus>(
|
||||||
|
chat_id, td_api::make_object<td_api::emojiStatus>(custom_emoji_id, expiration_date)));
|
||||||
|
} else if (op == "scese") {
|
||||||
|
ChatId chat_id;
|
||||||
|
get_args(args, chat_id);
|
||||||
|
send_request(td_api::make_object<td_api::setChatEmojiStatus>(chat_id, nullptr));
|
||||||
} else if (op == "scperm") {
|
} else if (op == "scperm") {
|
||||||
ChatId chat_id;
|
ChatId chat_id;
|
||||||
string permissions;
|
string permissions;
|
||||||
|
Loading…
Reference in New Issue
Block a user