Move device token check to DeviceTokenManager.

This commit is contained in:
levlam 2024-05-08 12:17:11 +03:00
parent dbd397cb0e
commit e065cce247
2 changed files with 3 additions and 4 deletions

View File

@ -133,7 +133,9 @@ StringBuilder &operator<<(StringBuilder &string_builder, const DeviceTokenManage
void DeviceTokenManager::register_device(tl_object_ptr<td_api::DeviceToken> device_token_ptr,
const vector<UserId> &other_user_ids,
Promise<td_api::object_ptr<td_api::pushReceiverId>> promise) {
CHECK(device_token_ptr != nullptr);
if (device_token_ptr == nullptr) {
return promise.set_error(Status::Error(400, "Device token must be non-empty"));
}
TokenType token_type;
string token;
bool is_app_sandbox = false;

View File

@ -4555,9 +4555,6 @@ void Td::on_request(uint64 id, td_api::processPushNotification &request) {
void Td::on_request(uint64 id, td_api::registerDevice &request) {
CHECK_IS_USER();
if (request.device_token_ == nullptr) {
return send_error_raw(id, 400, "Device token must be non-empty");
}
CREATE_REQUEST_PROMISE();
send_closure(device_token_manager_, &DeviceTokenManager::register_device, std::move(request.device_token_),
UserId::get_user_ids(request.other_user_ids_), std::move(promise));