Support adding tags to a message.
This commit is contained in:
parent
61277da56f
commit
e8f96d2520
@ -7627,12 +7627,12 @@ getMessageAvailableReactions chat_id:int53 message_id:int53 row_size:int32 = Ava
|
|||||||
//@description Clears the list of recently used reactions
|
//@description Clears the list of recently used reactions
|
||||||
clearRecentReactions = Ok;
|
clearRecentReactions = Ok;
|
||||||
|
|
||||||
//@description Adds a reaction to a message. Use getMessageAvailableReactions to receive the list of available reactions for the message
|
//@description Adds a reaction or a tag to a message. Use getMessageAvailableReactions to receive the list of available reactions for the message
|
||||||
//@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
|
||||||
//@reaction_type Type of the reaction to add
|
//@reaction_type Type of the reaction to add
|
||||||
//@is_big Pass true if the reaction is added with a big animation
|
//@is_big Pass true if the reaction is added with a big animation
|
||||||
//@update_recent_reactions Pass true if the reaction needs to be added to recent reactions
|
//@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;
|
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. A chosen reaction can always be removed
|
||||||
|
@ -613,7 +613,7 @@ void MessageReactions::update_from(const MessageReactions &old_reactions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MessageReactions::add_my_reaction(const ReactionType &reaction_type, bool is_big, DialogId my_dialog_id,
|
bool MessageReactions::add_my_reaction(const ReactionType &reaction_type, bool is_big, DialogId my_dialog_id,
|
||||||
bool have_recent_choosers) {
|
bool have_recent_choosers, bool is_tag) {
|
||||||
vector<ReactionType> new_chosen_reaction_order = get_chosen_reaction_types();
|
vector<ReactionType> new_chosen_reaction_order = get_chosen_reaction_types();
|
||||||
|
|
||||||
auto added_reaction = get_reaction(reaction_type);
|
auto added_reaction = get_reaction(reaction_type);
|
||||||
@ -633,6 +633,11 @@ bool MessageReactions::add_my_reaction(const ReactionType &reaction_type, bool i
|
|||||||
} else if (!is_big) {
|
} else if (!is_big) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!is_tag) {
|
||||||
|
CHECK(!are_tags_);
|
||||||
|
} else {
|
||||||
|
are_tags_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
auto max_reaction_count = get_max_reaction_count();
|
auto max_reaction_count = get_max_reaction_count();
|
||||||
while (new_chosen_reaction_order.size() > max_reaction_count) {
|
while (new_chosen_reaction_order.size() > max_reaction_count) {
|
||||||
|
@ -170,8 +170,8 @@ struct MessageReactions {
|
|||||||
|
|
||||||
void update_from(const MessageReactions &old_reactions);
|
void update_from(const MessageReactions &old_reactions);
|
||||||
|
|
||||||
bool add_my_reaction(const ReactionType &reaction_type, bool is_big, DialogId my_dialog_id,
|
bool add_my_reaction(const ReactionType &reaction_type, bool is_big, DialogId my_dialog_id, bool have_recent_choosers,
|
||||||
bool have_recent_choosers);
|
bool is_tag);
|
||||||
|
|
||||||
bool remove_my_reaction(const ReactionType &reaction_type, DialogId my_dialog_id);
|
bool remove_my_reaction(const ReactionType &reaction_type, DialogId my_dialog_id);
|
||||||
|
|
||||||
|
@ -22724,11 +22724,13 @@ void MessagesManager::add_message_reaction(MessageFullId message_full_id, Reacti
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOG(INFO) << "Have message with " << *m->reactions;
|
LOG(INFO) << "Have message with " << *m->reactions;
|
||||||
if (!m->reactions->add_my_reaction(reaction_type, is_big, get_my_reaction_dialog_id(d), have_recent_choosers)) {
|
bool is_tag = can_add_message_tag(dialog_id, m->reactions.get());
|
||||||
|
if (!m->reactions->add_my_reaction(reaction_type, is_big, get_my_reaction_dialog_id(d), have_recent_choosers,
|
||||||
|
is_tag)) {
|
||||||
return promise.set_value(Unit());
|
return promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add_to_recent) {
|
if (!is_tag && add_to_recent) {
|
||||||
td_->reaction_manager_->add_recent_reaction(reaction_type);
|
td_->reaction_manager_->add_recent_reaction(reaction_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user