Add td_api::updateAvailableMessageEffects.
This commit is contained in:
parent
aab71e18cf
commit
5d349d86e1
@ -7250,6 +7250,9 @@ updateWebAppMessageSent web_app_launch_id:int64 = Update;
|
||||
//@description The list of active emoji reactions has changed @emojis The new list of active emoji reactions
|
||||
updateActiveEmojiReactions emojis:vector<string> = Update;
|
||||
|
||||
//@description The list of available message effects has changed @effect_ids The new list of available message effects. Emoji reaction effects are guaranteed to be returned before sticker effects
|
||||
updateAvailableMessageEffects effect_ids:vector<int64> = Update;
|
||||
|
||||
//@description The type of default reaction has changed @reaction_type The new type of the default reaction
|
||||
updateDefaultReactionType reaction_type:ReactionType = Update;
|
||||
|
||||
|
@ -475,6 +475,7 @@ void ReactionManager::init() {
|
||||
td_->stickers_manager_->init();
|
||||
|
||||
load_active_reactions();
|
||||
load_active_message_effects();
|
||||
|
||||
if (td_->option_manager_->get_option_boolean("default_reaction_needs_sync")) {
|
||||
send_set_default_reaction_query();
|
||||
@ -1228,6 +1229,14 @@ td_api::object_ptr<td_api::messageEffects> ReactionManager::get_message_effects_
|
||||
return td_api::make_object<td_api::messageEffects>(std::move(effects));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::updateAvailableMessageEffects> ReactionManager::get_update_available_message_effects_object()
|
||||
const {
|
||||
return td_api::make_object<td_api::updateAvailableMessageEffects>(vector<int64>(active_message_effects_));
|
||||
}
|
||||
|
||||
void ReactionManager::reload_message_effects() {
|
||||
}
|
||||
|
||||
void ReactionManager::get_message_effects(Promise<td_api::object_ptr<td_api::messageEffects>> &&promise) {
|
||||
auto query_promise = PromiseCreator::lambda(
|
||||
[actor_id = actor_id(this), promise = std::move(promise)](
|
||||
@ -1324,6 +1333,8 @@ void ReactionManager::on_get_message_effects(
|
||||
|
||||
message_effects_.effects_ = std::move(new_effects);
|
||||
message_effects_.hash_ = effects->hash_;
|
||||
|
||||
update_active_message_effects();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -1332,6 +1343,46 @@ void ReactionManager::on_get_message_effects(
|
||||
promise.set_value(get_message_effects_object());
|
||||
}
|
||||
|
||||
void ReactionManager::save_active_message_effects() {
|
||||
LOG(INFO) << "Save " << active_message_effects_.size() << " available message effects";
|
||||
G()->td_db()->get_binlog_pmc()->set("active_message_effects",
|
||||
log_event_store(active_message_effects_).as_slice().str());
|
||||
}
|
||||
|
||||
void ReactionManager::load_active_message_effects() {
|
||||
LOG(INFO) << "Loading active message effects";
|
||||
string active_message_effects = G()->td_db()->get_binlog_pmc()->get("active_message_effects");
|
||||
if (active_message_effects.empty()) {
|
||||
return reload_message_effects();
|
||||
}
|
||||
|
||||
auto status = log_event_parse(active_message_effects_, active_message_effects);
|
||||
if (status.is_error()) {
|
||||
LOG(ERROR) << "Can't load active message effects: " << status;
|
||||
active_message_effects_ = {};
|
||||
return reload_message_effects();
|
||||
}
|
||||
|
||||
LOG(INFO) << "Successfully loaded " << active_message_effects_.size() << " active message effects";
|
||||
|
||||
send_closure(G()->td(), &Td::send_update, get_update_available_message_effects_object());
|
||||
}
|
||||
|
||||
void ReactionManager::update_active_message_effects() {
|
||||
vector<int64> active_message_effects;
|
||||
for (auto &effect : message_effects_.effects_) {
|
||||
active_message_effects.push_back(effect.id_);
|
||||
}
|
||||
if (active_message_effects == active_message_effects_) {
|
||||
return;
|
||||
}
|
||||
active_message_effects_ = std::move(active_message_effects);
|
||||
|
||||
save_active_message_effects();
|
||||
|
||||
send_closure(G()->td(), &Td::send_update, get_update_available_message_effects_object());
|
||||
}
|
||||
|
||||
void ReactionManager::get_message_effect(int64 effect_id,
|
||||
Promise<td_api::object_ptr<td_api::messageEffect>> &&promise) {
|
||||
/*
|
||||
@ -1358,6 +1409,9 @@ void ReactionManager::get_current_state(vector<td_api::object_ptr<td_api::Update
|
||||
for (auto &it : topic_tags_) {
|
||||
updates.push_back(get_update_saved_messages_tags_object(it.first, it.second.get()));
|
||||
}
|
||||
if (!active_message_effects_.empty()) {
|
||||
updates.push_back(get_update_available_message_effects_object());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -81,6 +81,8 @@ class ReactionManager final : public Actor {
|
||||
|
||||
void set_saved_messages_tag_title(ReactionType reaction_type, string title, Promise<Unit> &&promise);
|
||||
|
||||
void reload_message_effects();
|
||||
|
||||
void get_message_effects(Promise<td_api::object_ptr<td_api::messageEffects>> &&promise);
|
||||
|
||||
void get_message_effect(int64 effect_id, Promise<td_api::object_ptr<td_api::messageEffect>> &&promise);
|
||||
@ -265,9 +267,17 @@ class ReactionManager final : public Actor {
|
||||
|
||||
td_api::object_ptr<td_api::messageEffects> get_message_effects_object() const;
|
||||
|
||||
td_api::object_ptr<td_api::updateAvailableMessageEffects> get_update_available_message_effects_object() const;
|
||||
|
||||
void on_get_message_effects(Result<telegram_api::object_ptr<telegram_api::messages_AvailableEffects>> r_effects,
|
||||
Promise<td_api::object_ptr<td_api::messageEffects>> promise);
|
||||
|
||||
void save_active_message_effects();
|
||||
|
||||
void load_active_message_effects();
|
||||
|
||||
void update_active_message_effects();
|
||||
|
||||
Td *td_;
|
||||
ActorShared<> parent_;
|
||||
|
||||
@ -291,6 +301,7 @@ class ReactionManager final : public Actor {
|
||||
pending_get_topic_saved_reaction_tags_queries_;
|
||||
|
||||
Effects message_effects_;
|
||||
vector<int64> active_message_effects_;
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
@ -3957,7 +3957,6 @@ void Td::send_update(tl_object_ptr<td_api::Update> &&object) {
|
||||
VLOG(td_requests) << "Sending update: " << to_string(object);
|
||||
}
|
||||
break;
|
||||
case td_api::updateSpeedLimitNotification::ID:
|
||||
case td_api::updateDefaultReactionType::ID / 2:
|
||||
LOG(ERROR) << "Sending update: " << oneline(to_string(object));
|
||||
break;
|
||||
|
@ -2260,6 +2260,7 @@ void UpdatesManager::try_reload_data() {
|
||||
Auto());
|
||||
td_->quick_reply_manager_->reload_quick_reply_shortcuts();
|
||||
td_->reaction_manager_->reload_reactions();
|
||||
td_->reaction_manager_->reload_message_effects();
|
||||
|
||||
for (int32 type = 0; type < MAX_REACTION_LIST_TYPE; type++) {
|
||||
auto reaction_list_type = static_cast<ReactionListType>(type);
|
||||
|
Loading…
Reference in New Issue
Block a user