Add td_api::getStoryAvailableReactions.

This commit is contained in:
levlam 2023-08-09 14:13:41 +03:00
parent ca78c82e36
commit dd023dba19
6 changed files with 24 additions and 0 deletions

View File

@ -7474,6 +7474,9 @@ openStory story_sender_chat_id:int53 story_id:int32 = Ok;
//@story_id The identifier of the story
closeStory story_sender_chat_id:int53 story_id:int32 = Ok;
//@description Returns reactions, which can be chosen for a story @row_size Number of reaction per row, 5-25
getStoryAvailableReactions row_size:int32 = AvailableReactions;
//@description Changes chosen reaction on a story
//@story_sender_chat_id The identifier of the sender of the story
//@story_id The identifier of the story

View File

@ -322,6 +322,14 @@ td_api::object_ptr<td_api::availableReactions> ReactionManager::get_sorted_avail
available_reactions.allow_custom_);
}
td_api::object_ptr<td_api::availableReactions> ReactionManager::get_available_reactions(int32 row_size) {
ChatReactions available_reactions;
available_reactions.reaction_types_ = active_reaction_types_;
available_reactions.allow_custom_ = true;
return td_->reaction_manager_->get_sorted_available_reactions(std::move(available_reactions),
ChatReactions(true, true), row_size);
}
void ReactionManager::add_recent_reaction(const ReactionType &reaction_type) {
load_recent_reactions();

View File

@ -42,6 +42,8 @@ class ReactionManager final : public Actor {
ChatReactions active_reactions,
int32 row_size);
td_api::object_ptr<td_api::availableReactions> get_available_reactions(int32 row_size);
void add_recent_reaction(const ReactionType &reaction_type);
void clear_recent_reactions(Promise<Unit> &&promise);

View File

@ -6484,6 +6484,11 @@ void Td::on_request(uint64 id, const td_api::closeStory &request) {
story_manager_->close_story(DialogId(request.story_sender_chat_id_), StoryId(request.story_id_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getStoryAvailableReactions &request) {
CHECK_IS_USER();
send_closure(actor_id(this), &Td::send_result, id, reaction_manager_->get_available_reactions(request.row_size_));
}
void Td::on_request(uint64 id, const td_api::setStoryReaction &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();

View File

@ -1021,6 +1021,8 @@ class Td final : public Actor {
void on_request(uint64 id, const td_api::closeStory &request);
void on_request(uint64 id, const td_api::getStoryAvailableReactions &request);
void on_request(uint64 id, const td_api::setStoryReaction &request);
void on_request(uint64 id, td_api::getStoryViewers &request);

View File

@ -4140,6 +4140,10 @@ class CliClient final : public Actor {
StoryId story_id;
get_args(args, story_sender_chat_id, story_id);
send_request(td_api::make_object<td_api::closeStory>(story_sender_chat_id, story_id));
} else if (op == "gsar") {
int32 row_size;
get_args(args, row_size);
send_request(td_api::make_object<td_api::getStoryAvailableReactions>(row_size));
} else if (op == "ssr") {
ChatId story_sender_chat_id;
StoryId story_id;