Add QuickReplyShortcutId::is_server().
This commit is contained in:
parent
817a64ce0e
commit
5ef3562533
@ -564,7 +564,7 @@ void QuickReplyManager::on_reload_quick_reply_shortcuts(
|
||||
vector<QuickReplyShortcutId> deleted_shortcut_ids;
|
||||
for (auto &quick_reply : shortcuts->quick_replies_) {
|
||||
auto shortcut_id = QuickReplyShortcutId(quick_reply->shortcut_id_);
|
||||
if (!shortcut_id.is_valid() || quick_reply->shortcut_.empty() || quick_reply->count_ <= 0 ||
|
||||
if (!shortcut_id.is_server() || quick_reply->shortcut_.empty() || quick_reply->count_ <= 0 ||
|
||||
quick_reply->top_message_ <= 0) {
|
||||
LOG(ERROR) << "Receive " << to_string(quick_reply);
|
||||
continue;
|
||||
@ -691,8 +691,19 @@ void QuickReplyManager::delete_quick_reply_shortcut(const string &name, Promise<
|
||||
auto shortcut_id = s->shortcut_id_;
|
||||
td::remove_if(shortcuts_.shortcuts_,
|
||||
[shortcut_id](const unique_ptr<Shortcut> &shortcut) { return shortcut->shortcut_id_ == shortcut_id; });
|
||||
deleted_shortcut_ids_.insert(shortcut_id);
|
||||
|
||||
if (!shortcut_id.is_server()) {
|
||||
return promise.set_value(Unit());
|
||||
}
|
||||
|
||||
delete_quick_reply_shortcut_from_server(shortcut_id, std::move(promise));
|
||||
}
|
||||
|
||||
void QuickReplyManager::delete_quick_reply_shortcut_from_server(QuickReplyShortcutId shortcut_id,
|
||||
Promise<Unit> &&promise) {
|
||||
CHECK(shortcut_id.is_server());
|
||||
|
||||
deleted_shortcut_ids_.insert(shortcut_id);
|
||||
td_->create_handler<DeleteQuickReplyShortcutQuery>(std::move(promise))->send(shortcut_id);
|
||||
}
|
||||
|
||||
|
@ -197,6 +197,8 @@ class QuickReplyManager final : public Actor {
|
||||
|
||||
void send_update_quick_reply_shortcuts();
|
||||
|
||||
void delete_quick_reply_shortcut_from_server(QuickReplyShortcutId shortcut_id, Promise<Unit> &&promise);
|
||||
|
||||
Shortcuts shortcuts_;
|
||||
|
||||
FlatHashSet<QuickReplyShortcutId, QuickReplyShortcutIdHash> deleted_shortcut_ids_;
|
||||
|
@ -18,6 +18,8 @@ class QuickReplyShortcutId {
|
||||
int32 id = 0;
|
||||
|
||||
public:
|
||||
static constexpr int32 MAX_SERVER_SHORTCUT_ID = 1999999999;
|
||||
|
||||
QuickReplyShortcutId() = default;
|
||||
|
||||
explicit constexpr QuickReplyShortcutId(int32 quick_reply_shortcut_id) : id(quick_reply_shortcut_id) {
|
||||
@ -41,6 +43,10 @@ class QuickReplyShortcutId {
|
||||
return id > 0;
|
||||
}
|
||||
|
||||
bool is_server() const {
|
||||
return id > 0 && id <= MAX_SERVER_SHORTCUT_ID;
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
storer.store_int(id);
|
||||
|
Loading…
Reference in New Issue
Block a user