Some minor fixes and added the listfeaturesupport
command
This commit is contained in:
parent
f03af7a9bf
commit
14d2578a67
@ -7,8 +7,8 @@
|
|||||||
#include <experimental/filesystem>
|
#include <experimental/filesystem>
|
||||||
#include <log/LogUtils.h>
|
#include <log/LogUtils.h>
|
||||||
#include "./LocalFileProvider.h"
|
#include "./LocalFileProvider.h"
|
||||||
#include "./duration_utils.h"
|
|
||||||
#include "LocalFileProvider.h"
|
#include "LocalFileProvider.h"
|
||||||
|
#include "duration_utils.h"
|
||||||
|
|
||||||
using namespace ts::server::file;
|
using namespace ts::server::file;
|
||||||
using namespace ts::server::file::transfer;
|
using namespace ts::server::file::transfer;
|
||||||
|
@ -831,8 +831,6 @@ vector<pair<ts::permission::PermissionType, ts::permission::v2::PermissionFlagge
|
|||||||
bool have_skip_permission = false;
|
bool have_skip_permission = false;
|
||||||
int skip_permission_type = -1; /* -1 := unset | 0 := skip, not explicit | 1 := skip, explicit */
|
int skip_permission_type = -1; /* -1 := unset | 0 := skip, not explicit | 1 := skip, explicit */
|
||||||
|
|
||||||
bool have_skip;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* server_group_data[0] := Server group id
|
* server_group_data[0] := Server group id
|
||||||
* server_group_data[1] := Skip flag
|
* server_group_data[1] := Skip flag
|
||||||
@ -876,10 +874,10 @@ vector<pair<ts::permission::PermissionType, ts::permission::v2::PermissionFlagge
|
|||||||
server_group_data_initialized = true;
|
server_group_data_initialized = true;
|
||||||
active_server_group = nullptr;
|
active_server_group = nullptr;
|
||||||
|
|
||||||
auto groups = cache->getGroupAssignments(this, client_dbid, client_type);
|
auto assigned_groups = cache->getGroupAssignments(this, client_dbid, client_type);
|
||||||
server_group_data.resize(groups.size());
|
server_group_data.resize(assigned_groups.size());
|
||||||
auto it = server_group_data.begin();
|
auto it = server_group_data.begin();
|
||||||
for(auto& group : groups) {
|
for(auto& group : assigned_groups) {
|
||||||
auto group_permissions = group->group->permissions();
|
auto group_permissions = group->group->permissions();
|
||||||
auto permission_flags = group_permissions->permission_flags(permission_type);
|
auto permission_flags = group_permissions->permission_flags(permission_type);
|
||||||
|
|
||||||
@ -929,13 +927,6 @@ vector<pair<ts::permission::PermissionType, ts::permission::v2::PermissionFlagge
|
|||||||
};
|
};
|
||||||
|
|
||||||
for(const auto& permission : permissions) {
|
for(const auto& permission : permissions) {
|
||||||
if(permission == permission::b_client_skip_channelgroup_permissions) {
|
|
||||||
if(skip_permission_type == -1) /* initialize skip flag */
|
|
||||||
calculate_skip();
|
|
||||||
result.push_back({permission, {have_skip_permission, skip_permission_type == 1}});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
server_group_data_initialized = false; /* reset all group data */
|
server_group_data_initialized = false; /* reset all group data */
|
||||||
auto client_permission_flags = cache->client_permissions->permission_flags(permission);
|
auto client_permission_flags = cache->client_permissions->permission_flags(permission);
|
||||||
/* lets try to resolve the channel specific permission */
|
/* lets try to resolve the channel specific permission */
|
||||||
@ -949,27 +940,28 @@ vector<pair<ts::permission::PermissionType, ts::permission::v2::PermissionFlagge
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
have_skip = channel_id == 0;
|
bool skip_channel_permissions = channel_id == 0;
|
||||||
if(!have_skip) {
|
if(!skip_channel_permissions) {
|
||||||
/* look if somewhere is the skip permission flag set */
|
/* look if somewhere is the skip permission flag set */
|
||||||
if(skip_permission_type == -1) /* initialize skip flag */
|
if(skip_permission_type == -1) /* initialize skip flag */
|
||||||
calculate_skip();
|
calculate_skip();
|
||||||
have_skip = have_skip_permission;
|
skip_channel_permissions = have_skip_permission;
|
||||||
}
|
}
|
||||||
if(!have_skip) {
|
if(!skip_channel_permissions) {
|
||||||
/* okey we've no global skip. Then now lookup the groups and the client permissions */
|
/* okey we've no global skip. Then now lookup the groups and the client permissions */
|
||||||
if(calculate_granted ? client_permission_flags.grant_set : client_permission_flags.value_set) {
|
if(calculate_granted ? client_permission_flags.grant_set : client_permission_flags.value_set) {
|
||||||
/* okey the client has the permission, this counts */
|
/* okey the client has the permission, this counts */
|
||||||
have_skip = client_permission_flags.skip;
|
skip_channel_permissions = client_permission_flags.skip;
|
||||||
} else {
|
} else {
|
||||||
if(!server_group_data_initialized)
|
if(!server_group_data_initialized)
|
||||||
initialize_group_data(permission);
|
initialize_group_data(permission);
|
||||||
|
|
||||||
if(active_server_group)
|
if(active_server_group)
|
||||||
have_skip = std::get<1>(*active_server_group);
|
skip_channel_permissions = std::get<1>(*active_server_group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!have_skip) {
|
if(!skip_channel_permissions) {
|
||||||
/* lookup the channel group */
|
/* lookup the channel group */
|
||||||
{
|
{
|
||||||
auto channel_assignment = cache->getChannelAssignment(this, client_dbid, channel_id);
|
auto channel_assignment = cache->getChannelAssignment(this, client_dbid, channel_id);
|
||||||
|
@ -463,8 +463,6 @@ namespace ts {
|
|||||||
command_result handleCommandFTRenameFile(Command&);
|
command_result handleCommandFTRenameFile(Command&);
|
||||||
command_result handleCommandFTList(Command&);
|
command_result handleCommandFTList(Command&);
|
||||||
command_result handleCommandFTStop(Command&);
|
command_result handleCommandFTStop(Command&);
|
||||||
//CMD_TODO handleCommandFTStop -> 5 points
|
|
||||||
//CMD_TODO handleCommandFTList -> 5 points
|
|
||||||
|
|
||||||
command_result handleCommandBanList(Command&);
|
command_result handleCommandBanList(Command&);
|
||||||
command_result handleCommandBanAdd(Command&);
|
command_result handleCommandBanAdd(Command&);
|
||||||
@ -601,6 +599,8 @@ namespace ts {
|
|||||||
command_result handleCommandLogView(Command&);
|
command_result handleCommandLogView(Command&);
|
||||||
//CMD_TODO handleCommandLogAdd
|
//CMD_TODO handleCommandLogAdd
|
||||||
|
|
||||||
|
command_result handleCommandListFeatureSupport(Command &cmd);
|
||||||
|
|
||||||
//handleCommandClientSiteReport() -> return findError(0x00)
|
//handleCommandClientSiteReport() -> return findError(0x00)
|
||||||
//handleCommandChannelCreatePrivate() -> return findError(0x02)
|
//handleCommandChannelCreatePrivate() -> return findError(0x02)
|
||||||
//handleCommandCustome_Unknown_Command() -> return findError(0x100)
|
//handleCommandCustome_Unknown_Command() -> return findError(0x100)
|
||||||
|
@ -249,6 +249,8 @@ command_result ConnectedClient::handleCommand(Command &cmd) {
|
|||||||
else if (command == "conversationfetch") return this->handleCommandConversationFetch(cmd);
|
else if (command == "conversationfetch") return this->handleCommandConversationFetch(cmd);
|
||||||
else if (command == "conversationmessagedelete") return this->handleCommandConversationMessageDelete(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_QUERY) return command_result{error::command_not_found}; //Dont log query invalid commands
|
||||||
if (this->getType() == ClientType::CLIENT_TEAMSPEAK)
|
if (this->getType() == ClientType::CLIENT_TEAMSPEAK)
|
||||||
if (command.empty() || command.find_first_not_of(' ') == -1) {
|
if (command.empty() || command.find_first_not_of(' ') == -1) {
|
||||||
@ -2620,7 +2622,30 @@ command_result ConnectedClient::handleCommandConversationMessageDelete(ts::Comma
|
|||||||
return command_result{error::ok};
|
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};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -347,6 +347,7 @@ command_result ConnectedClient::handleCommandServerGroupCopy(Command &cmd) {
|
|||||||
return permission::b_serverinstance_modify_querygroup;
|
return permission::b_serverinstance_modify_querygroup;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GroupType::GROUP_TYPE_NORMAL:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -451,6 +452,7 @@ command_result ConnectedClient::handleCommandServerGroupDel(Command &cmd) {
|
|||||||
auto group_manager = this->server ? this->server->getGroupManager() : serverInstance->getGroupManager().get();
|
auto group_manager = this->server ? this->server->getGroupManager() : serverInstance->getGroupManager().get();
|
||||||
auto serverGroup = group_manager->findGroup(cmd["sgid"].as<GroupId>());
|
auto serverGroup = group_manager->findGroup(cmd["sgid"].as<GroupId>());
|
||||||
if (!serverGroup || serverGroup->target() != GROUPTARGET_SERVER) return command_result{error::group_invalid_id};
|
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())
|
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!"};
|
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};
|
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);
|
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();
|
auto type = serverGroup->type();
|
||||||
if(type == GroupType::GROUP_TYPE_QUERY) {
|
if(type == GroupType::GROUP_TYPE_QUERY) {
|
||||||
ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_serverinstance_modify_querygroup, 1);
|
ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_serverinstance_modify_querygroup, 1);
|
||||||
} else if(type == GroupType::GROUP_TYPE_TEMPLATE) {
|
} else if(type == GroupType::GROUP_TYPE_TEMPLATE) {
|
||||||
ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_serverinstance_modify_templates, 1);
|
ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_serverinstance_modify_templates, 1);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
command::bulk_parser::PermissionBulksParser<true> pparser{cmd};
|
command::bulk_parser::PermissionBulksParser<true> pparser{cmd};
|
||||||
if(!pparser.validate(this->ref(), 0))
|
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};
|
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);
|
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();
|
auto type = serverGroup->type();
|
||||||
if(type == GroupType::GROUP_TYPE_QUERY) {
|
if(type == GroupType::GROUP_TYPE_QUERY) {
|
||||||
ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_serverinstance_modify_querygroup, 1);
|
ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_serverinstance_modify_querygroup, 1);
|
||||||
} else if(type == GroupType::GROUP_TYPE_TEMPLATE) {
|
} else if(type == GroupType::GROUP_TYPE_TEMPLATE) {
|
||||||
ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_serverinstance_modify_templates, 1);
|
ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_serverinstance_modify_templates, 1);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
command::bulk_parser::PermissionBulksParser<false> pparser{cmd};
|
command::bulk_parser::PermissionBulksParser<false> pparser{cmd};
|
||||||
if(!pparser.validate(this->ref(), 0))
|
if(!pparser.validate(this->ref(), 0))
|
||||||
|
2
shared
2
shared
@ -1 +1 @@
|
|||||||
Subproject commit 32dc9423c21e087aeb5f8990e2e1c56c809cbffe
|
Subproject commit f11bee75c19b437513154a9dc1c9167c72e94427
|
Loading…
Reference in New Issue
Block a user