Add td_api::togglePaidMessageReactionIsAnonymous.
This commit is contained in:
parent
7644f1c50e
commit
f9dcb217d0
@ -9077,7 +9077,7 @@ removeMessageReaction chat_id:int53 message_id:int53 reaction_type:ReactionType
|
|||||||
//@chat_id Identifier of the chat to which the message belongs
|
//@chat_id Identifier of the chat to which the message belongs
|
||||||
//@message_id Identifier of the message
|
//@message_id Identifier of the message
|
||||||
//@star_count Number of Telegram Stars to be used for the reaction; 1-getOption("paid_reaction_star_count_max")
|
//@star_count Number of Telegram Stars to be used for the reaction; 1-getOption("paid_reaction_star_count_max")
|
||||||
//@is_anonymous Pass true to make all paid reactions of the user anonymous; pass false to make the user's profile visible among top reactors
|
//@is_anonymous Pass true to make paid reaction of the user on the message anonymous; pass false to make the user's profile visible among top reactors
|
||||||
addPaidMessageReaction chat_id:int53 message_id:int53 star_count:int53 is_anonymous:Bool = Ok;
|
addPaidMessageReaction chat_id:int53 message_id:int53 star_count:int53 is_anonymous:Bool = Ok;
|
||||||
|
|
||||||
//@description Removes all pending paid reactions on a message. Can be called within 5 seconds after the last addPaidMessageReaction call
|
//@description Removes all pending paid reactions on a message. Can be called within 5 seconds after the last addPaidMessageReaction call
|
||||||
@ -9085,6 +9085,12 @@ addPaidMessageReaction chat_id:int53 message_id:int53 star_count:int53 is_anonym
|
|||||||
//@message_id Identifier of the message
|
//@message_id Identifier of the message
|
||||||
removePendingPaidMessageReactions chat_id:int53 message_id:int53 = Ok;
|
removePendingPaidMessageReactions chat_id:int53 message_id:int53 = Ok;
|
||||||
|
|
||||||
|
//@description Changes whether the paid message reaction of the user to a message is anonymous. The message must have paid reaction added by the user
|
||||||
|
//@chat_id Identifier of the chat to which the message belongs
|
||||||
|
//@message_id Identifier of the message
|
||||||
|
//@is_anonymous Pass true to make paid reaction of the user on the message anonymous; pass false to make the user's profile visible among top reactors
|
||||||
|
togglePaidMessageReactionIsAnonymous chat_id:int53 message_id:int53 is_anonymous:Bool = Ok;
|
||||||
|
|
||||||
//@description Sets reactions on a message; for bots only
|
//@description Sets reactions on a message; for bots only
|
||||||
//@chat_id Identifier of the chat to which the message belongs
|
//@chat_id Identifier of the chat to which the message belongs
|
||||||
//@message_id Identifier of the message
|
//@message_id Identifier of the message
|
||||||
|
@ -201,6 +201,43 @@ class SendPaidReactionQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TogglePaidReactionPrivacyQuery final : public Td::ResultHandler {
|
||||||
|
Promise<Unit> promise_;
|
||||||
|
DialogId dialog_id_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit TogglePaidReactionPrivacyQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void send(MessageFullId message_full_id, bool is_anonymous) {
|
||||||
|
dialog_id_ = message_full_id.get_dialog_id();
|
||||||
|
|
||||||
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
|
||||||
|
if (input_peer == nullptr) {
|
||||||
|
return on_error(Status::Error(400, "Can't access the chat"));
|
||||||
|
}
|
||||||
|
|
||||||
|
send_query(G()->net_query_creator().create(
|
||||||
|
telegram_api::messages_togglePaidReactionPrivacy(
|
||||||
|
std::move(input_peer), message_full_id.get_message_id().get_server_message_id().get(), is_anonymous),
|
||||||
|
{{dialog_id_}, {message_full_id}}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(BufferSlice packet) final {
|
||||||
|
auto result_ptr = fetch_result<telegram_api::messages_togglePaidReactionPrivacy>(packet);
|
||||||
|
if (result_ptr.is_error()) {
|
||||||
|
return on_error(result_ptr.move_as_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
promise_.set_value(Unit());
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_error(Status status) final {
|
||||||
|
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "TogglePaidReactionPrivacyQuery");
|
||||||
|
promise_.set_error(std::move(status));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class GetMessageReactionsListQuery final : public Td::ResultHandler {
|
class GetMessageReactionsListQuery final : public Td::ResultHandler {
|
||||||
Promise<td_api::object_ptr<td_api::addedReactions>> promise_;
|
Promise<td_api::object_ptr<td_api::addedReactions>> promise_;
|
||||||
DialogId dialog_id_;
|
DialogId dialog_id_;
|
||||||
@ -1050,6 +1087,21 @@ void MessageReactions::send_paid_message_reaction(Td *td, MessageFullId message_
|
|||||||
->send(message_full_id, star_count, is_anonymous, random_id);
|
->send(message_full_id, star_count, is_anonymous, random_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MessageReactions::toggle_paid_message_reaction_is_anonymous(Td *td, MessageFullId message_full_id,
|
||||||
|
bool is_anonymous, Promise<Unit> &&promise) {
|
||||||
|
if (pending_paid_reactions_ != 0) {
|
||||||
|
pending_is_anonymous_ = is_anonymous;
|
||||||
|
}
|
||||||
|
for (auto &top_reactor : top_reactors_) {
|
||||||
|
if (top_reactor.is_me()) {
|
||||||
|
top_reactor.add_count(0, is_anonymous);
|
||||||
|
td->create_handler<TogglePaidReactionPrivacyQuery>(std::move(promise))->send(message_full_id, is_anonymous);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pending_paid_reactions_ != 0;
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder &operator<<(StringBuilder &string_builder, const MessageReactions &reactions) {
|
StringBuilder &operator<<(StringBuilder &string_builder, const MessageReactions &reactions) {
|
||||||
if (reactions.are_tags_) {
|
if (reactions.are_tags_) {
|
||||||
return string_builder << "MessageTags{" << reactions.reactions_ << '}';
|
return string_builder << "MessageTags{" << reactions.reactions_ << '}';
|
||||||
|
@ -215,6 +215,9 @@ struct MessageReactions {
|
|||||||
|
|
||||||
void send_paid_message_reaction(Td *td, MessageFullId message_full_id, int64 random_id, Promise<Unit> &&promise);
|
void send_paid_message_reaction(Td *td, MessageFullId message_full_id, int64 random_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
bool toggle_paid_message_reaction_is_anonymous(Td *td, MessageFullId message_full_id, bool is_anonymous,
|
||||||
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void store(StorerT &storer) const;
|
void store(StorerT &storer) const;
|
||||||
|
|
||||||
|
@ -22851,6 +22851,26 @@ void MessagesManager::remove_paid_message_reactions(MessageFullId message_full_i
|
|||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessagesManager::toggle_paid_message_reaction_is_anonymous(MessageFullId message_full_id, bool is_anonymous,
|
||||||
|
Promise<Unit> &&promise) {
|
||||||
|
auto dialog_id = message_full_id.get_dialog_id();
|
||||||
|
Dialog *d = get_dialog_force(dialog_id, "toggle_paid_message_reaction_is_anonymous");
|
||||||
|
if (d == nullptr) {
|
||||||
|
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||||
|
}
|
||||||
|
Message *m = get_message_force(d, message_full_id.get_message_id(), "toggle_paid_message_reaction_is_anonymous");
|
||||||
|
if (m == nullptr) {
|
||||||
|
return promise.set_error(Status::Error(400, "Message not found"));
|
||||||
|
}
|
||||||
|
if (m->reactions == nullptr) {
|
||||||
|
return promise.set_error(Status::Error(400, "Message has no paid reactions"));
|
||||||
|
}
|
||||||
|
if (m->reactions->toggle_paid_message_reaction_is_anonymous(td_, message_full_id, is_anonymous, std::move(promise))) {
|
||||||
|
send_update_message_interaction_info(d->dialog_id, m);
|
||||||
|
on_message_changed(d, m, true, "toggle_paid_message_reaction_is_anonymous");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MessagesManager::set_message_reactions(Dialog *d, Message *m, bool is_big, bool add_to_recent,
|
void MessagesManager::set_message_reactions(Dialog *d, Message *m, bool is_big, bool add_to_recent,
|
||||||
Promise<Unit> &&promise) {
|
Promise<Unit> &&promise) {
|
||||||
CHECK(m->reactions != nullptr);
|
CHECK(m->reactions != nullptr);
|
||||||
|
@ -801,6 +801,9 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
void remove_paid_message_reactions(MessageFullId message_full_id, Promise<Unit> &&promise);
|
void remove_paid_message_reactions(MessageFullId message_full_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void toggle_paid_message_reaction_is_anonymous(MessageFullId message_full_id, bool is_anonymous,
|
||||||
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
td_api::object_ptr<td_api::message> get_dialog_event_log_message_object(
|
td_api::object_ptr<td_api::message> get_dialog_event_log_message_object(
|
||||||
DialogId dialog_id, tl_object_ptr<telegram_api::Message> &&message, DialogId &sender_dialog_id);
|
DialogId dialog_id, tl_object_ptr<telegram_api::Message> &&message, DialogId &sender_dialog_id);
|
||||||
|
|
||||||
|
@ -4984,6 +4984,13 @@ void Td::on_request(uint64 id, const td_api::removePendingPaidMessageReactions &
|
|||||||
std::move(promise));
|
std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, const td_api::togglePaidMessageReactionIsAnonymous &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
messages_manager_->toggle_paid_message_reaction_is_anonymous(
|
||||||
|
{DialogId(request.chat_id_), MessageId(request.message_id_)}, request.is_anonymous_, std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::removeMessageReaction &request) {
|
void Td::on_request(uint64 id, const td_api::removeMessageReaction &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_OK_REQUEST_PROMISE();
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
@ -814,6 +814,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, const td_api::removePendingPaidMessageReactions &request);
|
void on_request(uint64 id, const td_api::removePendingPaidMessageReactions &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, const td_api::togglePaidMessageReactionIsAnonymous &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::removeMessageReaction &request);
|
void on_request(uint64 id, const td_api::removeMessageReaction &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::setMessageReactions &request);
|
void on_request(uint64 id, const td_api::setMessageReactions &request);
|
||||||
|
@ -2979,6 +2979,13 @@ class CliClient final : public Actor {
|
|||||||
MessageId message_id;
|
MessageId message_id;
|
||||||
get_args(args, chat_id, message_id);
|
get_args(args, chat_id, message_id);
|
||||||
send_request(td_api::make_object<td_api::removePendingPaidMessageReactions>(chat_id, message_id));
|
send_request(td_api::make_object<td_api::removePendingPaidMessageReactions>(chat_id, message_id));
|
||||||
|
} else if (op == "tpmria") {
|
||||||
|
ChatId chat_id;
|
||||||
|
MessageId message_id;
|
||||||
|
bool is_anonymous;
|
||||||
|
get_args(args, chat_id, message_id, is_anonymous);
|
||||||
|
send_request(
|
||||||
|
td_api::make_object<td_api::togglePaidMessageReactionIsAnonymous>(chat_id, message_id, is_anonymous));
|
||||||
} else if (op == "gmars") {
|
} else if (op == "gmars") {
|
||||||
ChatId chat_id;
|
ChatId chat_id;
|
||||||
MessageId message_id;
|
MessageId message_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user