From e3bf46a89b38f59713d12fc958ad0831adfa86b9 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Wed, 13 May 2020 11:51:01 +0200 Subject: [PATCH] Channel move improvements --- git-teaspeak | 2 +- server/src/VirtualServer.cpp | 2 +- server/src/client/command_handler/client.cpp | 13 ++++++++++--- shared | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/git-teaspeak b/git-teaspeak index ee50902..a8a0aab 160000 --- a/git-teaspeak +++ b/git-teaspeak @@ -1 +1 @@ -Subproject commit ee5090232867df795348b84f1c6d96561ea24d90 +Subproject commit a8a0aabd7fca05b950de9f781a3cd6ba5b799f79 diff --git a/server/src/VirtualServer.cpp b/server/src/VirtualServer.cpp index 2c37f74..0720f19 100644 --- a/server/src/VirtualServer.cpp +++ b/server/src/VirtualServer.cpp @@ -122,7 +122,6 @@ bool VirtualServer::initialize(bool test_properties) { channelTree = new ServerChannelTree(self.lock(), this->sql); channelTree->loadChannelsFromDatabase(); - channelTree->deleteSemiPermanentChannels(); this->groups = new GroupManager(self.lock(), this->sql, serverInstance->getGroupManager()); if(!this->groups->loadGroupFormDatabase()){ //TODO exception etc @@ -130,6 +129,7 @@ bool VirtualServer::initialize(bool test_properties) { return false; } + channelTree->deleteSemiPermanentChannels(); if(channelTree->channel_count() == 0){ logMessage(this->serverId, "Creating new channel tree (Copy from server 0)"); LOG_SQL_CMD(sql::command(this->getSql(), "INSERT INTO `channels` (`serverId`, `channelId`, `type`, `parentId`) SELECT :serverId AS `serverId`, `channelId`, `type`, `parentId` FROM `channels` WHERE `serverId` = 0", variable{":serverId", this->serverId}).execute()); diff --git a/server/src/client/command_handler/client.cpp b/server/src/client/command_handler/client.cpp index 1881c28..0d2ba13 100644 --- a/server/src/client/command_handler/client.cpp +++ b/server/src/client/command_handler/client.cpp @@ -102,8 +102,6 @@ command_result ConnectedClient::handleCommandClientKick(Command &cmd) { clients.emplace_back(std::move(client)); result.emplace_result(error::ok); } - if (clients.empty()) - return command_result{error::database_empty_result}; for(auto& client : clients) { if (target_channel) { @@ -170,6 +168,7 @@ command_result ConnectedClient::handleCommandClientMove(Command &cmd) { auto permission_cache = make_shared(); if(!cmd[0].has("cpw")) cmd["cpw"] = ""; + if (!channel->passwordMatch(cmd["cpw"], true)) if (!permission::v2::permission_granted(1, this->calculate_permission(permission::b_channel_join_ignore_password, channel->channelId()))) return command_result{error::channel_invalid_password}; @@ -196,9 +195,17 @@ command_result ConnectedClient::handleCommandClientMove(Command &cmd) { continue; } } + if(target_client->getChannel() == channel) { + result.emplace_result(error::ok); + continue; + } if(target_client.client != this) { - if(!permission::v2::permission_granted(target_client->calculate_permission(permission::i_client_needed_move_power, 0), this->calculate_permission(permission::i_client_move_power, 0))) { + if(!permission::v2::permission_granted(target_client->calculate_permission(permission::i_client_needed_move_power, target_client->getChannelId()), this->calculate_permission(permission::i_client_move_power, target_client->getChannelId()))) { + result.emplace_result(permission::i_client_move_power); + continue; + } + if(!permission::v2::permission_granted(target_client->calculate_permission(permission::i_client_needed_move_power, channel->channelId()), this->calculate_permission(permission::i_client_move_power, channel->channelId()))) { result.emplace_result(permission::i_client_move_power); continue; } diff --git a/shared b/shared index b60608f..a4febf7 160000 --- a/shared +++ b/shared @@ -1 +1 @@ -Subproject commit b60608ff94b06145bc808426392871ebd95fe9d3 +Subproject commit a4febf7b5af191d41c566292958c55155128f16f