Update default reaction from other apps.

This commit is contained in:
levlam 2022-08-22 15:44:38 +03:00
parent c2a62dbc09
commit ef4f0989b1
4 changed files with 15 additions and 4 deletions

View File

@ -12,6 +12,7 @@
#include "td/telegram/JsonValue.h"
#include "td/telegram/LinkManager.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/MessageReaction.h"
#include "td/telegram/net/AuthDataShared.h"
#include "td/telegram/net/ConnectionCreator.h"
#include "td/telegram/net/DcId.h"
@ -1414,6 +1415,13 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
options.set_option_integer("notification_cloud_delay_ms", fix_timeout_ms(config->notify_cloud_delay_ms_));
options.set_option_integer("notification_default_delay_ms", fix_timeout_ms(config->notify_default_delay_ms_));
if (is_from_main_dc && !options.have_option("default_reaction_need_sync")) {
auto reaction_str = get_message_reaction_string(config->reactions_default_);
if (!reaction_str.empty()) {
options.set_option_string("default_reaction", reaction_str);
}
}
// delete outdated options
options.set_option_empty("suggested_language_code");
options.set_option_empty("chat_big_size");

View File

@ -57,7 +57,7 @@ static telegram_api::object_ptr<telegram_api::Reaction> get_input_reaction(const
return telegram_api::make_object<telegram_api::reactionEmoji>(reaction);
}
static string get_reaction_string(const telegram_api::object_ptr<telegram_api::Reaction> &reaction) {
string get_message_reaction_string(const telegram_api::object_ptr<telegram_api::Reaction> &reaction) {
if (reaction == nullptr) {
return string();
}
@ -271,7 +271,7 @@ class GetMessageReactionsListQuery final : public Td::ResultHandler {
FlatHashMap<string, vector<DialogId>> recent_reactions;
for (const auto &reaction : ptr->reactions_) {
DialogId dialog_id(reaction->peer_id_);
auto reaction_str = get_reaction_string(reaction->reaction_);
auto reaction_str = get_message_reaction_string(reaction->reaction_);
if (!dialog_id.is_valid() || (reaction_.empty() ? reaction_str.empty() : reaction_ != reaction_str)) {
LOG(ERROR) << "Receive unexpected " << to_string(reaction);
continue;
@ -451,7 +451,7 @@ unique_ptr<MessageReactions> MessageReactions::get_message_reactions(
FlatHashSet<string> reaction_strings;
FlatHashSet<DialogId, DialogIdHash> recent_choosers;
for (auto &reaction_count : reactions->results_) {
auto reaction_str = get_reaction_string(reaction_count->reaction_);
auto reaction_str = get_message_reaction_string(reaction_count->reaction_);
if (reaction_count->count_ <= 0 || reaction_count->count_ >= MessageReaction::MAX_CHOOSE_COUNT ||
reaction_str.empty()) {
LOG(ERROR) << "Receive reaction " << reaction_str << " with invalid count " << reaction_count->count_;
@ -466,7 +466,7 @@ unique_ptr<MessageReactions> MessageReactions::get_message_reactions(
vector<DialogId> recent_chooser_dialog_ids;
vector<std::pair<ChannelId, MinChannel>> recent_chooser_min_channels;
for (auto &peer_reaction : reactions->recent_reactions_) {
auto peer_reaction_str = get_reaction_string(peer_reaction->reaction_);
auto peer_reaction_str = get_message_reaction_string(peer_reaction->reaction_);
if (peer_reaction_str == reaction_str) {
DialogId dialog_id(peer_reaction->peer_id_);
if (!dialog_id.is_valid()) {

View File

@ -173,6 +173,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const MessageReactions
StringBuilder &operator<<(StringBuilder &string_builder, const unique_ptr<MessageReactions> &reactions);
string get_message_reaction_string(const telegram_api::object_ptr<telegram_api::Reaction> &reaction);
string get_message_reaction_string(const td_api::object_ptr<td_api::ReactionType> &type);
void reload_message_reactions(Td *td, DialogId dialog_id, vector<MessageId> &&message_ids);

View File

@ -4053,6 +4053,7 @@ void Td::send_update(tl_object_ptr<td_api::Update> &&object) {
case td_api::updateFileAddedToDownloads::ID / 2:
case td_api::updateFileDownload::ID / 2:
case td_api::updateFileRemovedFromDownloads::ID / 2:
case td_api::updateDefaultReactionType::ID:
LOG(ERROR) << "Sending update: " << oneline(to_string(object));
break;
default: