From 14d2578a67466790f36dbe46dcb87956b9928a55 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Tue, 16 Jun 2020 12:57:20 +0200 Subject: [PATCH] Some minor fixes and added the `listfeaturesupport` command --- file/local_server/LocalFileTransferDisk.cpp | 2 +- server/src/VirtualServer.cpp | 30 +++++++------------- server/src/client/ConnectedClient.h | 4 +-- server/src/client/command_handler/misc.cpp | 27 +++++++++++++++++- server/src/client/command_handler/server.cpp | 6 ++++ shared | 2 +- 6 files changed, 47 insertions(+), 24 deletions(-) diff --git a/file/local_server/LocalFileTransferDisk.cpp b/file/local_server/LocalFileTransferDisk.cpp index f8539da..037ec3a 100644 --- a/file/local_server/LocalFileTransferDisk.cpp +++ b/file/local_server/LocalFileTransferDisk.cpp @@ -7,8 +7,8 @@ #include #include #include "./LocalFileProvider.h" -#include "./duration_utils.h" #include "LocalFileProvider.h" +#include "duration_utils.h" using namespace ts::server::file; using namespace ts::server::file::transfer; diff --git a/server/src/VirtualServer.cpp b/server/src/VirtualServer.cpp index d05edd9..8dd168f 100644 --- a/server/src/VirtualServer.cpp +++ b/server/src/VirtualServer.cpp @@ -831,8 +831,6 @@ vectorgetGroupAssignments(this, client_dbid, client_type); - server_group_data.resize(groups.size()); + auto assigned_groups = cache->getGroupAssignments(this, client_dbid, client_type); + server_group_data.resize(assigned_groups.size()); auto it = server_group_data.begin(); - for(auto& group : groups) { + for(auto& group : assigned_groups) { auto group_permissions = group->group->permissions(); auto permission_flags = group_permissions->permission_flags(permission_type); @@ -929,13 +927,6 @@ vectorclient_permissions->permission_flags(permission); /* lets try to resolve the channel specific permission */ @@ -949,27 +940,28 @@ vector(*active_server_group); + skip_channel_permissions = std::get<1>(*active_server_group); } } - if(!have_skip) { + if(!skip_channel_permissions) { /* lookup the channel group */ { auto channel_assignment = cache->getChannelAssignment(this, client_dbid, channel_id); diff --git a/server/src/client/ConnectedClient.h b/server/src/client/ConnectedClient.h index f97d35d..fb1def3 100644 --- a/server/src/client/ConnectedClient.h +++ b/server/src/client/ConnectedClient.h @@ -463,8 +463,6 @@ namespace ts { command_result handleCommandFTRenameFile(Command&); command_result handleCommandFTList(Command&); command_result handleCommandFTStop(Command&); - //CMD_TODO handleCommandFTStop -> 5 points - //CMD_TODO handleCommandFTList -> 5 points command_result handleCommandBanList(Command&); command_result handleCommandBanAdd(Command&); @@ -601,6 +599,8 @@ namespace ts { command_result handleCommandLogView(Command&); //CMD_TODO handleCommandLogAdd + command_result handleCommandListFeatureSupport(Command &cmd); + //handleCommandClientSiteReport() -> return findError(0x00) //handleCommandChannelCreatePrivate() -> return findError(0x02) //handleCommandCustome_Unknown_Command() -> return findError(0x100) diff --git a/server/src/client/command_handler/misc.cpp b/server/src/client/command_handler/misc.cpp index 9854766..7a80a2b 100644 --- a/server/src/client/command_handler/misc.cpp +++ b/server/src/client/command_handler/misc.cpp @@ -249,6 +249,8 @@ command_result ConnectedClient::handleCommand(Command &cmd) { else if (command == "conversationfetch") return this->handleCommandConversationFetch(cmd); else if (command == "conversationmessagedelete") return this->handleCommandConversationMessageDelete(cmd); + else if (command == "listfeaturesupport") return this->handleCommandListFeatureSupport(cmd); + if (this->getType() == ClientType::CLIENT_QUERY) return command_result{error::command_not_found}; //Dont log query invalid commands if (this->getType() == ClientType::CLIENT_TEAMSPEAK) if (command.empty() || command.find_first_not_of(' ') == -1) { @@ -2620,7 +2622,30 @@ command_result ConnectedClient::handleCommandConversationMessageDelete(ts::Comma return command_result{error::ok}; } - +enum struct FeatureSupportMode { + NONE, + FULL, + EXPERIMENTAL, + DEPRECATED +}; + +#define REGISTER_FEATURE(name, support, version) \ + notify.put_unchecked(index, "name", name); \ + notify.put_unchecked(index, "support", (int) support); \ + notify.put_unchecked(index, "version", version); \ + index++ + +command_result ConnectedClient::handleCommandListFeatureSupport(ts::Command &cmd) { + + ts::command_builder notify{this->notify_response_command("notifyfeaturesupport")}; + int index{0}; + + REGISTER_FEATURE("error-bulks", FeatureSupportMode::FULL, 1); + REGISTER_FEATURE("advanced-channel-chat", FeatureSupportMode::FULL, 1); + + this->sendCommand(notify); + return command_result{error::ok}; +} diff --git a/server/src/client/command_handler/server.cpp b/server/src/client/command_handler/server.cpp index e26f19c..9b9c812 100644 --- a/server/src/client/command_handler/server.cpp +++ b/server/src/client/command_handler/server.cpp @@ -347,6 +347,7 @@ command_result ConnectedClient::handleCommandServerGroupCopy(Command &cmd) { return permission::b_serverinstance_modify_querygroup; break; + case GroupType::GROUP_TYPE_NORMAL: default: break; } @@ -451,6 +452,7 @@ command_result ConnectedClient::handleCommandServerGroupDel(Command &cmd) { auto group_manager = this->server ? this->server->getGroupManager() : serverInstance->getGroupManager().get(); auto serverGroup = group_manager->findGroup(cmd["sgid"].as()); if (!serverGroup || serverGroup->target() != GROUPTARGET_SERVER) return command_result{error::group_invalid_id}; + ACTION_REQUIRES_GROUP_PERMISSION(serverGroup, permission::i_server_group_needed_modify_power, permission::i_server_group_modify_power, true); if(this->server && this->server->properties()[property::VIRTUALSERVER_DEFAULT_SERVER_GROUP] == serverGroup->groupId()) return command_result{error::parameter_invalid, "Could not delete default server group!"}; @@ -784,12 +786,14 @@ command_result ConnectedClient::handleCommandServerGroupAddPerm(Command &cmd) { if (serverGroup->target() != GROUPTARGET_SERVER) return command_result{error::parameter_invalid}; ACTION_REQUIRES_GROUP_PERMISSION(serverGroup, permission::i_server_group_needed_modify_power, permission::i_server_group_modify_power, 1); + /* We don't need this. The modify permissions only apply when creating/editing/renaming the groups itself auto type = serverGroup->type(); if(type == GroupType::GROUP_TYPE_QUERY) { ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_serverinstance_modify_querygroup, 1); } else if(type == GroupType::GROUP_TYPE_TEMPLATE) { ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_serverinstance_modify_templates, 1); } + */ command::bulk_parser::PermissionBulksParser pparser{cmd}; if(!pparser.validate(this->ref(), 0)) @@ -839,12 +843,14 @@ command_result ConnectedClient::handleCommandServerGroupDelPerm(Command &cmd) { if (serverGroup->target() != GROUPTARGET_SERVER) return command_result{error::parameter_invalid}; ACTION_REQUIRES_GROUP_PERMISSION(serverGroup, permission::i_server_group_needed_modify_power, permission::i_server_group_modify_power, 1); + /* We don't need this. The modify permissions only apply when creating/editing/renaming the groups itself auto type = serverGroup->type(); if(type == GroupType::GROUP_TYPE_QUERY) { ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_serverinstance_modify_querygroup, 1); } else if(type == GroupType::GROUP_TYPE_TEMPLATE) { ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_serverinstance_modify_templates, 1); } + */ command::bulk_parser::PermissionBulksParser pparser{cmd}; if(!pparser.validate(this->ref(), 0)) diff --git a/shared b/shared index 32dc942..f11bee7 160000 --- a/shared +++ b/shared @@ -1 +1 @@ -Subproject commit 32dc9423c21e087aeb5f8990e2e1c56c809cbffe +Subproject commit f11bee75c19b437513154a9dc1c9167c72e94427