Fixed some small stuff

This commit is contained in:
WolverinDEV 2020-04-04 12:22:20 +02:00
parent 3d90e8b57a
commit 421f04fe60
3 changed files with 25 additions and 26 deletions

@ -1 +1 @@
Subproject commit 15e54314da1903c0a70845180898e41b75749dbd Subproject commit d4ffb41adc2fe5145be4ab343039e72f66058d33

View File

@ -767,7 +767,9 @@ command_result ConnectedClient::handleCommandBanClient(Command &cmd) {
CMD_RESET_IDLE; CMD_RESET_IDLE;
CMD_CHK_AND_INC_FLOOD_POINTS(25); CMD_CHK_AND_INC_FLOOD_POINTS(25);
string uid; std::string target_unique_id{};
ClientDbId target_database_id{0};
string reason = cmd[0].has("banreason") ? cmd["banreason"].string() : ""; string reason = cmd[0].has("banreason") ? cmd["banreason"].string() : "";
auto time = cmd[0].has("time") ? cmd["time"].as<uint64_t>() : 0UL; auto time = cmd[0].has("time") ? cmd["time"].as<uint64_t>() : 0UL;
chrono::time_point<chrono::system_clock> until = time > 0 ? chrono::system_clock::now() + chrono::seconds(time) : chrono::time_point<chrono::system_clock>(); chrono::time_point<chrono::system_clock> until = time > 0 ? chrono::system_clock::now() + chrono::seconds(time) : chrono::time_point<chrono::system_clock>();
@ -776,43 +778,40 @@ command_result ConnectedClient::handleCommandBanClient(Command &cmd) {
const auto no_hwid = cmd.hasParm("no-hardware-id"); const auto no_hwid = cmd.hasParm("no-hardware-id");
const auto no_ip = cmd.hasParm("no-ip"); const auto no_ip = cmd.hasParm("no-ip");
deque<shared_ptr<ConnectedClient>> target_clients; std::deque<std::shared_ptr<ConnectedClient>> target_clients;
if (cmd[0].has("uid")) { if (cmd[0].has("uid")) {
target_clients = this->server->findClientsByUid(uid = cmd["uid"].string()); target_clients = this->server->findClientsByUid(target_unique_id = cmd["uid"].string());
for(const auto& client : target_clients) } else if(cmd[0].has("cldbid")) {
if(client->getType() == ClientType::CLIENT_MUSIC) target_clients = this->server->findClientsByCldbId(target_database_id = cmd["cldbid"].as<ClientDbId>());
return command_result{error::client_invalid_id, "You cant ban a music bot!"};
} else { } else {
target_clients = {this->server->find_client_by_id(cmd["clid"].as<ClientId>())}; target_clients = {this->server->find_client_by_id(cmd["clid"].as<ClientId>())};
if(!target_clients[0]) { if(!target_clients[0]) {
return command_result{error::client_invalid_id, "Could not find target client"}; return command_result{error::client_invalid_id, "Could not find target client"};
} }
if(target_clients[0]->getType() == ClientType::CLIENT_MUSIC) { }
for(const auto& client : target_clients)
if(client->getType() == ClientType::CLIENT_MUSIC)
return command_result{error::client_invalid_id, "You cant ban a music bot!"}; return command_result{error::client_invalid_id, "You cant ban a music bot!"};
}
uid = target_clients[0]->getUid();
}
ClientDbId target_dbid = 0; if(!target_clients.empty()) {
if (!target_clients.empty()) { if(target_unique_id.empty())
target_dbid = target_clients[0]->getClientDatabaseId(); target_unique_id = target_clients.back()->getUid();
} else {
auto info = serverInstance->databaseHelper()->queryDatabaseInfoByUid(this->getServer(), {uid});
if (!info.empty())
target_dbid = info[0]->cldbid;
else
return command_result{error::client_unknown};
}
if(!permission::v2::permission_granted(this->server->calculate_permission(permission::i_client_needed_ban_power, target_dbid, ClientType::CLIENT_TEAMSPEAK, 0), this->calculate_permission(permission::i_client_ban_power, 0))) if(!target_database_id)
target_database_id = target_clients.back()->getClientDatabaseId();
}
if(!permission::v2::permission_granted(this->server->calculate_permission(permission::i_client_needed_ban_power, target_database_id, ClientType::CLIENT_TEAMSPEAK, 0), this->calculate_permission(permission::i_client_ban_power, 0)))
return command_result{permission::i_client_ban_power}; return command_result{permission::i_client_ban_power};
if (permission::v2::permission_granted(1, this->server->calculate_permission(permission::b_client_ignore_bans, target_dbid, ClientType::CLIENT_TEAMSPEAK, 0))) if (permission::v2::permission_granted(1, this->server->calculate_permission(permission::b_client_ignore_bans, target_database_id, ClientType::CLIENT_TEAMSPEAK, 0)))
return command_result{permission::b_client_ignore_bans}; return command_result{permission::b_client_ignore_bans};
deque<BanId> ban_ids; deque<BanId> ban_ids;
auto _id = serverInstance->banManager()->registerBan(this->getServer()->getServerId(), this->getClientDatabaseId(), reason, uid, "", "", "", until); if(!target_unique_id.empty()) {
ban_ids.push_back(_id); auto _id = serverInstance->banManager()->registerBan(this->getServer()->getServerId(), this->getClientDatabaseId(), reason, target_unique_id, "", "", "", until);
ban_ids.push_back(_id);
}
auto b_ban_name = permission::v2::permission_granted(1, this->calculate_permission(permission::b_client_ban_name, 0), false); auto b_ban_name = permission::v2::permission_granted(1, this->calculate_permission(permission::b_client_ban_name, 0), false);
auto b_ban_ip = permission::v2::permission_granted(1, this->calculate_permission(permission::b_client_ban_ip, 0), false); auto b_ban_ip = permission::v2::permission_granted(1, this->calculate_permission(permission::b_client_ban_ip, 0), false);

2
shared

@ -1 +1 @@
Subproject commit 9063e17efb1b1d837e771da6c8262b477b39cbb3 Subproject commit f86c9b522a97ec6b524da3c7aa4bddffa54f7f38