Add more checks for paid reactions.
This commit is contained in:
parent
c55f946133
commit
62d1a85ab6
@ -9026,7 +9026,7 @@ clearRecentReactions = Ok;
|
||||
//@update_recent_reactions Pass true if the reaction needs to be added to recent reactions; tags are never added to the list of recent reactions
|
||||
addMessageReaction chat_id:int53 message_id:int53 reaction_type:ReactionType is_big:Bool update_recent_reactions:Bool = Ok;
|
||||
|
||||
//@description Removes a reaction from a message. A chosen reaction can always be removed
|
||||
//@description Removes a reaction from a message. The paid reaction can't be removed. A chosen reaction can always be removed
|
||||
//@chat_id Identifier of the chat to which the message belongs
|
||||
//@message_id Identifier of the message
|
||||
//@reaction_type Type of the reaction to remove
|
||||
@ -9047,7 +9047,7 @@ setMessageReactions chat_id:int53 message_id:int53 reaction_types:vector<Reactio
|
||||
//@limit The maximum number of reactions to be returned; must be positive and can't be greater than 100
|
||||
getMessageAddedReactions chat_id:int53 message_id:int53 reaction_type:ReactionType offset:string limit:int32 = AddedReactions;
|
||||
|
||||
//@description Changes type of default reaction for the current user @reaction_type New type of the default reaction
|
||||
//@description Changes type of default reaction for the current user @reaction_type New type of the default reaction. The paid reaction can't be set as default
|
||||
setDefaultReactionType reaction_type:ReactionType = Ok;
|
||||
|
||||
//@description Returns tags used in Saved Messages or a Saved Messages topic
|
||||
|
@ -1348,7 +1348,7 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
|
||||
|
||||
if (is_from_main_dc && !options.have_option("default_reaction_need_sync")) {
|
||||
ReactionType reaction_type(config->reactions_default_);
|
||||
if (!reaction_type.is_empty()) {
|
||||
if (!reaction_type.is_empty() && !reaction_type.is_paid_reaction()) {
|
||||
options.set_option_string("default_reaction", reaction_type.get_string());
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ MediaArea::MediaArea(Td *td, telegram_api::object_ptr<telegram_api::MediaArea> &
|
||||
reaction_type_ = ReactionType(area->reaction_);
|
||||
is_dark_ = area->dark_;
|
||||
is_flipped_ = area->flipped_;
|
||||
if (coordinates_.is_valid() && !reaction_type_.is_empty()) {
|
||||
if (coordinates_.is_valid() && !reaction_type_.is_empty() && !reaction_type_.is_paid_reaction()) {
|
||||
type_ = Type::Reaction;
|
||||
} else {
|
||||
LOG(ERROR) << "Receive " << to_string(area);
|
||||
@ -182,7 +182,7 @@ MediaArea::MediaArea(Td *td, td_api::object_ptr<td_api::inputStoryArea> &&input_
|
||||
reaction_type_ = ReactionType(type->reaction_type_);
|
||||
is_dark_ = type->is_dark_;
|
||||
is_flipped_ = type->is_flipped_;
|
||||
if (!reaction_type_.is_empty()) {
|
||||
if (!reaction_type_.is_empty() && !reaction_type_.is_paid_reaction()) {
|
||||
type_ = Type::Reaction;
|
||||
}
|
||||
break;
|
||||
|
@ -903,7 +903,7 @@ void set_message_reactions(Td *td, MessageFullId message_full_id, vector<Reactio
|
||||
return promise.set_error(Status::Error(400, "Message not found"));
|
||||
}
|
||||
for (const auto &reaction_type : reaction_types) {
|
||||
if (reaction_type.is_empty()) {
|
||||
if (reaction_type.is_empty() || reaction_type.is_paid_reaction()) {
|
||||
return promise.set_error(Status::Error(400, "Invalid reaction type specified"));
|
||||
}
|
||||
}
|
||||
|
@ -22667,7 +22667,7 @@ void MessagesManager::remove_message_reaction(MessageFullId message_full_id, Rea
|
||||
return promise.set_error(Status::Error(400, "Message not found"));
|
||||
}
|
||||
|
||||
if (reaction_type.is_empty()) {
|
||||
if (reaction_type.is_empty() || reaction_type.is_paid_reaction()) {
|
||||
return promise.set_error(Status::Error(400, "Invalid reaction specified"));
|
||||
}
|
||||
|
||||
|
@ -1190,6 +1190,9 @@ void ReactionManager::set_saved_messages_tag_title(ReactionType reaction_type, s
|
||||
if (reaction_type.is_empty()) {
|
||||
return promise.set_error(Status::Error(400, "Reaction type must be non-empty"));
|
||||
}
|
||||
if (reaction_type.is_paid_reaction()) {
|
||||
return promise.set_error(Status::Error(400, "Invalid reaction specified"));
|
||||
}
|
||||
title = clean_name(title, MAX_TAG_TITLE_LENGTH);
|
||||
|
||||
auto *all_tags = get_saved_reaction_tags(SavedMessagesTopicId());
|
||||
|
@ -55,8 +55,8 @@ StoryInteractionInfo::StoryInteractionInfo(Td *td, telegram_api::object_ptr<tele
|
||||
FlatHashSet<ReactionType, ReactionTypeHash> added_reaction_types;
|
||||
for (auto &reaction : story_views->reactions_) {
|
||||
ReactionType reaction_type(reaction->reaction_);
|
||||
if (reaction_type.is_empty()) {
|
||||
LOG(ERROR) << "Receive empty " << to_string(reaction);
|
||||
if (reaction_type.is_empty() || reaction_type.is_paid_reaction()) {
|
||||
LOG(ERROR) << "Receive " << to_string(reaction);
|
||||
continue;
|
||||
}
|
||||
if (!added_reaction_types.insert(reaction_type).second) {
|
||||
@ -81,6 +81,7 @@ void StoryInteractionInfo::add_dependencies(Dependencies &dependencies) const {
|
||||
void StoryInteractionInfo::set_chosen_reaction_type(const ReactionType &new_reaction_type,
|
||||
const ReactionType &old_reaction_type) {
|
||||
if (!old_reaction_type.is_empty()) {
|
||||
CHECK(!old_reaction_type.is_paid_reaction());
|
||||
for (auto it = reaction_counts_.begin(); it != reaction_counts_.end(); ++it) {
|
||||
if (it->first == old_reaction_type) {
|
||||
it->second--;
|
||||
@ -92,6 +93,7 @@ void StoryInteractionInfo::set_chosen_reaction_type(const ReactionType &new_reac
|
||||
}
|
||||
}
|
||||
if (!new_reaction_type.is_empty()) {
|
||||
CHECK(!new_reaction_type.is_paid_reaction());
|
||||
bool is_found = false;
|
||||
for (auto it = reaction_counts_.begin(); it != reaction_counts_.end(); ++it) {
|
||||
if (it->first == old_reaction_type) {
|
||||
|
@ -310,6 +310,7 @@ class SendStoryReactionQuery final : public Td::ResultHandler {
|
||||
if (input_peer == nullptr) {
|
||||
return on_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
CHECK(!reaction_type.is_paid_reaction());
|
||||
|
||||
int32 flags = 0;
|
||||
if (!reaction_type.is_empty() && add_to_recent) {
|
||||
@ -411,6 +412,7 @@ class GetStoryReactionsListQuery final : public Td::ResultHandler {
|
||||
if (input_peer == nullptr) {
|
||||
return on_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
CHECK(!reaction_type.is_paid_reaction());
|
||||
|
||||
int32 flags = 0;
|
||||
if (!reaction_type.is_empty()) {
|
||||
@ -2890,7 +2892,7 @@ void StoryManager::on_story_replied(StoryFullId story_full_id, UserId replier_us
|
||||
}
|
||||
|
||||
bool StoryManager::has_suggested_reaction(const Story *story, const ReactionType &reaction_type) {
|
||||
if (reaction_type.is_empty()) {
|
||||
if (reaction_type.is_empty() || reaction_type.is_paid_reaction()) {
|
||||
return false;
|
||||
}
|
||||
CHECK(story != nullptr);
|
||||
@ -3278,6 +3280,9 @@ void StoryManager::get_dialog_story_interactions(StoryFullId story_full_id, Reac
|
||||
if (!story_full_id.get_story_id().is_server()) {
|
||||
return promise.set_value(td_api::make_object<td_api::storyInteractions>());
|
||||
}
|
||||
if (reaction_type.is_paid_reaction()) {
|
||||
return promise.set_error(Status::Error(400, "Stories can't have paid reactions"));
|
||||
}
|
||||
|
||||
auto query_promise = PromiseCreator::lambda(
|
||||
[actor_id = actor_id(this), story_full_id, promise = std::move(promise)](
|
||||
@ -4578,6 +4583,10 @@ void StoryManager::on_update_story_chosen_reaction_type(DialogId owner_dialog_id
|
||||
if (!td_->dialog_manager_->have_dialog_info_force(owner_dialog_id, "on_update_story_chosen_reaction_type")) {
|
||||
return;
|
||||
}
|
||||
if (chosen_reaction_type.is_paid_reaction()) {
|
||||
LOG(ERROR) << "Receive paid reaction for " << story_id << " in " << owner_dialog_id;
|
||||
return;
|
||||
}
|
||||
StoryFullId story_full_id{owner_dialog_id, story_id};
|
||||
auto pending_reaction_it = being_set_story_reactions_.find(story_full_id);
|
||||
if (pending_reaction_it != being_set_story_reactions_.end()) {
|
||||
|
Loading…
Reference in New Issue
Block a user