Add MessagesManager::update_message_reactions.
This commit is contained in:
parent
512c0cd3c2
commit
0d79671f15
@ -3086,7 +3086,7 @@ class GetBroadcastStatsQuery final : public Td::ResultHandler {
|
||||
for (auto &info : result->recent_message_interactions_) {
|
||||
td_->messages_manager_->on_update_message_interaction_info({DialogId(channel_id_), MessageId(info->message_id_)},
|
||||
info->view_count_, info->forward_count_, false,
|
||||
nullptr, false, nullptr);
|
||||
nullptr);
|
||||
}
|
||||
promise_.set_value(std::move(result));
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class GetMessagesReactionsQuery final : public Td::ResultHandler {
|
||||
}
|
||||
}
|
||||
for (auto message_id : skipped_message_ids) {
|
||||
td_->messages_manager_->on_update_message_reactions({dialog_id_, message_id}, nullptr, Promise<Unit>());
|
||||
td_->messages_manager_->update_message_reactions({dialog_id_, message_id}, nullptr);
|
||||
}
|
||||
}
|
||||
td_->updates_manager_->on_get_updates(std::move(ptr), Promise<Unit>());
|
||||
@ -169,15 +169,17 @@ class GetMessageReactionsListQuery final : public Td::ResultHandler {
|
||||
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetMessageReactionsListQuery");
|
||||
|
||||
int32 total_count = ptr->count_;
|
||||
if (total_count < static_cast<int32>(ptr->reactions_.size())) {
|
||||
auto received_reaction_count = static_cast<int32>(ptr->reactions_.size());
|
||||
if (total_count < received_reaction_count) {
|
||||
LOG(ERROR) << "Receive invalid total_count in " << to_string(ptr);
|
||||
total_count = static_cast<int32>(ptr->reactions_.size());
|
||||
total_count = received_reaction_count;
|
||||
}
|
||||
|
||||
vector<td_api::object_ptr<td_api::addedReaction>> reactions;
|
||||
for (auto &reaction : ptr->reactions_) {
|
||||
for (const auto &reaction : ptr->reactions_) {
|
||||
DialogId dialog_id(reaction->peer_id_);
|
||||
if (!dialog_id.is_valid() || (!reaction_.empty() && reaction_ != reaction->reaction_)) {
|
||||
if (!dialog_id.is_valid() ||
|
||||
(reaction_.empty() ? reaction->reaction_.empty() : reaction_ != reaction->reaction_)) {
|
||||
LOG(ERROR) << "Receive unexpected " << to_string(reaction);
|
||||
continue;
|
||||
}
|
||||
@ -368,6 +370,7 @@ void MessageReactions::update_from(const MessageReactions &old_reactions) {
|
||||
}
|
||||
}
|
||||
}
|
||||
unread_reactions_ = old_reactions.unread_reactions_;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1919,7 +1919,7 @@ class GetMessagesViewsQuery final : public Td::ResultHandler {
|
||||
auto view_count = (flags & telegram_api::messageViews::VIEWS_MASK) != 0 ? info->views_ : 0;
|
||||
auto forward_count = (flags & telegram_api::messageViews::FORWARDS_MASK) != 0 ? info->forwards_ : 0;
|
||||
td_->messages_manager_->on_update_message_interaction_info(full_message_id, view_count, forward_count, true,
|
||||
std::move(info->replies_), false, nullptr);
|
||||
std::move(info->replies_));
|
||||
}
|
||||
}
|
||||
|
||||
@ -6800,21 +6800,25 @@ void MessagesManager::on_update_message_reactions(FullMessageId full_message_id,
|
||||
return get_message_from_server(full_message_id, std::move(promise), "on_update_message_reactions");
|
||||
}
|
||||
|
||||
update_message_interaction_info(full_message_id, -1, -1, false, nullptr, true, std::move(reactions));
|
||||
auto new_reactions = MessageReactions::get_message_reactions(td_, std::move(reactions), td_->auth_manager_->is_bot());
|
||||
update_message_interaction_info(full_message_id, -1, -1, false, nullptr, true, std::move(new_reactions));
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
void MessagesManager::update_message_reactions(FullMessageId full_message_id,
|
||||
unique_ptr<MessageReactions> &&reactions) {
|
||||
update_message_interaction_info(full_message_id, -1, -1, false, nullptr, true, std::move(reactions));
|
||||
}
|
||||
|
||||
void MessagesManager::on_update_message_interaction_info(FullMessageId full_message_id, int32 view_count,
|
||||
int32 forward_count, bool has_reply_info,
|
||||
tl_object_ptr<telegram_api::messageReplies> &&reply_info,
|
||||
bool has_reactions,
|
||||
tl_object_ptr<telegram_api::messageReactions> &&reactions) {
|
||||
tl_object_ptr<telegram_api::messageReplies> &&reply_info) {
|
||||
if (view_count < 0 || forward_count < 0) {
|
||||
LOG(ERROR) << "Receive " << view_count << "/" << forward_count << " interaction counters for " << full_message_id;
|
||||
return;
|
||||
}
|
||||
update_message_interaction_info(full_message_id, view_count, forward_count, has_reply_info, std::move(reply_info),
|
||||
has_reactions, std::move(reactions));
|
||||
false, nullptr);
|
||||
}
|
||||
|
||||
void MessagesManager::on_pending_message_views_timeout(DialogId dialog_id) {
|
||||
@ -6845,8 +6849,7 @@ void MessagesManager::on_pending_message_views_timeout(DialogId dialog_id) {
|
||||
void MessagesManager::update_message_interaction_info(FullMessageId full_message_id, int32 view_count,
|
||||
int32 forward_count, bool has_reply_info,
|
||||
tl_object_ptr<telegram_api::messageReplies> &&reply_info,
|
||||
bool has_reactions,
|
||||
tl_object_ptr<telegram_api::messageReactions> &&reactions) {
|
||||
bool has_reactions, unique_ptr<MessageReactions> &&reactions) {
|
||||
auto dialog_id = full_message_id.get_dialog_id();
|
||||
Dialog *d = get_dialog_force(dialog_id, "update_message_interaction_info");
|
||||
if (d == nullptr) {
|
||||
@ -6874,10 +6877,9 @@ void MessagesManager::update_message_interaction_info(FullMessageId full_message
|
||||
if (new_reply_info.is_empty() && !is_empty_reply_info) {
|
||||
has_reply_info = false;
|
||||
}
|
||||
auto new_reactions = MessageReactions::get_message_reactions(td_, std::move(reactions), td_->auth_manager_->is_bot());
|
||||
|
||||
if (update_message_interaction_info(dialog_id, m, view_count, forward_count, has_reply_info,
|
||||
std::move(new_reply_info), has_reactions, std::move(new_reactions),
|
||||
std::move(new_reply_info), has_reactions, std::move(reactions),
|
||||
"update_message_interaction_info")) {
|
||||
on_message_changed(d, m, true, "update_message_interaction_info");
|
||||
}
|
||||
|
@ -339,10 +339,11 @@ class MessagesManager final : public Actor {
|
||||
void on_update_message_reactions(FullMessageId full_message_id,
|
||||
tl_object_ptr<telegram_api::messageReactions> &&reactions, Promise<Unit> &&promise);
|
||||
|
||||
void update_message_reactions(FullMessageId full_message_id, unique_ptr<MessageReactions> &&reactions);
|
||||
|
||||
void on_update_message_interaction_info(FullMessageId full_message_id, int32 view_count, int32 forward_count,
|
||||
bool has_reply_info, tl_object_ptr<telegram_api::messageReplies> &&reply_info,
|
||||
bool has_reactions,
|
||||
tl_object_ptr<telegram_api::messageReactions> &&reactions);
|
||||
bool has_reply_info,
|
||||
tl_object_ptr<telegram_api::messageReplies> &&reply_info);
|
||||
|
||||
void on_update_live_location_viewed(FullMessageId full_message_id);
|
||||
|
||||
@ -2100,7 +2101,7 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void update_message_interaction_info(FullMessageId full_message_id, int32 view_count, int32 forward_count,
|
||||
bool has_reply_info, tl_object_ptr<telegram_api::messageReplies> &&reply_info,
|
||||
bool has_reactions, tl_object_ptr<telegram_api::messageReactions> &&reactions);
|
||||
bool has_reactions, unique_ptr<MessageReactions> &&reactions);
|
||||
|
||||
bool is_active_message_reply_info(DialogId dialog_id, const MessageReplyInfo &info) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user