Move all chatFilter checks to DialogFilter::create_dialog_filter.
This commit is contained in:
parent
19ac20adc9
commit
03819d0322
@ -93,7 +93,12 @@ unique_ptr<DialogFilter> DialogFilter::get_dialog_filter(
|
||||
|
||||
Result<unique_ptr<DialogFilter>> DialogFilter::create_dialog_filter(Td *td, DialogFilterId dialog_filter_id,
|
||||
td_api::object_ptr<td_api::chatFilter> filter) {
|
||||
CHECK(filter != nullptr);
|
||||
if (filter == nullptr) {
|
||||
return Status::Error(400, "Chat filter must be non-empty");
|
||||
}
|
||||
if (!clean_input_string(filter->title_) || !clean_input_string(filter->icon_name_)) {
|
||||
return Status::Error(400, "Strings must be encoded in UTF-8");
|
||||
}
|
||||
|
||||
auto dialog_filter = make_unique<DialogFilter>();
|
||||
dialog_filter->dialog_filter_id_ = dialog_filter_id;
|
||||
|
@ -6127,22 +6127,12 @@ void Td::on_request(uint64 id, const td_api::getRecommendedChatFilters &request)
|
||||
|
||||
void Td::on_request(uint64 id, td_api::createChatFilter &request) {
|
||||
CHECK_IS_USER();
|
||||
if (request.filter_ == nullptr) {
|
||||
return send_error_raw(id, 400, "Chat filter must be non-empty");
|
||||
}
|
||||
CLEAN_INPUT_STRING(request.filter_->title_);
|
||||
CLEAN_INPUT_STRING(request.filter_->icon_name_);
|
||||
CREATE_REQUEST_PROMISE();
|
||||
dialog_filter_manager_->create_dialog_filter(std::move(request.filter_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::editChatFilter &request) {
|
||||
CHECK_IS_USER();
|
||||
if (request.filter_ == nullptr) {
|
||||
return send_error_raw(id, 400, "Chat filter must be non-empty");
|
||||
}
|
||||
CLEAN_INPUT_STRING(request.filter_->title_);
|
||||
CLEAN_INPUT_STRING(request.filter_->icon_name_);
|
||||
CREATE_REQUEST_PROMISE();
|
||||
dialog_filter_manager_->edit_dialog_filter(DialogFilterId(request.chat_filter_id_), std::move(request.filter_),
|
||||
std::move(promise));
|
||||
|
Loading…
Reference in New Issue
Block a user