Add QuickReplyManager::check_new_shortcut_name function.
This commit is contained in:
parent
dad721ad47
commit
a7dca7a744
@ -22,6 +22,7 @@
|
||||
#include "td/telegram/MessageReplyHeader.h"
|
||||
#include "td/telegram/MessageSelfDestructType.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/ReplyMarkup.h"
|
||||
#include "td/telegram/ReplyMarkup.hpp"
|
||||
#include "td/telegram/ServerMessageId.h"
|
||||
@ -1498,6 +1499,27 @@ vector<unique_ptr<QuickReplyManager::QuickReplyMessage>>::iterator QuickReplyMan
|
||||
return s->messages_.end();
|
||||
}
|
||||
|
||||
Status QuickReplyManager::check_new_shortcut_name(const string &name, int32 new_message_count) {
|
||||
TRY_STATUS(check_shortcut_name(name));
|
||||
|
||||
load_quick_reply_shortcuts();
|
||||
const auto *s = get_shortcut(name);
|
||||
auto max_message_count = td_->option_manager_->get_option_integer("quick_reply_shortcut_message_count_max");
|
||||
if (s != nullptr) {
|
||||
max_message_count -= s->server_total_count_ + s->local_total_count_;
|
||||
} else {
|
||||
auto max_shortcut_count = td_->option_manager_->get_option_integer("quick_reply_shortcut_count_max");
|
||||
if (static_cast<int64>(shortcuts_.shortcuts_.size()) == max_shortcut_count) {
|
||||
return Status::Error(400, "Quick reply shortcut count exceeded");
|
||||
}
|
||||
}
|
||||
if (new_message_count > max_message_count) {
|
||||
return Status::Error(400, "Quick reply message count exceeded");
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
vector<QuickReplyShortcutId> QuickReplyManager::get_shortcut_ids() const {
|
||||
return transform(shortcuts_.shortcuts_, [](const unique_ptr<Shortcut> &shortcut) { return shortcut->shortcut_id_; });
|
||||
}
|
||||
|
@ -230,6 +230,8 @@ class QuickReplyManager final : public Actor {
|
||||
|
||||
vector<unique_ptr<QuickReplyMessage>>::iterator get_message_it(Shortcut *s, MessageId message_id);
|
||||
|
||||
Status check_new_shortcut_name(const string &name, int32 new_message_count);
|
||||
|
||||
bool is_shortcut_list_changed(const vector<unique_ptr<Shortcut>> &new_shortcuts) const;
|
||||
|
||||
vector<QuickReplyShortcutId> get_shortcut_ids() const;
|
||||
|
Loading…
Reference in New Issue
Block a user