Move list of active reactions to MessagesManager.
This commit is contained in:
parent
4e657b73ab
commit
facb8f754a
@ -342,13 +342,8 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeAvailableReactions::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeAvailableReactions>(action_ptr);
|
||||
auto old_value = td->stickers_manager_->get_active_reactions(std::move(action->prev_value_));
|
||||
auto new_value = td->stickers_manager_->get_active_reactions(std::move(action->new_value_));
|
||||
if (old_value == new_value) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventAvailableReactionsChanged>(std::move(old_value),
|
||||
std::move(new_value));
|
||||
return td_api::make_object<td_api::chatEventAvailableReactionsChanged>(std::move(action->prev_value_),
|
||||
std::move(action->new_value_));
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -5649,14 +5649,6 @@ bool is_unsent_animated_emoji_click(Td *td, DialogId dialog_id, const DialogActi
|
||||
return !td->stickers_manager_->is_sent_animated_emoji_click(dialog_id, remove_emoji_modifiers(emoji));
|
||||
}
|
||||
|
||||
vector<string> get_all_active_reactions(Td *td) {
|
||||
return td->stickers_manager_->get_all_active_reactions();
|
||||
}
|
||||
|
||||
vector<string> get_active_reactions(Td *td, const vector<string> &available_reactions) {
|
||||
return td->stickers_manager_->get_active_reactions(available_reactions);
|
||||
}
|
||||
|
||||
void on_dialog_used(TopDialogCategory category, DialogId dialog_id, int32 date) {
|
||||
send_closure(G()->top_dialog_manager(), &TopDialogManager::on_dialog_used, category, dialog_id, date);
|
||||
}
|
||||
|
@ -248,10 +248,6 @@ void on_sent_message_content(Td *td, const MessageContent *content);
|
||||
|
||||
bool is_unsent_animated_emoji_click(Td *td, DialogId dialog_id, const DialogAction &action);
|
||||
|
||||
vector<string> get_all_active_reactions(Td *td);
|
||||
|
||||
vector<string> get_active_reactions(Td *td, const vector<string> &available_reactions);
|
||||
|
||||
void on_dialog_used(TopDialogCategory category, DialogId dialog_id, int32 date);
|
||||
|
||||
void update_used_hashtags(Td *td, const MessageContent *content);
|
||||
|
@ -8194,8 +8194,7 @@ void MessagesManager::set_dialog_available_reactions(Dialog *d, vector<string> &
|
||||
|
||||
VLOG(notifications) << "Update available reactions in " << d->dialog_id << " to " << available_reactions;
|
||||
|
||||
bool need_update =
|
||||
get_active_reactions(td_, d->available_reactions) != get_active_reactions(td_, available_reactions);
|
||||
bool need_update = get_active_reactions(d->available_reactions) != get_active_reactions(available_reactions);
|
||||
|
||||
d->available_reactions = std::move(available_reactions);
|
||||
d->is_available_reactions_inited = true;
|
||||
@ -8206,14 +8205,26 @@ void MessagesManager::set_dialog_available_reactions(Dialog *d, vector<string> &
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesManager::set_active_reactions(vector<string> active_reactions) {
|
||||
if (active_reactions == active_reactions_) {
|
||||
return;
|
||||
}
|
||||
|
||||
active_reactions_ = std::move(active_reactions);
|
||||
}
|
||||
|
||||
vector<string> MessagesManager::get_active_reactions(const vector<string> &available_reactions) const {
|
||||
return available_reactions;
|
||||
}
|
||||
|
||||
vector<string> MessagesManager::get_dialog_active_reactions(const Dialog *d) const {
|
||||
CHECK(d != nullptr);
|
||||
switch (d->dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
return get_all_active_reactions(td_);
|
||||
return active_reactions_;
|
||||
case DialogType::Chat:
|
||||
case DialogType::Channel:
|
||||
return get_active_reactions(td_, d->available_reactions);
|
||||
return get_active_reactions(d->available_reactions);
|
||||
case DialogType::SecretChat:
|
||||
return {};
|
||||
default:
|
||||
@ -32439,7 +32450,7 @@ void MessagesManager::set_dialog_available_reactions(DialogId dialog_id, vector<
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
|
||||
if (get_active_reactions(td_, available_reactions) != available_reactions) {
|
||||
if (get_active_reactions(available_reactions) != available_reactions) {
|
||||
return promise.set_error(Status::Error(400, "Invalid reactions specified"));
|
||||
}
|
||||
std::unordered_set<string> unique_reactions{available_reactions.begin(), available_reactions.end()};
|
||||
|
@ -504,6 +504,8 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void set_dialog_description(DialogId dialog_id, const string &description, Promise<Unit> &&promise);
|
||||
|
||||
void set_active_reactions(vector<string> active_reactions);
|
||||
|
||||
void set_dialog_available_reactions(DialogId dialog_id, vector<string> available_reactions, Promise<Unit> &&promise);
|
||||
|
||||
void set_dialog_permissions(DialogId dialog_id, const td_api::object_ptr<td_api::chatPermissions> &permissions,
|
||||
@ -2580,6 +2582,8 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void set_dialog_available_reactions(Dialog *d, vector<string> &&available_reactions);
|
||||
|
||||
vector<string> get_active_reactions(const vector<string> &available_reactions) const;
|
||||
|
||||
vector<string> get_dialog_active_reactions(const Dialog *d) const;
|
||||
|
||||
bool is_dialog_action_unneeded(DialogId dialog_id) const;
|
||||
@ -3581,6 +3585,8 @@ class MessagesManager final : public Actor {
|
||||
|
||||
std::unordered_map<DialogId, MessageId, DialogIdHash> previous_repaired_read_inbox_max_message_id_;
|
||||
|
||||
vector<string> active_reactions_;
|
||||
|
||||
uint32 scheduled_messages_sync_generation_ = 1;
|
||||
|
||||
int64 authorization_date_ = 0;
|
||||
|
@ -475,7 +475,7 @@ void OptionManager::set_option(const string &name, td_api::object_ptr<td_api::Op
|
||||
break;
|
||||
case 'd':
|
||||
if (!is_bot && set_string_option("default_reaction", [td = td_](Slice value) {
|
||||
return td->stickers_manager_->get_active_reactions({value.str()}).size() == 1;
|
||||
return td->stickers_manager_->is_active_reaction(value.str());
|
||||
})) {
|
||||
G()->shared_config().set_option_boolean("default_reaction_needs_sync", true);
|
||||
return;
|
||||
@ -709,7 +709,8 @@ void OptionManager::set_default_reaction() {
|
||||
auto promise = PromiseCreator::lambda([actor_id = actor_id(this)](Result<Unit> &&result) {
|
||||
send_closure(actor_id, &OptionManager::on_set_default_reaction, result.is_ok());
|
||||
});
|
||||
td_->create_handler<SetDefaultReactionQuery>(std::move(promise))->send(G()->shared_config().get_option_string("default_reaction"));
|
||||
td_->create_handler<SetDefaultReactionQuery>(std::move(promise))
|
||||
->send(G()->shared_config().get_option_string("default_reaction"));
|
||||
}
|
||||
|
||||
void OptionManager::on_set_default_reaction(bool success) {
|
||||
|
@ -3201,9 +3201,10 @@ void StickersManager::on_get_available_reactions(
|
||||
new_reactions.push_back(std::move(reaction));
|
||||
}
|
||||
reactions_.reactions_ = std::move(new_reactions);
|
||||
reactions_.active_reactions_ = std::move(new_active_reactions);
|
||||
reactions_.hash_ = available_reactions->hash_;
|
||||
send_closure(G()->td(), &Td::send_update, get_update_reactions_object());
|
||||
|
||||
td_->messages_manager_->set_active_reactions(std::move(new_active_reactions));
|
||||
}
|
||||
|
||||
void StickersManager::on_get_installed_sticker_sets(bool is_masks,
|
||||
@ -4848,12 +4849,13 @@ void StickersManager::send_update_animated_emoji_clicked(FullMessageId full_mess
|
||||
dialog_id.get(), full_message_id.get_message_id().get(), get_sticker_object(sticker_id, false, true)));
|
||||
}
|
||||
|
||||
vector<string> StickersManager::get_all_active_reactions() const {
|
||||
return reactions_.active_reactions_;
|
||||
}
|
||||
|
||||
vector<string> StickersManager::get_active_reactions(const vector<string> &available_reactions) const {
|
||||
return available_reactions;
|
||||
bool StickersManager::is_active_reaction(const string &reaction) const {
|
||||
for (auto &supported_reaction : reactions_.reactions_) {
|
||||
if (supported_reaction.reaction_ == reaction) {
|
||||
return supported_reaction.is_active_;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void StickersManager::view_featured_sticker_sets(const vector<StickerSetId> &sticker_set_ids) {
|
||||
|
@ -89,9 +89,7 @@ class StickersManager final : public Actor {
|
||||
|
||||
Status on_animated_emoji_message_clicked(Slice emoji, FullMessageId full_message_id, string data);
|
||||
|
||||
vector<string> get_all_active_reactions() const;
|
||||
|
||||
vector<string> get_active_reactions(const vector<string> &available_reactions) const;
|
||||
bool is_active_reaction(const string &reaction) const;
|
||||
|
||||
void create_sticker(FileId file_id, string minithumbnail, PhotoSize thumbnail, Dimensions dimensions,
|
||||
tl_object_ptr<telegram_api::documentAttributeSticker> sticker, StickerFormat sticker_format,
|
||||
@ -459,7 +457,6 @@ class StickersManager final : public Actor {
|
||||
int32 hash_ = 0;
|
||||
bool are_being_reloaded_ = false;
|
||||
vector<Reaction> reactions_;
|
||||
vector<string> active_reactions_;
|
||||
};
|
||||
|
||||
class StickerListLogEvent;
|
||||
|
Loading…
Reference in New Issue
Block a user