Add td_api::messageReactions and messageReactions.are_tags.

This commit is contained in:
levlam 2024-01-22 19:37:05 +03:00
parent 0823ee492e
commit eb80098431
5 changed files with 22 additions and 10 deletions

View File

@ -1228,13 +1228,16 @@ messageReplyInfo reply_count:int32 recent_replier_ids:vector<MessageSender> last
//@recent_sender_ids Identifiers of at most 3 recent message senders, added the reaction; available in private, basic group and supergroup chats //@recent_sender_ids Identifiers of at most 3 recent message senders, added the reaction; available in private, basic group and supergroup chats
messageReaction type:ReactionType total_count:int32 is_chosen:Bool used_sender_id:MessageSender recent_sender_ids:vector<MessageSender> = MessageReaction; messageReaction type:ReactionType total_count:int32 is_chosen:Bool used_sender_id:MessageSender recent_sender_ids:vector<MessageSender> = MessageReaction;
//@description Contains a list of reactions added to a message @reactions List of added reactions @are_tags True, if the reactions are tags and the message can be found by them
messageReactions reactions:vector<messageReaction> are_tags:Bool = MessageReactions;
//@description Contains information about interactions with a message //@description Contains information about interactions with a message
//@view_count Number of times the message was viewed //@view_count Number of times the message was viewed
//@forward_count Number of times the message was forwarded //@forward_count Number of times the message was forwarded
//@reply_info Information about direct or indirect replies to the message; may be null. Currently, available only in channels with a discussion supergroup and discussion supergroups for messages, which are not replies itself //@reply_info Information about direct or indirect replies to the message; may be null. Currently, available only in channels with a discussion supergroup and discussion supergroups for messages, which are not replies itself
//@reactions The list of reactions added to the message //@reactions The list of reactions or tags added to the message; may be null
messageInteractionInfo view_count:int32 forward_count:int32 reply_info:messageReplyInfo reactions:vector<messageReaction> = MessageInteractionInfo; messageInteractionInfo view_count:int32 forward_count:int32 reply_info:messageReplyInfo reactions:messageReactions = MessageInteractionInfo;
//@description Contains information about an unread reaction to a message //@description Contains information about an unread reaction to a message
//@type Type of the reaction //@type Type of the reaction

View File

