Add td_api::toggleHasSponsoredMessagesEnabled.
This commit is contained in:
parent
0d2a6ccf14
commit
14f31d81c5
@ -9788,6 +9788,10 @@ setEmojiStatus emoji_status:emojiStatus = Ok;
|
|||||||
//@description Changes the location of the current user. Needs to be called if getOption("is_location_visible") is true and location changes for more than 1 kilometer. Must not be called if the user has a business location @location The new location of the user
|
//@description Changes the location of the current user. Needs to be called if getOption("is_location_visible") is true and location changes for more than 1 kilometer. Must not be called if the user has a business location @location The new location of the user
|
||||||
setLocation location:location = Ok;
|
setLocation location:location = Ok;
|
||||||
|
|
||||||
|
//@description Toggles whether the current user has sponsored messages enabled. The setting has no effect for users without Telegram Premium for which sponsored messages are always enabled
|
||||||
|
//@has_sponsored_messages_enabled Pass true to enable sponsored messages for the current user; false to disable them
|
||||||
|
toggleHasSponsoredMessagesEnabled has_sponsored_messages_enabled:Bool = Ok;
|
||||||
|
|
||||||
//@description Changes the business location of the current user. Requires Telegram Business subscription @location The new location of the business; pass null to remove the location
|
//@description Changes the business location of the current user. Requires Telegram Business subscription @location The new location of the business; pass null to remove the location
|
||||||
setBusinessLocation location:businessLocation = Ok;
|
setBusinessLocation location:businessLocation = Ok;
|
||||||
|
|
||||||
|
@ -7775,6 +7775,12 @@ void Td::on_request(uint64 id, const td_api::setEmojiStatus &request) {
|
|||||||
user_manager_->set_emoji_status(EmojiStatus(request.emoji_status_), std::move(promise));
|
user_manager_->set_emoji_status(EmojiStatus(request.emoji_status_), std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, const td_api::toggleHasSponsoredMessagesEnabled &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
user_manager_->toggle_sponsored_messages(request.has_sponsored_messages_enabled_, std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::getThemedEmojiStatuses &request) {
|
void Td::on_request(uint64 id, const td_api::getThemedEmojiStatuses &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_REQUEST_PROMISE();
|
CREATE_REQUEST_PROMISE();
|
||||||
|
@ -1375,6 +1375,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, const td_api::setEmojiStatus &request);
|
void on_request(uint64 id, const td_api::setEmojiStatus &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, const td_api::toggleHasSponsoredMessagesEnabled &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::getThemedEmojiStatuses &request);
|
void on_request(uint64 id, const td_api::getThemedEmojiStatuses &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::getThemedChatEmojiStatuses &request);
|
void on_request(uint64 id, const td_api::getThemedChatEmojiStatuses &request);
|
||||||
|
@ -1119,6 +1119,33 @@ class UpdateEmojiStatusQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ToggleSponsoredMessagesQuery final : public Td::ResultHandler {
|
||||||
|
Promise<Unit> promise_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ToggleSponsoredMessagesQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void send(bool sponsored_enabled) {
|
||||||
|
send_query(
|
||||||
|
G()->net_query_creator().create(telegram_api::account_toggleSponsoredMessages(sponsored_enabled), {{"me"}}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(BufferSlice packet) final {
|
||||||
|
auto result_ptr = fetch_result<telegram_api::account_toggleSponsoredMessages>(packet);
|
||||||
|
if (result_ptr.is_error()) {
|
||||||
|
return on_error(result_ptr.move_as_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(DEBUG) << "Receive result for ToggleSponsoredMessagesQuery: " << result_ptr.ok();
|
||||||
|
promise_.set_value(Unit());
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_error(Status status) final {
|
||||||
|
promise_.set_error(std::move(status));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class GetUsersQuery final : public Td::ResultHandler {
|
class GetUsersQuery final : public Td::ResultHandler {
|
||||||
Promise<Unit> promise_;
|
Promise<Unit> promise_;
|
||||||
|
|
||||||
@ -5185,6 +5212,29 @@ void UserManager::on_set_emoji_status(EmojiStatus emoji_status, Promise<Unit> &&
|
|||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UserManager::toggle_sponsored_messages(bool sponsored_enabled, Promise<Unit> &&promise) {
|
||||||
|
auto query_promise = PromiseCreator::lambda(
|
||||||
|
[actor_id = actor_id(this), sponsored_enabled, promise = std::move(promise)](Result<Unit> result) mutable {
|
||||||
|
if (result.is_ok()) {
|
||||||
|
send_closure(actor_id, &UserManager::on_toggle_sponsored_messages, sponsored_enabled, std::move(promise));
|
||||||
|
} else {
|
||||||
|
promise.set_error(result.move_as_error());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
td_->create_handler<ToggleSponsoredMessagesQuery>(std::move(query_promise))->send(sponsored_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserManager::on_toggle_sponsored_messages(bool sponsored_enabled, Promise<Unit> &&promise) {
|
||||||
|
auto my_user_id = get_my_id();
|
||||||
|
UserFull *user_full = get_user_full_force(my_user_id, "on_toggle_sponsored_messages");
|
||||||
|
if (user_full != nullptr && user_full->sponsored_enabled != sponsored_enabled) {
|
||||||
|
user_full->sponsored_enabled = sponsored_enabled;
|
||||||
|
user_full->is_changed = true;
|
||||||
|
update_user_full(user_full, my_user_id, "on_toggle_sponsored_messages");
|
||||||
|
}
|
||||||
|
promise.set_value(Unit());
|
||||||
|
}
|
||||||
|
|
||||||
void UserManager::get_support_user(Promise<td_api::object_ptr<td_api::user>> &&promise) {
|
void UserManager::get_support_user(Promise<td_api::object_ptr<td_api::user>> &&promise) {
|
||||||
if (support_user_id_.is_valid()) {
|
if (support_user_id_.is_valid()) {
|
||||||
return promise.set_value(get_user_object(support_user_id_));
|
return promise.set_value(get_user_object(support_user_id_));
|
||||||
|
@ -355,6 +355,8 @@ class UserManager final : public Actor {
|
|||||||
|
|
||||||
void set_emoji_status(const EmojiStatus &emoji_status, Promise<Unit> &&promise);
|
void set_emoji_status(const EmojiStatus &emoji_status, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void toggle_sponsored_messages(bool sponsored_enabled, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void get_support_user(Promise<td_api::object_ptr<td_api::user>> &&promise);
|
void get_support_user(Promise<td_api::object_ptr<td_api::user>> &&promise);
|
||||||
|
|
||||||
void get_user_profile_photos(UserId user_id, int32 offset, int32 limit,
|
void get_user_profile_photos(UserId user_id, int32 offset, int32 limit,
|
||||||
@ -866,6 +868,8 @@ class UserManager final : public Actor {
|
|||||||
|
|
||||||
void on_set_emoji_status(EmojiStatus emoji_status, Promise<Unit> &&promise);
|
void on_set_emoji_status(EmojiStatus emoji_status, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void on_toggle_sponsored_messages(bool sponsored_enabled, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void on_get_support_user(UserId user_id, Promise<td_api::object_ptr<td_api::user>> &&promise);
|
void on_get_support_user(UserId user_id, Promise<td_api::object_ptr<td_api::user>> &&promise);
|
||||||
|
|
||||||
void send_get_user_photos_query(UserId user_id, const UserPhotos *user_photos);
|
void send_get_user_photos_query(UserId user_id, const UserPhotos *user_photos);
|
||||||
|
@ -5933,6 +5933,8 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, custom_emoji_id, expiration_date);
|
get_args(args, custom_emoji_id, expiration_date);
|
||||||
send_request(td_api::make_object<td_api::setEmojiStatus>(
|
send_request(td_api::make_object<td_api::setEmojiStatus>(
|
||||||
td_api::make_object<td_api::emojiStatus>(custom_emoji_id, expiration_date)));
|
td_api::make_object<td_api::emojiStatus>(custom_emoji_id, expiration_date)));
|
||||||
|
} else if (op == "thsme") {
|
||||||
|
send_request(td_api::make_object<td_api::toggleHasSponsoredMessagesEnabled>(as_bool(args)));
|
||||||
} else if (op == "gtes") {
|
} else if (op == "gtes") {
|
||||||
send_request(td_api::make_object<td_api::getThemedEmojiStatuses>());
|
send_request(td_api::make_object<td_api::getThemedEmojiStatuses>());
|
||||||
} else if (op == "gdes") {
|
} else if (op == "gdes") {
|
||||||
|
Loading…
Reference in New Issue
Block a user