diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index edada4c2e..9e30f3d8f 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3208,7 +3208,7 @@ storyAreaTypeLocation location:location = StoryAreaType; //@description An area pointing to a venue @venue Information about the venue storyAreaTypeVenue venue:venue = StoryAreaType; -//@description An area pointing to a suggested reaction +//@description An area pointing to a suggested reaction. App needs to show a clickable reaction on the area and call setStoryReaction when the are is clicked //@reaction_type Type of the reaction //@is_dark True, if reaction has a dark background //@is_flipped True, if reaction corner is flipped diff --git a/td/telegram/MediaArea.cpp b/td/telegram/MediaArea.cpp index 23522f231..de357c281 100644 --- a/td/telegram/MediaArea.cpp +++ b/td/telegram/MediaArea.cpp @@ -124,6 +124,10 @@ MediaArea::MediaArea(Td *td, td_api::object_ptr &&input_ } } +bool MediaArea::has_reaction_type(const ReactionType &reaction_type) const { + return reaction_type_ == reaction_type; +} + td_api::object_ptr MediaArea::get_story_area_object() const { CHECK(is_valid()); td_api::object_ptr type; diff --git a/td/telegram/MediaArea.h b/td/telegram/MediaArea.h index a017a847b..75429e228 100644 --- a/td/telegram/MediaArea.h +++ b/td/telegram/MediaArea.h @@ -45,6 +45,8 @@ class MediaArea { MediaArea(Td *td, td_api::object_ptr &&input_story_area, const vector &old_media_areas); + bool has_reaction_type(const ReactionType &reaction_type) const; + td_api::object_ptr get_story_area_object() const; telegram_api::object_ptr get_input_media_area() const; diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index bc237ef19..01058a035 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -2346,12 +2346,20 @@ void StoryManager::on_story_replied(StoryFullId story_full_id, UserId replier_us } } -bool StoryManager::can_use_story_reaction(const ReactionType &reaction_type) const { +bool StoryManager::can_use_story_reaction(const Story *story, const ReactionType &reaction_type) const { if (reaction_type.is_empty()) { return true; } if (reaction_type.is_custom_reaction()) { - return td_->option_manager_->get_option_boolean("is_premium"); + if (td_->option_manager_->get_option_boolean("is_premium")) { + return true; + } + for (auto &area : story->areas_) { + if (area.has_reaction_type(reaction_type)) { + return true; + } + } + return false; } return td_->reaction_manager_->is_active_reaction(reaction_type); } @@ -2377,7 +2385,7 @@ void StoryManager::set_story_reaction(StoryFullId story_full_id, ReactionType re return promise.set_error(Status::Error(400, "Story not found")); } - if (!can_use_story_reaction(reaction_type)) { + if (!can_use_story_reaction(story, reaction_type)) { return promise.set_error(Status::Error(400, "The reaction isn't available for stories")); } diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index ffebff136..4abf348d2 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -521,7 +521,7 @@ class StoryManager final : public Actor { void read_stories_on_server(DialogId owner_dialog_id, StoryId story_id, uint64 log_event_id); - bool can_use_story_reaction(const ReactionType &reaction_type) const; + bool can_use_story_reaction(const Story *story, const ReactionType &reaction_type) const; void schedule_interaction_info_update();