@ -465,6 +465,7 @@ unique_ptr<MessageReactions> MessageReactions::get_message_reactions(
auto result = make_unique<MessageReactions>(); auto result = make_unique<MessageReactions>();
result->can_get_added_reactions_ = reactions->can_see_list_; result->can_get_added_reactions_ = reactions->can_see_list_;
result->is_min_ = reactions->min_; result->is_min_ = reactions->min_;
result->are_tags_ = reactions->reactions_as_tags_;
DialogId my_dialog_id; DialogId my_dialog_id;
for (auto &peer_reaction : reactions->recent_reactions_) { for (auto &peer_reaction : reactions->recent_reactions_) {
@ -796,11 +797,12 @@ bool MessageReactions::are_consistent_with_list(
} }
} }
vector<td_api::object_ptr<td_api::messageReaction>> MessageReactions::get_message_reactions_object( td_api::object_ptr<td_api::messageReactions> MessageReactions::get_message_reactions_object(Td *td, UserId my_user_id,
Td *td, UserId my_user_id, UserId peer_user_id) const { UserId peer_user_id) const {
return transform(reactions_, [td, my_user_id, peer_user_id](const MessageReaction &reaction) { auto reactions = transform(reactions_, [td, my_user_id, peer_user_id](const MessageReaction &reaction) {
return reaction.get_message_reaction_object(td, my_user_id, peer_user_id); return reaction.get_message_reaction_object(td, my_user_id, peer_user_id);
}); });
return td_api::make_object<td_api::messageReactions>(std::move(reactions), are_tags_);
} }
void MessageReactions::add_min_channels(Td *td) const { void MessageReactions::add_min_channels(Td *td) const {
@ -835,7 +837,8 @@ bool MessageReactions::need_update_message_reactions(const MessageReactions *old
// unread_reactions_ and chosen_reaction_order_ are updated independently; compare all other fields // unread_reactions_ and chosen_reaction_order_ are updated independently; compare all other fields
return old_reactions->reactions_ != new_reactions->reactions_ || old_reactions->is_min_ != new_reactions->is_min_ || return old_reactions->reactions_ != new_reactions->reactions_ || old_reactions->is_min_ != new_reactions->is_min_ ||
old_reactions->can_get_added_reactions_ != new_reactions->can_get_added_reactions_ || old_reactions->can_get_added_reactions_ != new_reactions->can_get_added_reactions_ ||
old_reactions->need_polling_ != new_reactions->need_polling_; old_reactions->need_polling_ != new_reactions->need_polling_ ||
old_reactions->are_tags_ != new_reactions->are_tags_;
} }
bool MessageReactions::need_update_unread_reactions(const MessageReactions *old_reactions, bool MessageReactions::need_update_unread_reactions(const MessageReactions *old_reactions,
@ -847,10 +850,13 @@ bool MessageReactions::need_update_unread_reactions(const MessageReactions *old_
} }
StringBuilder &operator<<(StringBuilder &string_builder, const MessageReactions &reactions) { StringBuilder &operator<<(StringBuilder &string_builder, const MessageReactions &reactions) {
if (reactions.are_tags_) {
return string_builder << "MessageTags{" << reactions.reactions_ << '}';
}
return string_builder << (reactions.is_min_ ? "Min" : "") << "MessageReactions{" << reactions.reactions_ return string_builder << (reactions.is_min_ ? "Min" : "") << "MessageReactions{" << reactions.reactions_
<< " with unread " << reactions.unread_reactions_ << ", reaction order " << " with unread " << reactions.unread_reactions_ << ", reaction order "
<< reactions.chosen_reaction_order_ << reactions.chosen_reaction_order_
<< " and can_get_added_reactions = " << reactions.can_get_added_reactions_; << " and can_get_added_reactions = " << reactions.can_get_added_reactions_ << '}';
} }
StringBuilder &operator<<(StringBuilder &string_builder, const unique_ptr<MessageReactions> &reactions) { StringBuilder &operator<<(StringBuilder &string_builder, const unique_ptr<MessageReactions> &reactions) {

View File

@ -156,6 +156,7 @@ struct MessageReactions {
bool is_min_ = false; bool is_min_ = false;
bool need_polling_ = true; bool need_polling_ = true;
bool can_get_added_reactions_ = false; bool can_get_added_reactions_ = false;
bool are_tags_ = false;
MessageReactions() = default; MessageReactions() = default;
@ -186,8 +187,8 @@ struct MessageReactions {
FlatHashMap<ReactionType, vector<DialogId>, ReactionTypeHash> reaction_types, FlatHashMap<ReactionType, vector<DialogId>, ReactionTypeHash> reaction_types,
int32 total_count) const; int32 total_count) const;
vector<td_api::object_ptr<td_api::messageReaction>> get_message_reactions_object(Td *td, UserId my_user_id, td_api::object_ptr<td_api::messageReactions> get_message_reactions_object(Td *td, UserId my_user_id,
UserId peer_user_id) const; UserId peer_user_id) const;
void add_min_channels(Td *td) const; void add_min_channels(Td *td) const;

View File

@ -107,6 +107,7 @@ void MessageReactions::store(StorerT &storer) const {
STORE_FLAG(has_unread_reactions); STORE_FLAG(has_unread_reactions);
STORE_FLAG(has_reactions); STORE_FLAG(has_reactions);
STORE_FLAG(has_chosen_reaction_order); STORE_FLAG(has_chosen_reaction_order);
STORE_FLAG(are_tags_);
END_STORE_FLAGS(); END_STORE_FLAGS();
if (has_reactions) { if (has_reactions) {
td::store(reactions_, storer); td::store(reactions_, storer);
@ -131,6 +132,7 @@ void MessageReactions::parse(ParserT &parser) {
PARSE_FLAG(has_unread_reactions); PARSE_FLAG(has_unread_reactions);
PARSE_FLAG(has_reactions); PARSE_FLAG(has_reactions);
PARSE_FLAG(has_chosen_reaction_order); PARSE_FLAG(has_chosen_reaction_order);
PARSE_FLAG(are_tags_);
END_PARSE_FLAGS(); END_PARSE_FLAGS();
if (has_reactions) { if (has_reactions) {
td::parse(reactions_, parser); td::parse(reactions_, parser);

View File

@ -6466,7 +6466,7 @@ td_api::object_ptr<td_api::messageInteractionInfo> MessagesManager::get_message_
CHECK(reply_info != nullptr); CHECK(reply_info != nullptr);
} }
vector<td_api::object_ptr<td_api::messageReaction>> reactions; td_api::object_ptr<td_api::messageReactions> reactions;
if (has_reactions) { if (has_reactions) {
UserId my_user_id; UserId my_user_id;
UserId peer_user_id; UserId peer_user_id;