Using new permissions system consequently
This commit is contained in:
@@ -96,7 +96,7 @@ if (!l_channel && (channel_id != 0 || force)) return command_result{error::chann
|
||||
/* the "newest" channel permission access test */
|
||||
#define CHANNEL_PERMISSION_TEST(permission_type, permission_needed_type, _channel, permission_required) \
|
||||
do { \
|
||||
auto permission_granted = this->calculate_permission_value(permission_type, _channel->channelId()); \
|
||||
auto permission_granted = this->calculate_permission(permission_type, _channel->channelId()); \
|
||||
if(!channel->permission_granted(permission_needed_type, permission_granted, permission_required)) \
|
||||
return command_result{permission_type}; \
|
||||
} while(0)
|
||||
@@ -104,7 +104,7 @@ do { \
|
||||
/* the "newest" group permission access test */
|
||||
#define GROUP_PERMISSION_TEST(permission_type, permission_needed_type, _group, permission_required) \
|
||||
do { \
|
||||
auto permission_granted = this->calculate_permission_value(permission_type, 0); \
|
||||
auto permission_granted = this->calculate_permission(permission_type, 0); \
|
||||
if(!_group->permission_granted(permission_needed_type, permission_granted, permission_required)) \
|
||||
return command_result{permission_type}; \
|
||||
} while(0)
|
||||
@@ -375,7 +375,7 @@ command_result ConnectedClient::handleCommand(Command &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) {
|
||||
if (!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_allow_invalid_packet, 1, this->currentChannel))
|
||||
if (!this->permissionGranted(permission::b_client_allow_invalid_packet, 1, this->currentChannel))
|
||||
((VoiceClient *) this)->disconnect(VREASON_SERVER_KICK, config::messages::kick_invalid_command, this->server ? this->server->serverAdmin : static_pointer_cast<ConnectedClient>(serverInstance->getInitialServerAdmin()), true);
|
||||
}
|
||||
|
||||
@@ -391,19 +391,19 @@ command_result ConnectedClient::handleCommandServerGetVariables(Command &cmd) {
|
||||
|
||||
#define SERVEREDIT_CHK_PROP(name, perm, type)\
|
||||
else if(key == name) { \
|
||||
if(!permissionGranted(permission::PERMTEST_HIGHEST, perm, 1, nullptr, true, cache, target_server, true)) return command_result{perm}; \
|
||||
if(!permissionGranted(perm, 1, nullptr, true, cache, target_server, true)) return command_result{perm}; \
|
||||
if(toApplay.count(key) == 0) toApplay[key] = cmd[key].as<std::string>(); \
|
||||
if(!cmd[0][key].castable<type>()) return command_result{error::parameter_invalid};
|
||||
|
||||
#define SERVEREDIT_CHK_PROP_CACHED(name, perm, type)\
|
||||
else if(key == name) { \
|
||||
if(!this->permission_granted(this->cached_permission_value(perm), 1)) return command_result{perm}; \
|
||||
if(!this->permission_granted(this->calculate_permission(perm, 0), 1)) return command_result{perm}; \
|
||||
if(toApplay.count(key) == 0) toApplay[key] = cmd[key].as<std::string>(); \
|
||||
if(!cmd[0][key].castable<type>()) return command_result{error::parameter_invalid};
|
||||
|
||||
#define SERVEREDIT_CHK_PROP2(name, perm, type_a, type_b)\
|
||||
else if(key == name) { \
|
||||
if(!permissionGranted(permission::PERMTEST_HIGHEST, perm, 1, nullptr, true, cache, target_server, true)) return command_result{perm}; \
|
||||
if(!permissionGranted(perm, 1, nullptr, true, cache, target_server, true)) return command_result{perm}; \
|
||||
if(toApplay.count(key) == 0) toApplay[key] = cmd[key].as<std::string>(); \
|
||||
if(!cmd[0][key].castable<type_a>() && !!cmd[0][key].castable<type_b>()) return command_result{error::parameter_invalid};
|
||||
|
||||
@@ -619,11 +619,11 @@ command_result ConnectedClient::handleCommandClientKick(Command &cmd) {
|
||||
auto type = cmd["reasonid"].as<ViewReasonId>();
|
||||
if (type == ViewReasonId::VREASON_CHANNEL_KICK) {
|
||||
auto channel = client->currentChannel;
|
||||
PERM_CHECK_CHANNELR(permission::i_client_kick_from_channel_power, client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_needed_kick_from_channel_power, channel), channel, true);
|
||||
PERM_CHECK_CHANNELR(permission::i_client_kick_from_channel_power, client->permissionValue(permission::i_client_needed_kick_from_channel_power, channel), channel, true);
|
||||
targetChannel = this->server->channelTree->getDefaultChannel();
|
||||
} else if (type == ViewReasonId::VREASON_SERVER_KICK) {
|
||||
auto channel = client->currentChannel;
|
||||
PERM_CHECK_CHANNELR(permission::i_client_kick_from_server_power, client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_needed_kick_from_server_power, channel), channel, true);
|
||||
PERM_CHECK_CHANNELR(permission::i_client_kick_from_server_power, client->permissionValue(permission::i_client_needed_kick_from_server_power, channel), channel, true);
|
||||
targetChannel = nullptr;
|
||||
} else return command_result{error::not_implemented};
|
||||
|
||||
@@ -643,7 +643,7 @@ command_result ConnectedClient::handleCommandChannelGetDescription(Command &cmd)
|
||||
auto channel = dynamic_pointer_cast<BasicChannel>(l_channel->entry);
|
||||
assert(channel);
|
||||
|
||||
if(!this->permission_granted(this->permissionValue(permission::b_channel_ignore_description_view_power, channel), 1, true)) {
|
||||
if(!this->permission_granted(this->calculate_permission(permission::b_channel_ignore_description_view_power, channel->channelId()), 1, true)) {
|
||||
CHANNEL_PERMISSION_TEST(permission::i_channel_description_view_power, permission::i_channel_needed_description_view_power, channel, false);
|
||||
}
|
||||
|
||||
@@ -663,7 +663,7 @@ command_result ConnectedClient::handleCommandGetConnectionInfo(Command &cmd) {
|
||||
if (info) {
|
||||
this->notifyConnectionInfo(client, info);
|
||||
} else if(send_temp) {
|
||||
this->notifyConnectionInfo(client, nullptr);
|
||||
return command_result{error::no_cached_connection_info};
|
||||
}
|
||||
|
||||
return command_result{error::ok};
|
||||
@@ -1034,7 +1034,7 @@ command_result ConnectedClient::handleCommandChannelGroupCopy(Command &cmd) {
|
||||
return command_result{result};
|
||||
}
|
||||
|
||||
if(!target_group->permission_granted(permission::i_channel_group_needed_modify_power, this->calculate_permission_value(permission::i_channel_group_modify_power, 0), true))
|
||||
if(!target_group->permission_granted(permission::i_channel_group_needed_modify_power, this->calculate_permission(permission::i_channel_group_modify_power, 0), true))
|
||||
return command_result{permission::i_channel_group_modify_power};
|
||||
|
||||
if(!group_manager->copyGroupPermissions(source_group, target_group))
|
||||
@@ -1230,7 +1230,7 @@ command_result ConnectedClient::handleCommandChannelGroupAddPerm(Command &cmd) {
|
||||
if (!channelGroup || channelGroup->target() != GROUPTARGET_CHANNEL) return command_result{error::parameter_invalid, "invalid channel group id"};
|
||||
GROUP_PERMISSION_TEST(permission::i_channel_group_modify_power, permission::i_channel_group_needed_modify_power, channelGroup, true);
|
||||
|
||||
auto maxValue = this->getPermissionGrantValue(permission::PERMTEST_ORDERED, permission::i_permission_modify_power, this->currentChannel);
|
||||
auto maxValue = this->getPermissionGrantValue(permission::i_permission_modify_power, this->currentChannel);
|
||||
bool ignoreGrant = this->permission_granted(this->cached_permission_value(permission::b_permission_modify_power_ignore), 1);
|
||||
bool updateList = false;
|
||||
bool conOnError = cmd[0].has("continueonerror");
|
||||
@@ -1243,7 +1243,7 @@ command_result ConnectedClient::handleCommandChannelGroupAddPerm(Command &cmd) {
|
||||
if(permission_require_granted_value(permType) && val > maxValue)
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, this->currentChannel))
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, this->currentChannel))
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
|
||||
if (grant) {
|
||||
@@ -1299,7 +1299,7 @@ command_result ConnectedClient::handleCommandChannelGroupDelPerm(Command &cmd) {
|
||||
for (int index = 0; index < cmd.bulkCount(); index++) {
|
||||
PARSE_PERMISSION(cmd)
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, this->currentChannel))
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, this->currentChannel))
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
if (grant) {
|
||||
permission_manager->set_permission(permType, permission::v2::empty_permission_values, permission::v2::PermissionUpdateType::do_nothing, permission::v2::PermissionUpdateType::delete_value);
|
||||
@@ -1362,7 +1362,7 @@ command_result ConnectedClient::handleCommandClientMove(Command &cmd) {
|
||||
if(!cmd[0].has("cpw"))
|
||||
cmd["cpw"] = "";
|
||||
if (!channel->passwordMatch(cmd["cpw"], true))
|
||||
if (!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_channel_join_ignore_password, 1, channel, true, permission_cache))
|
||||
if (!this->permissionGranted(permission::b_channel_join_ignore_password, 1, channel, true, permission_cache))
|
||||
return command_result{error::channel_invalid_password};
|
||||
|
||||
switch(channel->channelType()) {
|
||||
@@ -1377,7 +1377,7 @@ command_result ConnectedClient::handleCommandClientMove(Command &cmd) {
|
||||
break;
|
||||
}
|
||||
if (!channel->properties()[property::CHANNEL_FLAG_MAXCLIENTS_UNLIMITED].as<bool>() || !channel->properties()[property::CHANNEL_FLAG_MAXFAMILYCLIENTS_UNLIMITED].as<bool>()) {
|
||||
if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_channel_join_ignore_maxclients, 1, channel, true, permission_cache)) {
|
||||
if(!this->permissionGranted(permission::b_channel_join_ignore_maxclients, 1, channel, true, permission_cache)) {
|
||||
if(!channel->properties()[property::CHANNEL_FLAG_MAXCLIENTS_UNLIMITED].as<bool>()) {
|
||||
auto maxClients = channel->properties()[property::CHANNEL_MAXCLIENTS].as<int32_t>();
|
||||
if (maxClients >= 0 && maxClients <= this->server->getClientsByChannel(channel).size())
|
||||
@@ -1401,23 +1401,23 @@ command_result ConnectedClient::handleCommandClientMove(Command &cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_channel_ignore_join_power, 1, channel, true, permission_cache)) {
|
||||
if(!this->permissionGranted(permission::b_channel_ignore_join_power, 1, channel, true, permission_cache)) {
|
||||
CHANNEL_PERMISSION_TEST(permission::i_channel_join_power, permission::i_channel_needed_join_power, channel, false);
|
||||
}
|
||||
|
||||
if (target_client == this) {
|
||||
auto permission_cache_current = make_shared<CalculateCache>();
|
||||
auto val = this->permissionValue(permission::PERMTEST_ORDERED, permission::b_client_is_sticky, this->currentChannel, permission_cache_current);
|
||||
auto val = this->permissionValue(permission::b_client_is_sticky, this->currentChannel, permission_cache_current);
|
||||
if (val != permNotGranted && val > 0) {
|
||||
auto st = this->permissionValue(permission::PERMTEST_ORDERED, permission::b_client_ignore_sticky, this->currentChannel, permission_cache_current);
|
||||
auto st = this->permissionValue(permission::b_client_ignore_sticky, this->currentChannel, permission_cache_current);
|
||||
if (st != 1)
|
||||
return command_result{permission::b_client_is_sticky};
|
||||
}
|
||||
}
|
||||
|
||||
if (target_client != this) {
|
||||
PERM_CHECK_CHANNELR(permission::i_client_move_power, target_client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_needed_move_power, target_client->getChannel()), target_client->getChannel(), true);
|
||||
PERM_CHECK_CHANNEL_CR(permission::i_client_move_power, target_client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_needed_move_power, channel), channel, true, permission_cache);
|
||||
PERM_CHECK_CHANNELR(permission::i_client_move_power, target_client->permissionValue(permission::i_client_needed_move_power, target_client->getChannel()), target_client->getChannel(), true);
|
||||
PERM_CHECK_CHANNEL_CR(permission::i_client_move_power, target_client->permissionValue(permission::i_client_needed_move_power, channel), channel, true, permission_cache);
|
||||
}
|
||||
|
||||
server_channel_r_lock.unlock();
|
||||
@@ -1524,7 +1524,7 @@ command_result ConnectedClient::handleCommandChannelCreate(Command &cmd) {
|
||||
}
|
||||
|
||||
|
||||
auto max_channels = this->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_max_channels, nullptr, permission_cache);
|
||||
auto max_channels = this->permissionValue(permission::i_client_max_channels, nullptr, permission_cache);
|
||||
|
||||
if(max_channels >= 0) {
|
||||
if(max_channels <= created_perm + created_semi + created_tmp)
|
||||
@@ -1532,21 +1532,21 @@ command_result ConnectedClient::handleCommandChannelCreate(Command &cmd) {
|
||||
}
|
||||
|
||||
if (cmd[0]["channel_flag_permanent"].as<bool>()) {
|
||||
max_channels = this->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_max_permanent_channels, nullptr, permission_cache);
|
||||
max_channels = this->permissionValue(permission::i_client_max_permanent_channels, nullptr, permission_cache);
|
||||
if(max_channels >= 0) {
|
||||
if(max_channels <= created_perm)
|
||||
return command_result{permission::i_client_max_permanent_channels};
|
||||
}
|
||||
}
|
||||
else if (cmd[0]["channel_flag_semi_permanent"].as<bool>()) {
|
||||
max_channels = this->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_max_semi_channels, nullptr, permission_cache);
|
||||
max_channels = this->permissionValue(permission::i_client_max_semi_channels, nullptr, permission_cache);
|
||||
if(max_channels >= 0) {
|
||||
if(max_channels <= created_semi)
|
||||
return command_result{permission::i_client_max_semi_channels};
|
||||
}
|
||||
}
|
||||
else {
|
||||
max_channels = this->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_max_temporary_channels, nullptr, permission_cache);
|
||||
max_channels = this->permissionValue(permission::i_client_max_temporary_channels, nullptr, permission_cache);
|
||||
if(max_channels >= 0) {
|
||||
if(max_channels <= created_tmp)
|
||||
return command_result{permission::i_client_max_temporary_channels};
|
||||
@@ -1567,8 +1567,8 @@ command_result ConnectedClient::handleCommandChannelCreate(Command &cmd) {
|
||||
|
||||
{
|
||||
|
||||
auto min_channel_deep = this->permissionValue(permission::PERMTEST_ORDERED, permission::i_channel_min_depth, nullptr, permission_cache);
|
||||
auto max_channel_deep = this->permissionValue(permission::PERMTEST_ORDERED, permission::i_channel_max_depth, nullptr, permission_cache);
|
||||
auto min_channel_deep = this->permissionValue(permission::i_channel_min_depth, nullptr, permission_cache);
|
||||
auto max_channel_deep = this->permissionValue(permission::i_channel_max_depth, nullptr, permission_cache);
|
||||
|
||||
if(min_channel_deep >= 0 || max_channel_deep >= 0) {
|
||||
auto channel_deep = 0;
|
||||
@@ -1622,13 +1622,13 @@ command_result ConnectedClient::handleCommandChannelCreate(Command &cmd) {
|
||||
auto permission_manager = created_channel->permissions();
|
||||
permission_manager->set_permission(
|
||||
permission::i_channel_needed_modify_power,
|
||||
{this->permissionValue(permission::PERMTEST_ORDERED, permission::i_channel_modify_power, this->currentChannel, permission_cache), 0},
|
||||
{this->permissionValue(permission::i_channel_modify_power, this->currentChannel, permission_cache), 0},
|
||||
permission::v2::PermissionUpdateType::set_value,
|
||||
permission::v2::PermissionUpdateType::do_nothing
|
||||
);
|
||||
permission_manager->set_permission(
|
||||
permission::i_channel_needed_delete_power,
|
||||
{this->permissionValue(permission::PERMTEST_ORDERED, permission::i_channel_delete_power, this->currentChannel, permission_cache), 0},
|
||||
{this->permissionValue(permission::i_channel_delete_power, this->currentChannel, permission_cache), 0},
|
||||
permission::v2::PermissionUpdateType::set_value,
|
||||
permission::v2::PermissionUpdateType::do_nothing
|
||||
);
|
||||
@@ -1849,13 +1849,13 @@ command_result ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
CHANNEL_PERM_TEST(permission::b_channel_modify_topic, 1, true);
|
||||
} else if (key == "channel_description") {
|
||||
CHANNEL_PERM_TEST(permission::b_channel_modify_description, 1, true);
|
||||
if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_use_bbcode_any, 1, this->currentChannel)) {
|
||||
if(!this->permissionGranted(permission::b_client_use_bbcode_any, 1, this->currentChannel)) {
|
||||
auto bbcode_image = bbcode::sloppy::has_image(cmd[key]);
|
||||
auto bbcode_url = bbcode::sloppy::has_url(cmd[key]);
|
||||
debugMessage(this->getServerId(), "Channel description contains bb codes: Image: {} URL: {}", bbcode_image, bbcode_url);
|
||||
if(bbcode_image && !this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_use_bbcode_image, 1, this->currentChannel))
|
||||
if(bbcode_image && !this->permissionGranted(permission::b_client_use_bbcode_image, 1, this->currentChannel))
|
||||
return command_result{permission::b_client_use_bbcode_image};
|
||||
if(bbcode_url && !this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_use_bbcode_url, 1, this->currentChannel))
|
||||
if(bbcode_url && !this->permissionGranted(permission::b_client_use_bbcode_url, 1, this->currentChannel))
|
||||
return command_result{permission::b_client_use_bbcode_url};
|
||||
}
|
||||
} else if (key == "channel_codec") {
|
||||
@@ -2270,8 +2270,8 @@ command_result ConnectedClient::handleCommandChannelMove(Command &cmd) {
|
||||
|
||||
{
|
||||
|
||||
auto min_channel_deep = this->permissionValue(permission::PERMTEST_ORDERED, permission::i_channel_min_depth, nullptr, nullptr);
|
||||
auto max_channel_deep = this->permissionValue(permission::PERMTEST_ORDERED, permission::i_channel_max_depth, nullptr, nullptr);
|
||||
auto min_channel_deep = this->permissionValue(permission::i_channel_min_depth, nullptr, nullptr);
|
||||
auto max_channel_deep = this->permissionValue(permission::i_channel_max_depth, nullptr, nullptr);
|
||||
|
||||
if(min_channel_deep >= 0 || max_channel_deep >= 0) {
|
||||
auto channel_deep = 0;
|
||||
@@ -2355,7 +2355,7 @@ command_result ConnectedClient::handleCommandClientPoke(Command &cmd) {
|
||||
auto client = this->server->findClient(cmd["clid"].as<ClientId>());
|
||||
if (!client) return command_result{error::client_invalid_id};
|
||||
if (client->getType() == CLIENT_MUSIC) return command_result{error::client_invalid_type};
|
||||
CACHED_PERM_CHECK(permission::i_client_poke_power, client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_needed_poke_power, client->currentChannel), false);
|
||||
CACHED_PERM_CHECK(permission::i_client_poke_power, client->permissionValue(permission::i_client_needed_poke_power, client->currentChannel), false);
|
||||
|
||||
client->notifyClientPoke(_this.lock(), cmd["msg"]);
|
||||
return command_result{error::ok};
|
||||
@@ -2432,8 +2432,8 @@ command_result ConnectedClient::handleCommandChannelAddPerm(Command &cmd) {
|
||||
|
||||
CHANNEL_PERMISSION_TEST(permission::i_channel_permission_modify_power, permission::i_channel_needed_permission_modify_power, channel, true);
|
||||
|
||||
auto maxValue = this->getPermissionGrantValue(permission::PERMTEST_ORDERED, permission::i_permission_modify_power, channel);
|
||||
bool ignoreGrant = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_permission_modify_power_ignore, 1, channel);
|
||||
auto maxValue = this->getPermissionGrantValue(permission::i_permission_modify_power, channel);
|
||||
bool ignoreGrant = this->permissionGranted(permission::b_permission_modify_power_ignore, 1, channel);
|
||||
auto updateClients = false, update_view = false, update_channel_properties = false;
|
||||
|
||||
bool conOnError = cmd[0].has("continueonerror");
|
||||
@@ -2449,7 +2449,7 @@ command_result ConnectedClient::handleCommandChannelAddPerm(Command &cmd) {
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
}
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, channel)) {
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, channel)) {
|
||||
if(conOnError) continue;
|
||||
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
@@ -2536,7 +2536,7 @@ command_result ConnectedClient::handleCommandChannelDelPerm(Command &cmd) {
|
||||
assert(channel);
|
||||
CHANNEL_PERMISSION_TEST(permission::i_channel_permission_modify_power, permission::i_channel_needed_permission_modify_power, channel, true);
|
||||
|
||||
bool ignoreGrant = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_permission_modify_power_ignore, 1, channel);
|
||||
bool ignoreGrant = this->permissionGranted(permission::b_permission_modify_power_ignore, 1, channel);
|
||||
bool conOnError = cmd[0].has("continueonerror");
|
||||
auto updateClients = false, update_view = false, update_channel_properties = false;
|
||||
|
||||
@@ -2544,7 +2544,7 @@ command_result ConnectedClient::handleCommandChannelDelPerm(Command &cmd) {
|
||||
for (int index = 0; index < cmd.bulkCount(); index++) {
|
||||
PARSE_PERMISSION(cmd);
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, channel))
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, channel))
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
|
||||
if (grant) {
|
||||
@@ -2681,7 +2681,7 @@ command_result ConnectedClient::handleCommandServerGroupCopy(Command &cmd) {
|
||||
return command_result{result};
|
||||
}
|
||||
|
||||
if(!target_group->permission_granted(permission::i_server_group_needed_modify_power, this->calculate_permission_value(permission::i_server_group_modify_power, 0), true))
|
||||
if(!target_group->permission_granted(permission::i_server_group_needed_modify_power, this->calculate_permission(permission::i_server_group_modify_power, 0), true))
|
||||
return command_result{permission::i_server_group_modify_power};
|
||||
|
||||
if(!group_manager->copyGroupPermissions(source_group, target_group))
|
||||
@@ -2836,7 +2836,7 @@ command_result ConnectedClient::handleCommandServerGroupAddClient(Command &cmd)
|
||||
auto target_cldbid = cmd["cldbid"].as<ClientDbId>();
|
||||
if (!serverInstance->databaseHelper()->validClientDatabaseId(target_server, cmd["cldbid"])) return command_result{error::client_invalid_id, "invalid cldbid"};
|
||||
|
||||
auto needed_client_permission = this->server->calculatePermission(permission::PERMTEST_ORDERED, target_cldbid, permission::i_client_needed_permission_modify_power, ClientType::CLIENT_TEAMSPEAK, nullptr);
|
||||
auto needed_client_permission = this->server->calculatePermission(target_cldbid, permission::i_client_needed_permission_modify_power, ClientType::CLIENT_TEAMSPEAK, nullptr);
|
||||
if(needed_client_permission != permNotGranted) {
|
||||
if(!this->permission_granted(this->permissionValue(permission::i_client_permission_modify_power), needed_client_permission))
|
||||
return command_result{permission::i_client_needed_permission_modify_power};
|
||||
@@ -2848,8 +2848,8 @@ command_result ConnectedClient::handleCommandServerGroupAddClient(Command &cmd)
|
||||
|
||||
auto continue_on_error = cmd.hasParm("continueonerror");
|
||||
{
|
||||
auto permission_add_power = this->calculate_permission_value(permission::i_server_group_member_add_power, -1);
|
||||
auto permission_self_add_power = this->calculate_permission_value(permission::i_server_group_member_add_power, -1);
|
||||
auto permission_add_power = this->calculate_permission(permission::i_server_group_member_add_power, -1);
|
||||
auto permission_self_add_power = this->calculate_permission(permission::i_server_group_member_add_power, -1);
|
||||
|
||||
for(auto index = 0; index < cmd.bulkCount(); index++) {
|
||||
auto group_id = cmd[index]["sgid"];
|
||||
@@ -2952,7 +2952,7 @@ command_result ConnectedClient::handleCommandServerGroupDelClient(Command &cmd)
|
||||
auto target_cldbid = cmd["cldbid"].as<ClientDbId>();
|
||||
if (!serverInstance->databaseHelper()->validClientDatabaseId(target_server, cmd["cldbid"])) return command_result{error::client_invalid_id, "invalid cldbid"};
|
||||
|
||||
auto needed_client_permission = this->server->calculatePermission(permission::PERMTEST_ORDERED, target_cldbid, permission::i_client_needed_permission_modify_power, ClientType::CLIENT_TEAMSPEAK, nullptr);
|
||||
auto needed_client_permission = this->server->calculatePermission(target_cldbid, permission::i_client_needed_permission_modify_power, ClientType::CLIENT_TEAMSPEAK, nullptr);
|
||||
if(needed_client_permission != permNotGranted) {
|
||||
if(!this->permission_granted(this->permissionValue(permission::i_client_permission_modify_power), needed_client_permission))
|
||||
return command_result{permission::i_client_needed_permission_modify_power};
|
||||
@@ -2964,8 +2964,8 @@ command_result ConnectedClient::handleCommandServerGroupDelClient(Command &cmd)
|
||||
|
||||
auto continue_on_error = cmd.hasParm("continueonerror");
|
||||
{
|
||||
auto permission_remove_power = this->calculate_permission_value(permission::i_server_group_member_remove_power, -1);
|
||||
auto permission_self_remove_power = this->calculate_permission_value(permission::i_server_group_member_remove_power, -1);
|
||||
auto permission_remove_power = this->calculate_permission(permission::i_server_group_member_remove_power, -1);
|
||||
auto permission_self_remove_power = this->calculate_permission(permission::i_server_group_member_remove_power, -1);
|
||||
|
||||
for(auto index = 0; index < cmd.bulkCount(); index++) {
|
||||
auto group_id = cmd[index]["sgid"];
|
||||
@@ -3104,7 +3104,7 @@ command_result ConnectedClient::handleCommandServerGroupAddPerm(Command &cmd) {
|
||||
return command_result{permission::b_serverinstance_modify_templates};
|
||||
}
|
||||
|
||||
auto maxValue = this->getPermissionGrantValue(permission::PERMTEST_ORDERED, permission::i_permission_modify_power, this->currentChannel);
|
||||
auto maxValue = this->getPermissionGrantValue(permission::i_permission_modify_power, this->currentChannel);
|
||||
bool ignoreGrant = this->permission_granted(this->cached_permission_value(permission::b_permission_modify_power_ignore), 1);
|
||||
bool conOnError = cmd[0].has("continueonerror");
|
||||
bool checkTp = false;
|
||||
@@ -3121,7 +3121,7 @@ command_result ConnectedClient::handleCommandServerGroupAddPerm(Command &cmd) {
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
}
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, this->currentChannel)) {
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, this->currentChannel)) {
|
||||
if(conOnError) continue;
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
}
|
||||
@@ -3194,7 +3194,7 @@ command_result ConnectedClient::handleCommandServerGroupDelPerm(Command &cmd) {
|
||||
for (int index = 0; index < cmd.bulkCount(); index++) {
|
||||
PARSE_PERMISSION(cmd);
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, this->currentChannel)) {
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, this->currentChannel)) {
|
||||
if(conOnError) continue;
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
}
|
||||
@@ -3250,13 +3250,13 @@ command_result ConnectedClient::handleCommandServerGroupAutoAddPerm(ts::Command&
|
||||
deque<shared_ptr<Group>> groups;
|
||||
for(const auto& group : group_manager->availableGroups(false)) {
|
||||
if(group->updateType() == cmd["sgtype"].as<permission::PermissionValue>() && group->target() == GROUPTARGET_SERVER) {
|
||||
if(group->permission_granted(permission::i_server_group_needed_modify_power, this->calculate_permission_value(permission::i_server_group_modify_power, 0), true)) {
|
||||
if(group->permission_granted(permission::i_server_group_needed_modify_power, this->calculate_permission(permission::i_server_group_modify_power, 0), true)) {
|
||||
auto type = group->type();
|
||||
if(type == GroupType::GROUP_TYPE_QUERY) {
|
||||
if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_serverinstance_modify_querygroup, 1))
|
||||
if(!this->permissionGranted(permission::b_serverinstance_modify_querygroup, 1))
|
||||
continue;
|
||||
} else if(type == GroupType::GROUP_TYPE_TEMPLATE) {
|
||||
if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_serverinstance_modify_templates, 1))
|
||||
if(!this->permissionGranted(permission::b_serverinstance_modify_templates, 1))
|
||||
continue;
|
||||
}
|
||||
groups.push_back(group);//sgtype
|
||||
@@ -3267,9 +3267,9 @@ command_result ConnectedClient::handleCommandServerGroupAutoAddPerm(ts::Command&
|
||||
if(groups.empty())
|
||||
return command_result{error::ok};
|
||||
|
||||
auto maxValue = this->getPermissionGrantValue(permission::PERMTEST_ORDERED, permission::i_permission_modify_power, this->currentChannel);
|
||||
auto maxValue = this->getPermissionGrantValue(permission::i_permission_modify_power, this->currentChannel);
|
||||
|
||||
bool ignoreGrant = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_permission_modify_power_ignore, 1);
|
||||
bool ignoreGrant = this->permissionGranted(permission::b_permission_modify_power_ignore, 1);
|
||||
bool conOnError = cmd[0].has("continueonerror");
|
||||
bool checkTp = false;
|
||||
bool sgroupUpdate = false;
|
||||
@@ -3284,7 +3284,7 @@ command_result ConnectedClient::handleCommandServerGroupAutoAddPerm(ts::Command&
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
}
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, this->currentChannel)) {
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, this->currentChannel)) {
|
||||
if(conOnError) continue;
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
}
|
||||
@@ -3347,13 +3347,13 @@ command_result ConnectedClient::handleCommandServerGroupAutoDelPerm(ts::Command&
|
||||
deque<shared_ptr<Group>> groups;
|
||||
for(const auto& group : group_manager->availableGroups(false)) {
|
||||
if(group->updateType() == cmd["sgtype"].as<permission::PermissionValue>() && group->target() == GROUPTARGET_SERVER) {
|
||||
if(group->permission_granted(permission::i_server_group_needed_modify_power, this->calculate_permission_value(permission::i_server_group_modify_power, 0), true)) {
|
||||
if(group->permission_granted(permission::i_server_group_needed_modify_power, this->calculate_permission(permission::i_server_group_modify_power, 0), true)) {
|
||||
auto type = group->type();
|
||||
if(type == GroupType::GROUP_TYPE_QUERY) {
|
||||
if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_serverinstance_modify_querygroup, 1))
|
||||
if(!this->permissionGranted(permission::b_serverinstance_modify_querygroup, 1))
|
||||
continue;
|
||||
} else if(type == GroupType::GROUP_TYPE_TEMPLATE) {
|
||||
if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_serverinstance_modify_templates, 1))
|
||||
if(!this->permissionGranted(permission::b_serverinstance_modify_templates, 1))
|
||||
continue;
|
||||
}
|
||||
groups.push_back(group);//sgtype
|
||||
@@ -3363,14 +3363,14 @@ command_result ConnectedClient::handleCommandServerGroupAutoDelPerm(ts::Command&
|
||||
|
||||
if(groups.empty()) return command_result{error::ok};
|
||||
|
||||
bool ignoreGrant = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_permission_modify_power_ignore, 1);
|
||||
bool ignoreGrant = this->permissionGranted(permission::b_permission_modify_power_ignore, 1);
|
||||
bool conOnError = cmd[0].has("continueonerror");
|
||||
bool checkTp = false;
|
||||
auto sgroupUpdate = false;
|
||||
for (int index = 0; index < cmd.bulkCount(); index++) {
|
||||
PARSE_PERMISSION(cmd);
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, this->currentChannel)) {
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, this->currentChannel)) {
|
||||
if(conOnError) continue;
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
}
|
||||
@@ -3441,18 +3441,18 @@ command_result ConnectedClient::handleCommandSetClientChannelGroup(Command &cmd)
|
||||
|
||||
auto target_cldbid = cmd["cldbid"].as<ClientDbId>();
|
||||
{
|
||||
auto channel_group_member_add_power = this->calculate_permission_value(permission::i_channel_group_member_add_power, channel_id);
|
||||
auto channel_group_member_add_power = this->calculate_permission(permission::i_channel_group_member_add_power, channel_id);
|
||||
if(!serverGroup->permission_granted(permission::i_channel_group_needed_member_add_power, channel_group_member_add_power, true)) {
|
||||
if(target_cldbid != this->getClientDatabaseId())
|
||||
return command_result{permission::i_channel_group_member_add_power};
|
||||
|
||||
auto channel_group_self_add_power = this->calculate_permission_value(permission::i_channel_group_self_add_power, channel_id);
|
||||
auto channel_group_self_add_power = this->calculate_permission(permission::i_channel_group_self_add_power, channel_id);
|
||||
if(!serverGroup->permission_granted(permission::i_channel_group_needed_member_add_power, channel_group_self_add_power, true))
|
||||
return command_result{permission::i_channel_group_self_add_power};
|
||||
}
|
||||
|
||||
|
||||
auto client_permission_modify_power = this->calculate_permission_value(permission::i_client_permission_modify_power, channel_id);
|
||||
auto client_permission_modify_power = this->calculate_permission(permission::i_client_permission_modify_power, channel_id);
|
||||
auto client_needed_permission_modify_power = this->server->calculatePermission2(
|
||||
permission::i_client_needed_permission_modify_power, target_cldbid, ClientType::CLIENT_TEAMSPEAK, channel_id);
|
||||
|
||||
@@ -3466,12 +3466,12 @@ command_result ConnectedClient::handleCommandSetClientChannelGroup(Command &cmd)
|
||||
{
|
||||
auto old_group = this->server->groups->getChannelGroupExact(target_cldbid, channel, false);
|
||||
if(old_group) {
|
||||
auto channel_group_member_remove_power = this->calculate_permission_value(permission::i_channel_group_member_remove_power, channel_id);
|
||||
auto channel_group_member_remove_power = this->calculate_permission(permission::i_channel_group_member_remove_power, channel_id);
|
||||
if(!serverGroup->permission_granted(permission::i_channel_group_needed_member_remove_power, channel_group_member_remove_power, true)) {
|
||||
if(target_cldbid != this->getClientDatabaseId())
|
||||
return command_result{permission::i_channel_group_member_remove_power};
|
||||
|
||||
auto channel_group_self_remove_power = this->calculate_permission_value(permission::i_channel_group_self_remove_power, channel_id);
|
||||
auto channel_group_self_remove_power = this->calculate_permission(permission::i_channel_group_self_remove_power, channel_id);
|
||||
if(!serverGroup->permission_granted(permission::i_channel_group_needed_member_remove_power, channel_group_self_remove_power, true))
|
||||
return command_result{permission::i_channel_group_self_remove_power};
|
||||
}
|
||||
@@ -3534,7 +3534,7 @@ command_result ConnectedClient::handleCommandSendTextMessage(Command &cmd) {
|
||||
PERM_CHECK_CHANNELR(permission::b_client_even_textmessage_send, 1, this->currentChannel, true);
|
||||
}
|
||||
|
||||
PERM_CHECK_CHANNELR(permission::i_client_private_textmessage_power, target->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_needed_private_textmessage_power, target->currentChannel), this->currentChannel, false);
|
||||
PERM_CHECK_CHANNELR(permission::i_client_private_textmessage_power, target->permissionValue(permission::i_client_needed_private_textmessage_power, target->currentChannel), this->currentChannel, false);
|
||||
|
||||
|
||||
{
|
||||
@@ -3568,7 +3568,7 @@ command_result ConnectedClient::handleCommandSendTextMessage(Command &cmd) {
|
||||
channel_tree_read_lock.lock();
|
||||
}
|
||||
|
||||
if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_channel_textmessage_send, 1, channel, false))
|
||||
if(!this->permissionGranted(permission::b_client_channel_textmessage_send, 1, channel, false))
|
||||
return command_result{permission::b_client_channel_textmessage_send};
|
||||
|
||||
bool conversation_private = channel->properties()[property::CHANNEL_FLAG_CONVERSATION_PRIVATE].as<bool>();
|
||||
@@ -3715,7 +3715,7 @@ command_result ConnectedClient::handleCommandFTGetFileList(Command &cmd) {
|
||||
if (cmd[0].has("cid") && cmd["cid"] != 0) { //Channel
|
||||
auto channel = this->server->channelTree->findChannel(cmd["cid"].as<ChannelId>());
|
||||
if (!channel) return command_result{error::channel_invalid_id, "Cant resolve channel"};
|
||||
if (!channel->passwordMatch(cmd["cpw"]) && !this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_ft_ignore_password, 1, channel, true))
|
||||
if (!channel->passwordMatch(cmd["cpw"]) && !this->permissionGranted(permission::b_ft_ignore_password, 1, channel, true))
|
||||
return cmd["cpw"].string().empty() ? command_result{permission::b_ft_ignore_password} : command_result{error::channel_invalid_password};
|
||||
CHANNEL_PERMISSION_TEST(permission::i_ft_file_browse_power, permission::i_ft_needed_file_browse_power, channel, true);
|
||||
cmd_filelist_append_files(
|
||||
@@ -3759,7 +3759,7 @@ command_result ConnectedClient::handleCommandFTCreateDir(Command &cmd) {
|
||||
|
||||
auto channel = this->server->channelTree->findChannel(cmd["cid"].as<ChannelId>());
|
||||
if (!channel) return command_result{error::channel_invalid_id, "Cant resolve channel"};
|
||||
if (!channel->passwordMatch(cmd["cpw"]) && !this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_ft_ignore_password, 1, channel, true))
|
||||
if (!channel->passwordMatch(cmd["cpw"]) && !this->permissionGranted(permission::b_ft_ignore_password, 1, channel, true))
|
||||
return cmd["cpw"].string().empty() ? command_result{permission::b_ft_ignore_password} : command_result{error::channel_invalid_password};
|
||||
CHANNEL_PERMISSION_TEST(permission::i_ft_directory_create_power, permission::i_ft_needed_directory_create_power, channel, true);
|
||||
|
||||
@@ -3780,7 +3780,7 @@ command_result ConnectedClient::handleCommandFTDeleteFile(Command &cmd) {
|
||||
if (cmd[0].has("cid") && cmd["cid"] != 0) { //Channel
|
||||
auto channel = this->server->channelTree->findChannel(cmd["cid"].as<ChannelId>());
|
||||
if (!channel) return command_result{error::channel_invalid_id, "Cant resolve channel"};
|
||||
if (!channel->passwordMatch(cmd["cpw"]) && !this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_ft_ignore_password, 1, channel, true))
|
||||
if (!channel->passwordMatch(cmd["cpw"]) && !this->permissionGranted(permission::b_ft_ignore_password, 1, channel, true))
|
||||
return cmd["cpw"].string().empty() ? command_result{permission::b_ft_ignore_password} : command_result{error::channel_invalid_password};
|
||||
CHANNEL_PERMISSION_TEST(permission::i_ft_file_delete_power, permission::i_ft_needed_file_delete_power, channel, true);
|
||||
for (int index = 0; index < cmd.bulkCount(); index++)
|
||||
@@ -3834,17 +3834,17 @@ command_result ConnectedClient::handleCommandFTInitUpload(Command &cmd) {
|
||||
if (cmd[0].has("cid") && cmd["cid"] != 0) { //Channel
|
||||
auto channel = this->server->channelTree->findChannel(cmd["cid"].as<ChannelId>());
|
||||
if (!channel) return command_result{error::channel_invalid_id, "Cant resolve channel"};
|
||||
if (!channel->passwordMatch(cmd["cpw"]) && !this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_ft_ignore_password, 1, channel, true))
|
||||
if (!channel->passwordMatch(cmd["cpw"]) && !this->permissionGranted(permission::b_ft_ignore_password, 1, channel, true))
|
||||
return cmd["cpw"].string().empty() ? command_result{permission::b_ft_ignore_password} : command_result{error::channel_invalid_password};
|
||||
CHANNEL_PERMISSION_TEST(permission::i_ft_file_upload_power, permission::i_ft_needed_file_upload_power, channel, true);
|
||||
directory = serverInstance->getFileServer()->resolveDirectory(this->server, channel);
|
||||
} else {
|
||||
if (cmd["path"].as<std::string>().empty() && cmd["name"].as<std::string>().find("/icon_") == 0) {
|
||||
auto max_size = this->permissionValue(permission::PERMTEST_ORDERED, permission::i_max_icon_filesize, this->currentChannel);
|
||||
auto max_size = this->permissionValue(permission::i_max_icon_filesize, this->currentChannel);
|
||||
if(max_size != -1 && max_size < (ssize_t) cmd["size"].as<size_t>()) return command_result{permission::i_max_icon_filesize};
|
||||
directory = serverInstance->getFileServer()->iconDirectory(this->server);
|
||||
} else if (cmd["path"].as<std::string>().empty() && cmd["name"].string() == "/avatar") {
|
||||
auto max_size = this->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_max_avatar_filesize, this->currentChannel);
|
||||
auto max_size = this->permissionValue(permission::i_client_max_avatar_filesize, this->currentChannel);
|
||||
if(max_size != -1 && max_size < (ssize_t) cmd["size"].as<size_t>()) return command_result{permission::i_client_max_avatar_filesize};
|
||||
|
||||
directory = serverInstance->getFileServer()->avatarDirectory(this->server);
|
||||
@@ -3870,7 +3870,7 @@ command_result ConnectedClient::handleCommandFTInitUpload(Command &cmd) {
|
||||
server_used_quota += trans->remaining_bytes();
|
||||
if(server_quota >= 0 && server_quota * 1024 * 1024 < (int64_t) server_used_quota) return command_result{error::file_transfer_server_quota_exceeded};
|
||||
|
||||
auto client_quota = this->permissionValue(permission::PERMTEST_ORDERED, permission::i_ft_quota_mb_upload_per_client, this->currentChannel);
|
||||
auto client_quota = this->permissionValue(permission::i_ft_quota_mb_upload_per_client, this->currentChannel);
|
||||
auto client_used_quota = this->properties()[property::CLIENT_MONTH_BYTES_UPLOADED].as<size_t>();
|
||||
client_used_quota += cmd["size"].as<uint64_t>();
|
||||
for(const auto& trans : serverInstance->getFileServer()->pending_file_transfers(_this.lock()))
|
||||
@@ -3932,7 +3932,7 @@ command_result ConnectedClient::handleCommandFTInitDownload(Command &cmd) {
|
||||
if (!channel) return command_result{error::channel_invalid_id, "Cant resolve channel"};
|
||||
|
||||
CHANNEL_PERMISSION_TEST(permission::i_ft_file_download_power, permission::i_ft_needed_file_download_power, channel, true);
|
||||
if (!channel->passwordMatch(cmd["cpw"]) && !this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_ft_ignore_password, 1, channel, true))
|
||||
if (!channel->passwordMatch(cmd["cpw"]) && !this->permissionGranted(permission::b_ft_ignore_password, 1, channel, true))
|
||||
return cmd["cpw"].string().empty() ? command_result{permission::b_ft_ignore_password} : command_result{error::channel_invalid_password};
|
||||
|
||||
directory = serverInstance->getFileServer()->resolveDirectory(this->server, channel);
|
||||
@@ -3970,7 +3970,7 @@ command_result ConnectedClient::handleCommandFTInitDownload(Command &cmd) {
|
||||
if(server_quota >= 0 && server_quota * 1024 * 1024 < (int64_t) server_used_quota) return command_result{error::file_transfer_server_quota_exceeded};
|
||||
|
||||
|
||||
auto client_quota = this->permissionValue(permission::PERMTEST_ORDERED, permission::i_ft_quota_mb_download_per_client, this->currentChannel);
|
||||
auto client_quota = this->permissionValue(permission::i_ft_quota_mb_download_per_client, this->currentChannel);
|
||||
auto client_used_quota = this->properties()[property::CLIENT_MONTH_BYTES_DOWNLOADED].as<size_t>();
|
||||
client_used_quota += key->size;
|
||||
for(const auto& trans : serverInstance->getFileServer()->pending_file_transfers(_this.lock()))
|
||||
@@ -4042,7 +4042,7 @@ command_result ConnectedClient::handleCommandFTGetFileInfo(ts::Command &cmd) {
|
||||
if (request.has("cid") && request["cid"].as<ChannelId>() != 0) { //Channel
|
||||
auto channel = this->server->channelTree->findChannel(request["cid"].as<ChannelId>());
|
||||
if (!channel) return command_result{error::channel_invalid_id, "Cant resolve channel"};
|
||||
if (!channel->passwordMatch(cmd["cpw"]) && !this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_ft_ignore_password, 1, channel, true))
|
||||
if (!channel->passwordMatch(cmd["cpw"]) && !this->permissionGranted(permission::b_ft_ignore_password, 1, channel, true))
|
||||
return cmd["cpw"].string().empty() ? command_result{permission::b_ft_ignore_password} : command_result{error::channel_invalid_password};
|
||||
|
||||
CHANNEL_PERMISSION_TEST(permission::i_ft_file_browse_power, permission::i_ft_needed_file_browse_power, channel, true);
|
||||
@@ -4097,7 +4097,7 @@ command_result ConnectedClient::handleCommandBanList(Command &cmd) {
|
||||
auto server = serverInstance->getVoiceServerManager()->findServerById(sid);
|
||||
if (!server) return command_result{error::parameter_invalid};
|
||||
|
||||
if (server->calculatePermission(permission::PERMTEST_ORDERED, this->getClientDatabaseId(), permission::b_client_ban_list, this->getType(), nullptr) != 1)
|
||||
if (server->calculatePermission(this->getClientDatabaseId(), permission::b_client_ban_list, this->getType(), nullptr) != 1)
|
||||
return command_result{permission::b_client_ban_list};
|
||||
}
|
||||
|
||||
@@ -4159,7 +4159,7 @@ command_result ConnectedClient::handleCommandBanAdd(Command &cmd) {
|
||||
} else {
|
||||
auto server = serverInstance->getVoiceServerManager()->findServerById(sid);
|
||||
if (!server) return command_result{error::parameter_invalid};
|
||||
if (server->calculatePermission(permission::PERMTEST_ORDERED, this->getClientDatabaseId(), permission::b_client_ban_create, this->getType(), nullptr) != 1)
|
||||
if (server->calculatePermission(this->getClientDatabaseId(), permission::b_client_ban_create, this->getType(), nullptr) != 1)
|
||||
return command_result{permission::b_client_ban_create_global};
|
||||
}
|
||||
|
||||
@@ -4210,7 +4210,7 @@ command_result ConnectedClient::handleCommandBanEdit(Command &cmd) {
|
||||
auto server = serverInstance->getVoiceServerManager()->findServerById(sid);
|
||||
if (!server) return command_result{error::parameter_invalid};
|
||||
|
||||
if (server->calculatePermission(permission::PERMTEST_ORDERED, this->getClientDatabaseId(), permission::b_client_ban_edit, this->getType(), nullptr) != 1) return command_result{permission::b_client_ban_edit};
|
||||
if (server->calculatePermission(this->getClientDatabaseId(), permission::b_client_ban_edit, this->getType(), nullptr) != 1) return command_result{permission::b_client_ban_edit};
|
||||
}
|
||||
|
||||
/* ip name uid reason time hwid */
|
||||
@@ -4298,9 +4298,9 @@ command_result ConnectedClient::handleCommandBanClient(Command &cmd) {
|
||||
return command_result{error::client_unknown};
|
||||
}
|
||||
if (target_dbid != 0) {
|
||||
if (this->server->calculatePermission(permission::PERMTEST_ORDERED, target_dbid, permission::i_client_needed_ban_power, ClientType::CLIENT_TEAMSPEAK, nullptr) > this->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_ban_power))
|
||||
if (this->server->calculatePermission(target_dbid, permission::i_client_needed_ban_power, ClientType::CLIENT_TEAMSPEAK, nullptr) > this->permissionValue(permission::i_client_ban_power))
|
||||
return command_result{permission::i_client_ban_power};
|
||||
if (this->server->calculatePermission(permission::PERMTEST_ORDERED, target_dbid, permission::b_client_ignore_bans, ClientType::CLIENT_TEAMSPEAK, nullptr) >= 1) return command_result{permission::b_client_ignore_bans};
|
||||
if (this->server->calculatePermission(target_dbid, permission::b_client_ignore_bans, ClientType::CLIENT_TEAMSPEAK, nullptr) >= 1) return command_result{permission::b_client_ignore_bans};
|
||||
}
|
||||
deque<BanId> ban_ids;
|
||||
auto _id = serverInstance->banManager()->registerBan(this->getServer()->getServerId(), this->getClientDatabaseId(), reason, uid, "", "", "", until);
|
||||
@@ -4376,7 +4376,7 @@ command_result ConnectedClient::handleCommandBanDel(Command &cmd) {
|
||||
if (!server) return command_result{error::parameter_invalid};
|
||||
|
||||
auto perm = ban->invokerDbId == this->getClientDatabaseId() ? permission::b_client_ban_delete_own : permission::b_client_ban_delete;
|
||||
if (server->calculatePermission(permission::PERMTEST_ORDERED, this->getClientDatabaseId(), perm, this->getType(), nullptr) != 1) return command_result{perm};
|
||||
if (server->calculatePermission(this->getClientDatabaseId(), perm, this->getType(), nullptr) != 1) return command_result{perm};
|
||||
}
|
||||
serverInstance->banManager()->unban(ban);
|
||||
return command_result{error::ok};
|
||||
@@ -4763,7 +4763,7 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
PERM_CHECKR(permission::b_client_modify_own_description, 1, true);
|
||||
else if(client->getType() == ClientType::CLIENT_MUSIC) {
|
||||
if(client->properties()[property::CLIENT_OWNER] != this->getClientDatabaseId()) {
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
}
|
||||
} else {
|
||||
PERM_CHECKR(permission::b_client_modify_description, 1, true);
|
||||
@@ -4784,7 +4784,7 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
if(!self) {
|
||||
if(client->getType() != ClientType::CLIENT_MUSIC) return command_result{error::client_invalid_type};
|
||||
if(client->properties()[property::CLIENT_OWNER] != this->getClientDatabaseId()) {
|
||||
CACHED_PERM_CHECK(permission::i_client_music_rename_power, client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_rename_power, client->currentChannel), true);
|
||||
CACHED_PERM_CHECK(permission::i_client_music_rename_power, client->permissionValue(permission::i_client_music_needed_rename_power, client->currentChannel), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4792,7 +4792,7 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
if (count_characters(name) < 3) return command_result{error::parameter_invalid, "Invalid name length. A minimum of 3 characters is required!"};
|
||||
if (count_characters(name) > 30) return command_result{error::parameter_invalid, "Invalid name length. A maximum of 30 characters is allowed!"};
|
||||
|
||||
auto banIgnore = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_ignore_bans, 1, this->currentChannel);
|
||||
auto banIgnore = this->permissionGranted(permission::b_client_ignore_bans, 1, this->currentChannel);
|
||||
if (!banIgnore) {
|
||||
auto banRecord = serverInstance->banManager()->findBanByName(this->getServerId(), name);
|
||||
if (banRecord)
|
||||
@@ -4817,7 +4817,7 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
} else if(*info == property::CLIENT_PLAYER_VOLUME) {
|
||||
if(client->getType() != ClientType::CLIENT_MUSIC) return command_result{error::client_invalid_type};
|
||||
if(client->properties()[property::CLIENT_OWNER] != this->getClientDatabaseId()) {
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
}
|
||||
auto bot = dynamic_pointer_cast<MusicClient>(client);
|
||||
assert(bot);
|
||||
@@ -4831,7 +4831,7 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
if(!self) {
|
||||
if(client->getType() != ClientType::CLIENT_MUSIC) return command_result{error::client_invalid_type};
|
||||
if(client->properties()[property::CLIENT_OWNER] != this->getClientDatabaseId()) {
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4844,7 +4844,7 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
if(client->getType() != ClientType::CLIENT_MUSIC)
|
||||
return command_result{error::client_invalid_type};
|
||||
if(client->properties()[property::CLIENT_OWNER] != this->getClientDatabaseId()) {
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4871,7 +4871,7 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
index++;
|
||||
} while (index < str.length() && index != 0);
|
||||
if (badgesTags >= 2) {
|
||||
if (!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_allow_invalid_badges, 1, this->currentChannel))
|
||||
if (!this->permissionGranted(permission::b_client_allow_invalid_badges, 1, this->currentChannel))
|
||||
((VoiceClient *) this)->disconnect(VREASON_SERVER_KICK, config::messages::kick_invalid_badges, this->server ? this->server->serverAdmin : dynamic_pointer_cast<ConnectedClient>(serverInstance->getInitialServerAdmin()), true);
|
||||
return command_result{error::parameter_invalid, "Invalid badges"};
|
||||
}
|
||||
@@ -4879,27 +4879,27 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
} else if(!self && key == "client_version") {
|
||||
if(client->getType() != ClientType::CLIENT_MUSIC) return command_result{error::client_invalid_type};
|
||||
if(client->properties()[property::CLIENT_OWNER] != this->getClientDatabaseId()) {
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
}
|
||||
} else if(!self && key == "client_platform") {
|
||||
if(client->getType() != ClientType::CLIENT_MUSIC) return command_result{error::client_invalid_type};
|
||||
if(client->properties()[property::CLIENT_OWNER] != this->getClientDatabaseId()) {
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
}
|
||||
} else if(!self && key == "client_country") {
|
||||
if(client->getType() != ClientType::CLIENT_MUSIC) return command_result{error::client_invalid_type};
|
||||
if(client->properties()[property::CLIENT_OWNER] != this->getClientDatabaseId()) {
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
}
|
||||
} else if(!self && (*info == property::CLIENT_FLAG_NOTIFY_SONG_CHANGE/* || *info == property::CLIENT_NOTIFY_SONG_MESSAGE*/)) {
|
||||
if(client->getType() != ClientType::CLIENT_MUSIC) return command_result{error::client_invalid_type};
|
||||
if(client->properties()[property::CLIENT_OWNER] != this->getClientDatabaseId()) {
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
}
|
||||
} else if(!self && key == "client_uptime_mode") {
|
||||
if(client->getType() != ClientType::CLIENT_MUSIC) return command_result{error::client_invalid_type};
|
||||
if(client->properties()[property::CLIENT_OWNER] != this->getClientDatabaseId()) {
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
CACHED_PERM_CHECK(permission::i_client_music_modify_power, client->permissionValue(permission::i_client_music_needed_modify_power, client->currentChannel), true);
|
||||
}
|
||||
|
||||
if(cmd[key].as<MusicClient::UptimeMode::value>() == MusicClient::UptimeMode::TIME_SINCE_SERVER_START) {
|
||||
@@ -5253,10 +5253,10 @@ command_result ConnectedClient::handleCommandClientAddPerm(Command &cmd) {
|
||||
return command_result{error::client_invalid_id};
|
||||
auto mgr = serverInstance->databaseHelper()->loadClientPermissionManager(this->server, cldbid);
|
||||
|
||||
PERM_CHECKR(permission::i_client_permission_modify_power, this->server->calculatePermission(permission::PERMTEST_ORDERED, cldbid, permission::i_client_needed_permission_modify_power, ClientType::CLIENT_TEAMSPEAK, nullptr), true);
|
||||
PERM_CHECKR(permission::i_client_permission_modify_power, this->server->calculatePermission(cldbid, permission::i_client_needed_permission_modify_power, ClientType::CLIENT_TEAMSPEAK, nullptr), true);
|
||||
|
||||
auto maxValue = this->getPermissionGrantValue(permission::PERMTEST_ORDERED, permission::i_permission_modify_power, this->currentChannel);
|
||||
bool ignoreGrant = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_permission_modify_power_ignore, 1, this->currentChannel);
|
||||
auto maxValue = this->getPermissionGrantValue(permission::i_permission_modify_power, this->currentChannel);
|
||||
bool ignoreGrant = this->permissionGranted(permission::b_permission_modify_power_ignore, 1, this->currentChannel);
|
||||
bool conOnError = cmd[0].has("continueonerror");
|
||||
auto update_channels = false;
|
||||
for (int index = 0; index < cmd.bulkCount(); index++) {
|
||||
@@ -5266,7 +5266,7 @@ command_result ConnectedClient::handleCommandClientAddPerm(Command &cmd) {
|
||||
if(permission_require_granted_value(permType) && val > maxValue)
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, this->currentChannel))
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, this->currentChannel))
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
|
||||
if (grant) {
|
||||
@@ -5299,16 +5299,16 @@ command_result ConnectedClient::handleCommandClientDelPerm(Command &cmd) {
|
||||
if(!serverInstance->databaseHelper()->validClientDatabaseId(this->server, cldbid))
|
||||
return command_result{error::client_invalid_id};
|
||||
auto mgr = serverInstance->databaseHelper()->loadClientPermissionManager(this->server, cldbid);
|
||||
PERM_CHECKR(permission::i_client_permission_modify_power, this->server->calculatePermission(permission::PERMTEST_ORDERED, cldbid, permission::i_client_needed_permission_modify_power, ClientType::CLIENT_TEAMSPEAK, nullptr), true);
|
||||
PERM_CHECKR(permission::i_client_permission_modify_power, this->server->calculatePermission(cldbid, permission::i_client_needed_permission_modify_power, ClientType::CLIENT_TEAMSPEAK, nullptr), true);
|
||||
|
||||
bool ignoreGrant = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_permission_modify_power_ignore, 1, this->currentChannel);
|
||||
bool ignoreGrant = this->permissionGranted(permission::b_permission_modify_power_ignore, 1, this->currentChannel);
|
||||
bool conOnError = cmd[0].has("continueonerror");
|
||||
auto onlineClients = this->server->findClientsByCldbId(cmd["cldbid"]);
|
||||
auto update_channel = false;
|
||||
for (int index = 0; index < cmd.bulkCount(); index++) {
|
||||
PARSE_PERMISSION(cmd)
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, this->currentChannel))
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, this->currentChannel))
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
|
||||
|
||||
@@ -5411,19 +5411,19 @@ command_result ConnectedClient::handleCommandChannelClientDelPerm(Command &cmd)
|
||||
return command_result{error::parameter_invalid, "Invalid manager db id"};
|
||||
|
||||
auto mgr = serverInstance->databaseHelper()->loadClientPermissionManager(this->server, cldbid);
|
||||
PERM_CHECKR(permission::i_client_permission_modify_power, this->server->calculatePermission(permission::PERMTEST_ORDERED, cmd["cldbid"], permission::i_client_needed_permission_modify_power, ClientType::CLIENT_TEAMSPEAK, nullptr), true);
|
||||
PERM_CHECKR(permission::i_client_permission_modify_power, this->server->calculatePermission(cmd["cldbid"], permission::i_client_needed_permission_modify_power, ClientType::CLIENT_TEAMSPEAK, nullptr), true);
|
||||
|
||||
RESOLVE_CHANNEL_R(cmd["cid"], true);
|
||||
auto channel = dynamic_pointer_cast<ServerChannel>(l_channel->entry);
|
||||
if(!channel) return command_result{error::vs_critical};
|
||||
|
||||
bool ignoreGrant = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_permission_modify_power_ignore, 1, this->currentChannel);
|
||||
bool ignoreGrant = this->permissionGranted(permission::b_permission_modify_power_ignore, 1, this->currentChannel);
|
||||
bool conOnError = cmd[0].has("continueonerror"), update_view = false;
|
||||
auto cll = this->server->findClientsByCldbId(cldbid);
|
||||
for (int index = 0; index < cmd.bulkCount(); index++) {
|
||||
PARSE_PERMISSION(cmd);
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, this->currentChannel))
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, this->currentChannel))
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
|
||||
if (grant) {
|
||||
@@ -5479,11 +5479,11 @@ command_result ConnectedClient::handleCommandChannelClientAddPerm(Command &cmd)
|
||||
if(!channel) return command_result{error::vs_critical};
|
||||
|
||||
auto mgr = serverInstance->databaseHelper()->loadClientPermissionManager(this->server, cldbid);
|
||||
PERM_CHECK_CHANNELR(permission::i_client_permission_modify_power, this->server->calculatePermission(permission::PERMTEST_ORDERED, cmd["cldbid"], permission::i_client_needed_permission_modify_power, ClientType::CLIENT_TEAMSPEAK, channel), channel, true);
|
||||
PERM_CHECK_CHANNELR(permission::i_client_permission_modify_power, this->server->calculatePermission(cmd["cldbid"], permission::i_client_needed_permission_modify_power, ClientType::CLIENT_TEAMSPEAK, channel), channel, true);
|
||||
|
||||
|
||||
auto maxValue = this->getPermissionGrantValue(permission::PERMTEST_ORDERED, permission::i_permission_modify_power, this->currentChannel);
|
||||
bool ignoreGrant = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_permission_modify_power_ignore, 1, this->currentChannel);
|
||||
auto maxValue = this->getPermissionGrantValue(permission::i_permission_modify_power, this->currentChannel);
|
||||
bool ignoreGrant = this->permissionGranted(permission::b_permission_modify_power_ignore, 1, this->currentChannel);
|
||||
bool conOnError = cmd[0].has("continueonerror");
|
||||
auto onlineClientInstances = this->server->findClientsByCldbId(cldbid);
|
||||
bool update_view = false;
|
||||
@@ -5494,7 +5494,7 @@ command_result ConnectedClient::handleCommandChannelClientAddPerm(Command &cmd)
|
||||
if(permission_require_granted_value(permType) && val > maxValue)
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, this->currentChannel))
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, this->currentChannel))
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
|
||||
|
||||
@@ -5872,7 +5872,7 @@ command_result ConnectedClient::handleCommandPermGet(Command &cmd) {
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for(const auto& entry : this->permissionValues(permission::PERMTEST_ORDERED, requrested, this->currentChannel)) {
|
||||
for(const auto& entry : this->permissionValues(requrested, this->currentChannel)) {
|
||||
res[index]["permsid"] = permission_mapper->permission_name(type, entry.first);;
|
||||
res[index]["permid"] = entry.first;
|
||||
res[index++]["permvalue"] = entry.second;
|
||||
@@ -6374,7 +6374,7 @@ command_result ConnectedClient::handleCommandComplainAdd(Command &cmd) {
|
||||
|
||||
auto cl = this->server->findClientsByCldbId(target);
|
||||
if (cl.empty()) return command_result{error::client_invalid_id};
|
||||
PERM_CHECKR(permission::i_client_complain_power, cl[0]->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_needed_complain_power), true);
|
||||
PERM_CHECKR(permission::i_client_complain_power, cl[0]->permissionValue(permission::i_client_needed_complain_power), true);
|
||||
|
||||
/*
|
||||
if(!serverInstance->databaseHelper()->validClientDatabaseId(target))
|
||||
@@ -6488,7 +6488,7 @@ command_result ConnectedClient::handleCommandMusicBotCreate(Command& cmd) {
|
||||
}
|
||||
|
||||
|
||||
auto permissions_list = this->permissionValues(permission::PERMTEST_ORDERED, {
|
||||
auto permissions_list = this->permissionValues({
|
||||
permission::i_client_music_limit,
|
||||
permission::b_client_music_create_permanent,
|
||||
permission::b_client_music_create_semi_permanent,
|
||||
@@ -6543,7 +6543,7 @@ command_result ConnectedClient::handleCommandMusicBotCreate(Command& cmd) {
|
||||
if(cmd[0].has("cid")) return command_result{error::channel_invalid_id};
|
||||
} else {
|
||||
CHANNEL_PERMISSION_TEST(permission::i_channel_description_view_power, permission::i_channel_needed_description_view_power, channel, false);
|
||||
auto permission_granted = this->calculate_permission_value(permission::i_channel_join_power, channel->channelId());
|
||||
auto permission_granted = this->calculate_permission(permission::i_channel_join_power, channel->channelId());
|
||||
if(!channel->permission_granted(permission::i_channel_needed_join_power, permission_granted, false))
|
||||
channel = nullptr;
|
||||
}
|
||||
@@ -6600,7 +6600,7 @@ command_result ConnectedClient::handleCommandMusicBotDelete(Command& cmd) {
|
||||
auto bot = this->server->musicManager->findBotById(cmd["bot_id"]);
|
||||
if(!bot) return command_result{error::music_invalid_id};
|
||||
|
||||
bool permPower = this->permissionGranted(permission::PERMTEST_ORDERED, permission::i_client_music_delete_power, bot->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_delete_power));
|
||||
bool permPower = this->permissionGranted(permission::i_client_music_delete_power, bot->permissionValue(permission::i_client_music_needed_delete_power));
|
||||
if(bot->getOwner() != this->getClientDatabaseId()) {
|
||||
if(!permPower) return command_result{permission::i_client_music_delete_power};
|
||||
}
|
||||
@@ -6697,7 +6697,7 @@ command_result ConnectedClient::handleCommandMusicBotPlayerAction(Command& cmd)
|
||||
|
||||
auto bot = this->server->musicManager->findBotById(cmd["bot_id"]);
|
||||
if(!bot) return command_result{error::music_invalid_id};
|
||||
PERM_CHECK_CHANNELR(permission::i_client_music_play_power, bot->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_play_power, bot->currentChannel), this->currentChannel, true);
|
||||
PERM_CHECK_CHANNELR(permission::i_client_music_play_power, bot->permissionValue(permission::i_client_music_needed_play_power, bot->currentChannel), this->currentChannel, true);
|
||||
|
||||
if(cmd["action"] == 0) {
|
||||
bot->stopMusic();
|
||||
@@ -6963,7 +6963,7 @@ command_result ConnectedClient::handleCommandPlaylistAddPerm(ts::Command &cmd) {
|
||||
if(permission_require_granted_value(permType) && val > maxValue)
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, this->currentChannel))
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, this->currentChannel))
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
|
||||
if (grant) {
|
||||
@@ -6994,7 +6994,7 @@ command_result ConnectedClient::handleCommandPlaylistDelPerm(ts::Command &cmd) {
|
||||
for (int index = 0; index < cmd.bulkCount(); index++) {
|
||||
PARSE_PERMISSION(cmd);
|
||||
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permission::PERMTEST_ORDERED, permType, 1, this->currentChannel))
|
||||
if(!ignoreGrant && !this->permissionGrantGranted(permType, 1, this->currentChannel))
|
||||
return command_result{permission::i_permission_modify_power};
|
||||
|
||||
if (grant) {
|
||||
@@ -7128,7 +7128,7 @@ command_result ConnectedClient::handleCommandMusicBotQueueList(Command& cmd) {
|
||||
|
||||
auto bot = this->server->musicManager->findBotById(cmd["bot_id"]);
|
||||
if(!bot) return command_result{error::music_invalid_id};
|
||||
PERM_CHECK_CHANNELR(permission::i_client_music_info, bot->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_info, bot->currentChannel), this->currentChannel, true);
|
||||
PERM_CHECK_CHANNELR(permission::i_client_music_info, bot->permissionValue(permission::i_client_music_needed_info, bot->currentChannel), this->currentChannel, true);
|
||||
|
||||
|
||||
bool bulked = cmd.hasParm("bulk") || cmd.hasParm("balk") || cmd.hasParm("pipe") || cmd.hasParm("bar") || cmd.hasParm("paypal");
|
||||
@@ -7209,7 +7209,7 @@ command_result ConnectedClient::handleCommandMusicBotQueueAdd(Command& cmd) {
|
||||
|
||||
auto bot = this->server->musicManager->findBotById(cmd["bot_id"]);
|
||||
if(!bot) return command_result{error::music_invalid_id};
|
||||
PERM_CHECK_CHANNELR(permission::i_client_music_play_power, bot->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_play_power, bot->currentChannel), this->currentChannel, true);
|
||||
PERM_CHECK_CHANNELR(permission::i_client_music_play_power, bot->permissionValue(permission::i_client_music_needed_play_power, bot->currentChannel), this->currentChannel, true);
|
||||
|
||||
MusicClient::loader_t loader;
|
||||
auto& type = cmd[0]["type"];
|
||||
@@ -7245,7 +7245,7 @@ command_result ConnectedClient::handleCommandMusicBotQueueRemove(Command& cmd) {
|
||||
|
||||
auto bot = this->server->musicManager->findBotById(cmd["bot_id"]);
|
||||
if(!bot) return command_result{error::music_invalid_id};
|
||||
PERM_CHECK_CHANNELR(permission::i_client_music_play_power, bot->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_play_power, bot->currentChannel), this->currentChannel, true);
|
||||
PERM_CHECK_CHANNELR(permission::i_client_music_play_power, bot->permissionValue(permission::i_client_music_needed_play_power, bot->currentChannel), this->currentChannel, true);
|
||||
|
||||
std::deque<std::shared_ptr<music::SongInfo>> songs;
|
||||
for(int index = 0; index < cmd.bulkCount(); index++) {
|
||||
@@ -7277,7 +7277,7 @@ command_result ConnectedClient::handleCommandMusicBotQueueReorder(Command& cmd)
|
||||
|
||||
auto bot = this->server->musicManager->findBotById(cmd["bot_id"]);
|
||||
if(!bot) return command_result{error::music_invalid_id};
|
||||
PERM_CHECK_CHANNELR(permission::i_client_music_play_power, bot->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_play_power, bot->currentChannel), this->currentChannel, true);
|
||||
PERM_CHECK_CHANNELR(permission::i_client_music_play_power, bot->permissionValue(permission::i_client_music_needed_play_power, bot->currentChannel), this->currentChannel, true);
|
||||
|
||||
auto entry = bot->queue()->find_queue(cmd["song_id"]);
|
||||
if(!entry) return command_result{error::database_empty_result};
|
||||
@@ -7299,7 +7299,7 @@ command_result ConnectedClient::handleCommandMusicBotPlaylistAssign(ts::Command
|
||||
auto bot = ref_server->musicManager->findBotById(cmd["bot_id"]);
|
||||
if(!bot) return command_result{error::music_invalid_id};
|
||||
if(bot->getOwner() != this->getClientDatabaseId())
|
||||
PERM_CHECK_CHANNELR(permission::i_client_music_play_power, bot->permissionValue(permission::PERMTEST_ORDERED, permission::i_client_music_needed_play_power, bot->currentChannel), this->currentChannel, true);
|
||||
PERM_CHECK_CHANNELR(permission::i_client_music_play_power, bot->permissionValue(permission::i_client_music_needed_play_power, bot->currentChannel), this->currentChannel, true);
|
||||
|
||||
auto playlist = ref_server->musicManager->find_playlist(cmd["playlist_id"]);
|
||||
if(!playlist && cmd["playlist_id"] != 0) return command_result{error::playlist_invalid_id};
|
||||
@@ -7530,8 +7530,8 @@ command_result ConnectedClient::handleCommandQueryList(ts::Command &cmd) {
|
||||
if(!server && server_id != EmptyServerId && server_id != 0)
|
||||
return command_result{error::server_invalid_id};
|
||||
|
||||
auto global_list = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_query_list, 1, nullptr, true, nullptr, server, true);
|
||||
auto own_list = global_list || this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_query_list_own, 1, nullptr, true, nullptr, server, true);
|
||||
auto global_list = this->permissionGranted(permission::b_client_query_list, 1, nullptr, true, nullptr, server, true);
|
||||
auto own_list = global_list || this->permissionGranted(permission::b_client_query_list_own, 1, nullptr, true, nullptr, server, true);
|
||||
|
||||
if(!own_list && !global_list)
|
||||
return command_result{permission::b_client_query_list};
|
||||
@@ -7575,7 +7575,7 @@ command_result ConnectedClient::handleCommandQueryCreate(ts::Command &cmd) {
|
||||
if(!server && server_id != EmptyServerId && server_id != 0)
|
||||
return command_result{error::server_invalid_id};
|
||||
|
||||
if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_query_create, 1, nullptr, true, nullptr, server, true))
|
||||
if(!this->permissionGranted(permission::b_client_query_create, 1, nullptr, true, nullptr, server, true))
|
||||
return command_result{permission::b_client_query_create};
|
||||
|
||||
auto username = cmd["client_login_name"].as<string>();
|
||||
@@ -7613,8 +7613,8 @@ command_result ConnectedClient::handleCommandQueryDelete(ts::Command &cmd) {
|
||||
return command_result{error::server_invalid_id};
|
||||
*/
|
||||
|
||||
auto delete_all = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_query_delete, 1, nullptr, true, nullptr, server, true);
|
||||
auto delete_own = delete_all || this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_query_delete_own, 1, nullptr, true, nullptr, server, true);
|
||||
auto delete_all = this->permissionGranted(permission::b_client_query_delete, 1, nullptr, true, nullptr, server, true);
|
||||
auto delete_own = delete_all || this->permissionGranted(permission::b_client_query_delete_own, 1, nullptr, true, nullptr, server, true);
|
||||
|
||||
if(account->unique_id == this->getUid()) {
|
||||
if(!delete_own)
|
||||
@@ -7643,8 +7643,8 @@ command_result ConnectedClient::handleCommandQueryRename(ts::Command &cmd) {
|
||||
if(!server && account->bound_server != 0)
|
||||
return command_result{error::server_invalid_id};
|
||||
|
||||
auto rename_all = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_query_rename, 1, nullptr, true, nullptr, server, true);
|
||||
auto rename_own = rename_all || this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_query_rename_own, 1, nullptr, true, nullptr, server, true);
|
||||
auto rename_all = this->permissionGranted(permission::b_client_query_rename, 1, nullptr, true, nullptr, server, true);
|
||||
auto rename_own = rename_all || this->permissionGranted(permission::b_client_query_rename_own, 1, nullptr, true, nullptr, server, true);
|
||||
|
||||
if(account->unique_id == this->getUid()) {
|
||||
if(!rename_own)
|
||||
@@ -7676,8 +7676,8 @@ command_result ConnectedClient::handleCommandQueryChangePassword(ts::Command &cm
|
||||
if(!server && account->bound_server != 0)
|
||||
return command_result{error::server_invalid_id};
|
||||
|
||||
auto change_all = this->permissionGranted(permission::PERMTEST_ORDERED, server ? permission::b_client_query_change_password : permission::b_client_query_change_password_global, 1, nullptr, true, nullptr, server, true);
|
||||
auto change_own = change_all || this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_query_change_own_password, 1, nullptr, true, nullptr, server, true);
|
||||
auto change_all = this->permissionGranted(server ? permission::b_client_query_change_password : permission::b_client_query_change_password_global, 1, nullptr, true, nullptr, server, true);
|
||||
auto change_own = change_all || this->permissionGranted(permission::b_client_query_change_own_password, 1, nullptr, true, nullptr, server, true);
|
||||
|
||||
auto password = cmd[0].has("client_login_password") ? cmd["client_login_password"].as<string>() : "";
|
||||
|
||||
@@ -7707,7 +7707,7 @@ command_result ConnectedClient::handleCommandDummy_IpChange(ts::Command &cmd) {
|
||||
CMD_REF_SERVER(server);
|
||||
logMessage(this->getServerId(), "[{}] Address changed from {} to {}", CLIENT_STR_LOG_PREFIX, cmd["old_ip"].string(), cmd["new_ip"].string());
|
||||
|
||||
if(geoloc::provider_vpn && !this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_client_ignore_vpn, 1)) {
|
||||
if(geoloc::provider_vpn && !this->permissionGranted(permission::b_client_ignore_vpn, 1)) {
|
||||
auto provider = this->isAddressV4() ? geoloc::provider_vpn->resolveInfoV4(this->getPeerIp(), true) : geoloc::provider_vpn->resolveInfoV6(this->getPeerIp(), true);
|
||||
if(provider) {
|
||||
this->disconnect(strvar::transform(ts::config::messages::kick_vpn, strvar::StringValue{"provider.name", provider->name}, strvar::StringValue{"provider.website", provider->side}));
|
||||
@@ -7764,10 +7764,10 @@ command_result ConnectedClient::handleCommandConversationHistory(ts::Command &co
|
||||
command[0]["cpw"] = "";
|
||||
|
||||
if (!channel->passwordMatch(command["cpw"], true))
|
||||
if (!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_channel_join_ignore_password, 1, channel, true))
|
||||
if (!this->permissionGranted(permission::b_channel_join_ignore_password, 1, channel, true))
|
||||
return command_result{error::channel_invalid_password, "invalid password"};
|
||||
|
||||
if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_channel_ignore_join_power, 1, channel, true)) {
|
||||
if(!this->permissionGranted(permission::b_channel_ignore_join_power, 1, channel, true)) {
|
||||
CHANNEL_PERMISSION_TEST(permission::i_channel_join_power, permission::i_channel_needed_join_power, channel, false);
|
||||
}
|
||||
}
|
||||
@@ -7894,15 +7894,15 @@ command_result ConnectedClient::handleCommandConversationFetch(ts::Command &cmd)
|
||||
bulk["cpw"] = "";
|
||||
|
||||
if (!channel->passwordMatch(bulk["cpw"], true))
|
||||
if (!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_channel_join_ignore_password, 1, channel, true)) {
|
||||
if (!this->permissionGranted(permission::b_channel_join_ignore_password, 1, channel, true)) {
|
||||
auto error = findError("channel_invalid_password");
|
||||
result_bulk["error_id"] = error.errorId;
|
||||
result_bulk["error_msg"] = error.message;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_channel_ignore_join_power, 1, channel, true)) {
|
||||
auto permission_granted = this->calculate_permission_value(permission::i_channel_join_power, channel->channelId());
|
||||
if(!this->permissionGranted(permission::b_channel_ignore_join_power, 1, channel, true)) {
|
||||
auto permission_granted = this->calculate_permission(permission::i_channel_join_power, channel->channelId());
|
||||
if(!channel->permission_granted(permission::i_channel_needed_join_power, permission_granted, false)) {
|
||||
auto error = findError("server_insufficeient_permissions");
|
||||
result_bulk["error_id"] = error.errorId;
|
||||
@@ -7966,14 +7966,14 @@ command_result ConnectedClient::handleCommandConversationMessageDelete(ts::Comma
|
||||
bulk["cpw"] = "";
|
||||
|
||||
if (!channel->passwordMatch(bulk["cpw"], true))
|
||||
if (!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_channel_join_ignore_password, 1, channel, true))
|
||||
if (!this->permissionGranted(permission::b_channel_join_ignore_password, 1, channel, true))
|
||||
return command_result{error::channel_invalid_password};
|
||||
|
||||
if (!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_channel_conversation_message_delete, 1, channel))
|
||||
if (!this->permissionGranted(permission::b_channel_conversation_message_delete, 1, channel))
|
||||
return command_result{permission::b_channel_conversation_message_delete};
|
||||
|
||||
if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_channel_ignore_join_power, 1, channel, true)) {
|
||||
auto permission_granted = this->calculate_permission_value(permission::i_channel_join_power, channel->channelId());
|
||||
if(!this->permissionGranted(permission::b_channel_ignore_join_power, 1, channel, true)) {
|
||||
auto permission_granted = this->calculate_permission(permission::i_channel_join_power, channel->channelId());
|
||||
if(!channel->permission_granted(permission::i_channel_needed_join_power, permission_granted, false))
|
||||
return command_result{permission::i_channel_needed_join_power};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user