Save quick reply shortcuts to binlog.
This commit is contained in:
parent
b7e8584260
commit
139d1d92ae
@ -523,6 +523,7 @@ void QuickReplyManager::on_reload_quick_reply_shortcuts(
|
|||||||
case telegram_api::messages_quickRepliesNotModified::ID:
|
case telegram_api::messages_quickRepliesNotModified::ID:
|
||||||
if (!shortcuts_.are_inited_) {
|
if (!shortcuts_.are_inited_) {
|
||||||
shortcuts_.are_inited_ = true;
|
shortcuts_.are_inited_ = true;
|
||||||
|
save_quick_reply_shortcuts();
|
||||||
send_update_quick_reply_shortcuts();
|
send_update_quick_reply_shortcuts();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -643,6 +644,7 @@ void QuickReplyManager::on_reload_quick_reply_shortcuts(
|
|||||||
shortcuts_.shortcuts_ = std::move(new_shortcuts);
|
shortcuts_.shortcuts_ = std::move(new_shortcuts);
|
||||||
shortcuts_.are_inited_ = true;
|
shortcuts_.are_inited_ = true;
|
||||||
|
|
||||||
|
save_quick_reply_shortcuts();
|
||||||
for (auto shortcut_id : changed_shortcut_ids) {
|
for (auto shortcut_id : changed_shortcut_ids) {
|
||||||
send_update_quick_reply_shortcut(get_shortcut(shortcut_id), "on_reload_quick_reply_shortcuts 2");
|
send_update_quick_reply_shortcut(get_shortcut(shortcut_id), "on_reload_quick_reply_shortcuts 2");
|
||||||
}
|
}
|
||||||
@ -697,6 +699,7 @@ void QuickReplyManager::delete_quick_reply_shortcut(QuickReplyShortcutId shortcu
|
|||||||
return promise.set_error(Status::Error(400, "Shortcut not found"));
|
return promise.set_error(Status::Error(400, "Shortcut not found"));
|
||||||
}
|
}
|
||||||
shortcuts_.shortcuts_.erase(it);
|
shortcuts_.shortcuts_.erase(it);
|
||||||
|
save_quick_reply_shortcuts();
|
||||||
|
|
||||||
if (!shortcut_id.is_server()) {
|
if (!shortcut_id.is_server()) {
|
||||||
return promise.set_value(Unit());
|
return promise.set_value(Unit());
|
||||||
@ -742,11 +745,11 @@ void QuickReplyManager::reorder_quick_reply_shortcuts(const vector<QuickReplySho
|
|||||||
shortcuts.push_back(std::move(shortcut));
|
shortcuts.push_back(std::move(shortcut));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool is_list_changed = old_shortcut_ids != get_shortcut_ids();
|
|
||||||
shortcuts_.shortcuts_ = std::move(shortcuts);
|
shortcuts_.shortcuts_ = std::move(shortcuts);
|
||||||
if (!is_list_changed) {
|
if (old_shortcut_ids == get_shortcut_ids()) {
|
||||||
return promise.set_value(Unit());
|
return promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
save_quick_reply_shortcuts();
|
||||||
send_update_quick_reply_shortcuts();
|
send_update_quick_reply_shortcuts();
|
||||||
|
|
||||||
auto new_server_shortcut_ids = get_server_shortcut_ids();
|
auto new_server_shortcut_ids = get_server_shortcut_ids();
|
||||||
@ -894,6 +897,15 @@ bool QuickReplyManager::update_shortcut_from(Shortcut *new_shortcut, Shortcut *o
|
|||||||
return *is_object_changed || is_changed || old_shortcut->server_total_count_ != new_shortcut->server_total_count_;
|
return *is_object_changed || is_changed || old_shortcut->server_total_count_ != new_shortcut->server_total_count_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string QuickReplyManager::get_quick_reply_shortcuts_database_key() {
|
||||||
|
return "quick_reply_shortcuts";
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuickReplyManager::save_quick_reply_shortcuts() {
|
||||||
|
G()->td_db()->get_binlog_pmc()->set(get_quick_reply_shortcuts_database_key(),
|
||||||
|
log_event_store(shortcuts_).as_slice().str());
|
||||||
|
}
|
||||||
|
|
||||||
td_api::object_ptr<td_api::updateQuickReplyShortcut> QuickReplyManager::get_update_quick_reply_shortcut_object(
|
td_api::object_ptr<td_api::updateQuickReplyShortcut> QuickReplyManager::get_update_quick_reply_shortcut_object(
|
||||||
const Shortcut *s, const char *source) const {
|
const Shortcut *s, const char *source) const {
|
||||||
return td_api::make_object<td_api::updateQuickReplyShortcut>(get_quick_reply_shortcut_object(s, source));
|
return td_api::make_object<td_api::updateQuickReplyShortcut>(get_quick_reply_shortcut_object(s, source));
|
||||||
|
@ -206,6 +206,10 @@ class QuickReplyManager final : public Actor {
|
|||||||
|
|
||||||
void reorder_quick_reply_shortcuts_on_server(vector<QuickReplyShortcutId> shortcut_ids, Promise<Unit> &&promise);
|
void reorder_quick_reply_shortcuts_on_server(vector<QuickReplyShortcutId> shortcut_ids, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
string get_quick_reply_shortcuts_database_key();
|
||||||
|
|
||||||
|
void save_quick_reply_shortcuts();
|
||||||
|
|
||||||
Shortcuts shortcuts_;
|
Shortcuts shortcuts_;
|
||||||
|
|
||||||
FlatHashSet<QuickReplyShortcutId, QuickReplyShortcutIdHash> deleted_shortcut_ids_;
|
FlatHashSet<QuickReplyShortcutId, QuickReplyShortcutIdHash> deleted_shortcut_ids_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user