A lot of updates for 1.4.12
This commit is contained in:
@@ -737,14 +737,14 @@ command_result ConnectedClient::handleCommandChannelCreate(Command &cmd) {
|
||||
if (prop == "cpid") continue;
|
||||
if (prop == "cid") continue;
|
||||
|
||||
const auto &property = property::info<property::ChannelProperties>(prop);
|
||||
if(*property == property::CHANNEL_UNDEFINED) {
|
||||
const auto &property = property::find<property::ChannelProperties>(prop);
|
||||
if(property == property::CHANNEL_UNDEFINED) {
|
||||
logError(this->getServerId(), "Client " + this->getDisplayName() + " tried to change a not existing channel property " + prop);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!property->validate_input(cmd[prop].as<string>())) {
|
||||
logError(this->getServerId(), "Client " + this->getDisplayName() + " tried to change a property to an invalid value. (Value: '" + cmd[prop].as<string>() + "', Property: '" + property->name + "')");
|
||||
if(!property.validate_input(cmd[prop].as<string>())) {
|
||||
logError(this->getServerId(), "Client " + this->getDisplayName() + " tried to change a property to an invalid value. (Value: '" + cmd[prop].as<string>() + "', Property: '" + std::string{property.name} + "')");
|
||||
continue;
|
||||
}
|
||||
created_channel->properties()[property] = cmd[prop].as<std::string>();
|
||||
@@ -847,7 +847,7 @@ command_result ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
return command_result{error::ok};
|
||||
}
|
||||
|
||||
std::deque<std::shared_ptr<property::PropertyDescription>> keys;
|
||||
std::deque<const property::PropertyDescription*> keys;
|
||||
bool require_write_lock = false;
|
||||
bool update_max_clients = false;
|
||||
bool update_max_family_clients = false;
|
||||
@@ -866,23 +866,23 @@ command_result ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
if(key == "return_code")
|
||||
continue;
|
||||
|
||||
const auto &property = property::info<property::ChannelProperties>(key);
|
||||
if(*property == property::CHANNEL_UNDEFINED) {
|
||||
const auto &property = property::find<property::ChannelProperties>(key);
|
||||
if(property == property::CHANNEL_UNDEFINED) {
|
||||
logError(this->getServerId(), R"({} Tried to edit a not existing channel property "{}" to "{}")", CLIENT_STR_LOG_PREFIX, key, cmd[key].string());
|
||||
continue;
|
||||
}
|
||||
|
||||
if((property->flags & property::FLAG_USER_EDITABLE) == 0) {
|
||||
if((property.flags & property::FLAG_USER_EDITABLE) == 0) {
|
||||
logError(this->getServerId(), "{} Tried to change a channel property which is not changeable. (Key: {}, Value: \"{}\")", CLIENT_STR_LOG_PREFIX, key, cmd[key].string());
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!property->validate_input(cmd[key].as<string>())) {
|
||||
if(!property.validate_input(cmd[key].as<string>())) {
|
||||
logError(this->getServerId(), "{} Tried to change a channel property to an invalid value. (Key: {}, Value: \"{}\")", CLIENT_STR_LOG_PREFIX, key, cmd[key].string());
|
||||
continue;
|
||||
}
|
||||
|
||||
if(channel->properties()[*property].as<string>() == cmd[key].as<string>())
|
||||
if(channel->properties()[property].as<string>() == cmd[key].as<string>())
|
||||
continue; /* we dont need to update stuff which is the same */
|
||||
|
||||
if(key == "channel_icon_id") {
|
||||
@@ -972,7 +972,7 @@ command_result ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
);
|
||||
continue;
|
||||
}
|
||||
keys.push_back(property);
|
||||
keys.push_back(&property);
|
||||
}
|
||||
|
||||
unique_lock server_channel_w_lock(this->server ? this->server->channel_tree_lock : serverInstance->getChannelTreeLock(), defer_lock);
|
||||
@@ -992,11 +992,11 @@ command_result ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
return command_result{error::parameter_missing};
|
||||
else
|
||||
cmd["channel_password"] = ""; /* no password set */
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_PASSWORD));
|
||||
keys.push_back(&property::describe(property::CHANNEL_PASSWORD));
|
||||
}
|
||||
if(!cmd[0].has("channel_flag_password")) {
|
||||
cmd["channel_flag_password"] = !cmd["channel_password"].string().empty();
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_FLAG_PASSWORD));
|
||||
keys.push_back(&property::describe(property::CHANNEL_FLAG_PASSWORD));
|
||||
}
|
||||
|
||||
if(cmd["channel_flag_password"].as<bool>()) {
|
||||
@@ -1019,20 +1019,20 @@ command_result ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
if((cmd[0].has("channel_flag_password") && cmd["channel_flag_password"].as<bool>()) || channel->properties()[property::CHANNEL_FLAG_PASSWORD]) {
|
||||
cmd["channel_flag_password"] = false;
|
||||
cmd["channel_password"] = "";
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_FLAG_PASSWORD));
|
||||
keys.push_back(&property::describe(property::CHANNEL_FLAG_PASSWORD));
|
||||
}
|
||||
|
||||
if(cmd[0].has("channel_flag_default")) {
|
||||
cmd["channel_maxclients"] = -1;
|
||||
cmd["channel_flag_maxclients_unlimited"] = true;
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_MAXCLIENTS));
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_FLAG_MAXCLIENTS_UNLIMITED));
|
||||
keys.push_back(&property::describe(property::CHANNEL_MAXCLIENTS));
|
||||
keys.push_back(&property::describe(property::CHANNEL_FLAG_MAXCLIENTS_UNLIMITED));
|
||||
update_max_clients = true;
|
||||
|
||||
cmd["channel_maxfamilyclients"] = -1;
|
||||
cmd["channel_flag_maxfamilyclients_inherited"] = true;
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_MAXFAMILYCLIENTS));
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_FLAG_MAXFAMILYCLIENTS_INHERITED));
|
||||
keys.push_back(&property::describe(property::CHANNEL_MAXFAMILYCLIENTS));
|
||||
keys.push_back(&property::describe(property::CHANNEL_FLAG_MAXFAMILYCLIENTS_INHERITED));
|
||||
update_max_family_clients = true;
|
||||
}
|
||||
}
|
||||
@@ -1043,15 +1043,15 @@ command_result ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
if(channel->properties()[property::CHANNEL_MAXCLIENTS].as<int>() != -1) {
|
||||
cmd["channel_maxclients"] = -1;
|
||||
cmd["channel_flag_maxclients_unlimited"] = true;
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_MAXCLIENTS));
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_FLAG_MAXCLIENTS_UNLIMITED));
|
||||
keys.push_back(&property::describe(property::CHANNEL_MAXCLIENTS));
|
||||
keys.push_back(&property::describe(property::CHANNEL_FLAG_MAXCLIENTS_UNLIMITED));
|
||||
update_max_clients = true;
|
||||
}
|
||||
if(channel->properties()[property::CHANNEL_MAXFAMILYCLIENTS].as<int>() != -1) {
|
||||
cmd["channel_maxfamilyclients"] = -1;
|
||||
cmd["channel_flag_maxfamilyclients_inherited"] = true;
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_MAXFAMILYCLIENTS));
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_FLAG_MAXFAMILYCLIENTS_INHERITED));
|
||||
keys.push_back(&property::describe(property::CHANNEL_MAXFAMILYCLIENTS));
|
||||
keys.push_back(&property::describe(property::CHANNEL_FLAG_MAXFAMILYCLIENTS_INHERITED));
|
||||
update_max_family_clients = true;
|
||||
}
|
||||
}
|
||||
@@ -1074,12 +1074,12 @@ command_result ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
cmd["channel_maxclients"] = -1;
|
||||
else
|
||||
return command_result{error::parameter_missing, "channel_maxclients"}; /* max clients must be specified */
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_MAXCLIENTS));
|
||||
keys.push_back(&property::describe(property::CHANNEL_MAXCLIENTS));
|
||||
}
|
||||
|
||||
if(!cmd[0].has("channel_flag_maxclients_unlimited")) {
|
||||
cmd["channel_flag_maxclients_unlimited"] = cmd["channel_maxclients"].as<int>() < 0;
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_FLAG_MAXCLIENTS_UNLIMITED));
|
||||
keys.push_back(&property::describe(property::CHANNEL_FLAG_MAXCLIENTS_UNLIMITED));
|
||||
}
|
||||
|
||||
if(cmd["channel_flag_maxclients_unlimited"].as<bool>() && cmd["channel_maxclients"].as<int>() != -1)
|
||||
@@ -1097,17 +1097,17 @@ command_result ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
cmd["channel_flag_maxfamilyclients_inherited"] = false;
|
||||
else
|
||||
cmd["channel_flag_maxfamilyclients_inherited"] = true;
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_FLAG_MAXFAMILYCLIENTS_INHERITED));
|
||||
keys.push_back(&property::describe(property::CHANNEL_FLAG_MAXFAMILYCLIENTS_INHERITED));
|
||||
} else if(cmd[0].has("channel_flag_maxfamilyclients_inherited")) {
|
||||
if(cmd["channel_flag_maxfamilyclients_inherited"].as<bool>())
|
||||
cmd["channel_flag_maxfamilyclients_unlimited"] = false;
|
||||
else
|
||||
cmd["channel_flag_maxfamilyclients_unlimited"] = true;
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_FLAG_MAXFAMILYCLIENTS_UNLIMITED));
|
||||
keys.push_back(&property::describe(property::CHANNEL_FLAG_MAXFAMILYCLIENTS_UNLIMITED));
|
||||
} else /* not really possible */
|
||||
return command_result{error::parameter_missing, "channel_maxfamilyclients"}; /* family max clients must be */
|
||||
cmd["channel_maxfamilyclients"] = -1;
|
||||
keys.push_back(property::info<property::ChannelProperties>(property::CHANNEL_MAXFAMILYCLIENTS));
|
||||
keys.push_back(&property::describe(property::CHANNEL_MAXFAMILYCLIENTS));
|
||||
}
|
||||
//keep this order because this command: "channeledit cid=<x> channel_maxfamilyclients=-1" should set max family clients mode to inherited
|
||||
if(!cmd[0].has("channel_flag_maxfamilyclients_inherited")) {
|
||||
@@ -1148,10 +1148,10 @@ command_result ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
auto self_ref = this->ref();
|
||||
shared_ptr<BasicChannel> old_default_channel;
|
||||
deque<shared_ptr<BasicChannel>> child_channel_updated;
|
||||
for(const std::shared_ptr<property::PropertyDescription>& key : keys) {
|
||||
for(const property::PropertyDescription* key : keys) {
|
||||
if(*key == property::CHANNEL_ORDER) {
|
||||
/* TODO: May move that up because if it fails may some other props have already be applied */
|
||||
if (!channel_tree->change_order(channel, cmd[key->name]))
|
||||
if (!channel_tree->change_order(channel, cmd[std::string{key->name}]))
|
||||
return command_result{error::channel_invalid_order, "Can't change order id"};
|
||||
|
||||
if(this->server) {
|
||||
@@ -1194,7 +1194,7 @@ command_result ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!cmd[key->name].as<bool>()) {
|
||||
if(!cmd[std::string{key->name}].as<bool>()) {
|
||||
old_default_channel = nullptr;
|
||||
continue;
|
||||
}
|
||||
@@ -1253,13 +1253,13 @@ command_result ConnectedClient::handleCommandChannelEdit(Command &cmd) {
|
||||
if(conversation_manager) {
|
||||
auto conversation = conversation_manager->get(channel->channelId());
|
||||
if(conversation)
|
||||
conversation->set_history_length(cmd[key->name]);
|
||||
conversation->set_history_length(cmd[std::string{key->name}]);
|
||||
}
|
||||
} else if(*key == property::CHANNEL_NEEDED_TALK_POWER) {
|
||||
channel->permissions()->set_permission(permission::i_client_needed_talk_power, {cmd[key->name].as<int>(), 0}, permission::v2::set_value, permission::v2::do_nothing);
|
||||
}
|
||||
|
||||
channel->properties()[key] = cmd[key->name].string();
|
||||
channel->properties()[*key] = cmd[std::string{key->name}].string();
|
||||
}
|
||||
if(this->server) {
|
||||
vector<property::ChannelProperties> key_vector;
|
||||
|
||||
@@ -44,9 +44,9 @@ command_result ConnectedClient::handleCommandClientGetVariables(Command &cmd) {
|
||||
if (!client || (client.client != this && !this->isClientVisible(client.client, false)))
|
||||
return command_result{error::client_invalid_id, ""};
|
||||
|
||||
deque<shared_ptr<property::PropertyDescription>> props;
|
||||
deque<const property::PropertyDescription*> props;
|
||||
for (auto &prop : client->properties()->list_properties(property::FLAG_CLIENT_VARIABLE, this->getType() == CLIENT_TEAMSPEAK ? property::FLAG_NEW : (uint16_t) 0)) {
|
||||
props.push_back(property::info((property::ClientProperties) prop.type().property_index));
|
||||
props.push_back(&prop.type());
|
||||
}
|
||||
|
||||
this->notifyClientUpdated(client.client, props, false);
|
||||
@@ -391,13 +391,13 @@ command_result ConnectedClient::handleCommandClientDBEdit(Command &cmd) {
|
||||
for (auto &elm : cmd[0].keys()) {
|
||||
if (elm == "cldbid") continue;
|
||||
|
||||
auto info = property::info<property::ClientProperties>(elm);
|
||||
if(*info == property::CLIENT_UNDEFINED) {
|
||||
const auto& info = property::find<property::ClientProperties>(elm);
|
||||
if(info == property::CLIENT_UNDEFINED) {
|
||||
logError(this->getServerId(), "Client " + this->getDisplayName() + " tried to change someone's db entry, but the entry in unknown: " + elm);
|
||||
continue;
|
||||
}
|
||||
if(!info->validate_input(cmd[elm].as<string>())) {
|
||||
logError(this->getServerId(), "Client " + this->getDisplayName() + " tried to change a property to an invalid value. (Value: '" + cmd[elm].as<string>() + "', Property: '" + info->name + "')");
|
||||
if(!info.validate_input(cmd[elm].as<string>())) {
|
||||
logError(this->getServerId(), "Client " + this->getDisplayName() + " tried to change a property to an invalid value. (Value: '" + cmd[elm].as<string>() + "', Property: '" + std::string{info.name} + "')");
|
||||
continue;
|
||||
}
|
||||
(*props)[info] = cmd[elm].string();
|
||||
@@ -423,29 +423,29 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
|
||||
bool update_talk_rights = false;
|
||||
unique_ptr<lock_guard<std::recursive_mutex>> nickname_lock;
|
||||
deque<pair<property::ClientProperties, string>> keys;
|
||||
std::deque<std::pair<const property::PropertyDescription*, std::string>> keys;
|
||||
for(const auto& key : cmd[0].keys()) {
|
||||
if(key == "return_code") continue;
|
||||
if(key == "clid") continue;
|
||||
|
||||
const auto &info = property::info<property::ClientProperties>(key);
|
||||
if(*info == property::CLIENT_UNDEFINED) {
|
||||
const auto &info = property::find<property::ClientProperties>(key);
|
||||
if(info == property::CLIENT_UNDEFINED) {
|
||||
logError(this->getServerId(), R"([{}] Tried to change a not existing client property for {}. (Key: "{}", Value: "{}"))", CLIENT_STR_LOG_PREFIX, CLIENT_STR_LOG_PREFIX_(client), key, cmd[key].string());
|
||||
continue;
|
||||
}
|
||||
|
||||
if((info->flags & property::FLAG_USER_EDITABLE) == 0) {
|
||||
if((info.flags & property::FLAG_USER_EDITABLE) == 0) {
|
||||
logError(this->getServerId(), R"([{}] Tried to change a not user editable client property for {}. (Key: "{}", Value: "{}"))", CLIENT_STR_LOG_PREFIX, CLIENT_STR_LOG_PREFIX_(client), key, cmd[key].string());
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!info->validate_input(cmd[key].as<string>())) {
|
||||
if(!info.validate_input(cmd[key].as<string>())) {
|
||||
logError(this->getServerId(), R"([{}] Tried to change a client property to an invalid value for {}. (Key: "{}", Value: "{}"))", CLIENT_STR_LOG_PREFIX, CLIENT_STR_LOG_PREFIX_(client), key, cmd[key].string());
|
||||
continue;
|
||||
}
|
||||
if(client->properties()[info].as<string>() == cmd[key].as<string>()) continue;
|
||||
if(client->properties()[&info].as<string>() == cmd[key].as<string>()) continue;
|
||||
|
||||
if (*info == property::CLIENT_DESCRIPTION) {
|
||||
if (info == property::CLIENT_DESCRIPTION) {
|
||||
if (self) {
|
||||
ACTION_REQUIRES_PERMISSION(permission::b_client_modify_own_description, 1, client->getChannelId());
|
||||
} else if(client->getType() == ClientType::CLIENT_MUSIC) {
|
||||
@@ -458,16 +458,16 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
|
||||
string value = cmd["client_description"].string();
|
||||
if (count_characters(value) > 200) return command_result{error::parameter_invalid, "Invalid description length. A maximum of 200 characters is allowed!"};
|
||||
} else if (*info == property::CLIENT_IS_TALKER) {
|
||||
} else if (info == property::CLIENT_IS_TALKER) {
|
||||
ACTION_REQUIRES_PERMISSION(permission::b_client_set_flag_talker, 1, client->getChannelId());
|
||||
cmd["client_is_talker"] = cmd["client_is_talker"].as<bool>();
|
||||
cmd["client_talk_request"] = 0;
|
||||
update_talk_rights = true;
|
||||
|
||||
keys.emplace_back(property::CLIENT_IS_TALKER, "client_is_talker");
|
||||
keys.emplace_back(property::CLIENT_TALK_REQUEST, "client_talk_request");
|
||||
keys.emplace_back(&property::describe(property::CLIENT_IS_TALKER), "client_is_talker");
|
||||
keys.emplace_back(&property::describe(property::CLIENT_TALK_REQUEST), "client_talk_request");
|
||||
continue;
|
||||
} else if(*info == property::CLIENT_NICKNAME) {
|
||||
} else if(info == property::CLIENT_NICKNAME) {
|
||||
if(!self) {
|
||||
if(client->getType() != ClientType::CLIENT_MUSIC) return command_result{error::client_invalid_type};
|
||||
if(client->properties()[property::CLIENT_OWNER] != this->getClientDatabaseId()) {
|
||||
@@ -500,7 +500,7 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else if(*info == property::CLIENT_PLAYER_VOLUME) {
|
||||
} 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()) {
|
||||
ACTION_REQUIRES_PERMISSION(permission::i_client_music_modify_power, client->calculate_permission(permission::i_client_music_needed_modify_power, client->getChannelId()), client->getChannelId());
|
||||
@@ -515,7 +515,7 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
return command_result{permission::i_client_music_create_modify_max_volume};
|
||||
|
||||
bot->volume_modifier(cmd["player_volume"]);
|
||||
} else if(*info == property::CLIENT_IS_CHANNEL_COMMANDER) {
|
||||
} else if(info == property::CLIENT_IS_CHANNEL_COMMANDER) {
|
||||
if(!self) {
|
||||
if(client->getType() != ClientType::CLIENT_MUSIC) return command_result{error::client_invalid_type};
|
||||
if(client->properties()[property::CLIENT_OWNER] != this->getClientDatabaseId()) {
|
||||
@@ -525,7 +525,7 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
|
||||
if(cmd["client_is_channel_commander"].as<bool>())
|
||||
ACTION_REQUIRES_PERMISSION(permission::b_client_use_channel_commander, 1, client->getChannelId());
|
||||
} else if(*info == property::CLIENT_IS_PRIORITY_SPEAKER) {
|
||||
} else if(info == property::CLIENT_IS_PRIORITY_SPEAKER) {
|
||||
//FIXME allow other to remove this thing
|
||||
if(!self) {
|
||||
if(client->getType() != ClientType::CLIENT_MUSIC)
|
||||
@@ -544,7 +544,7 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
cmd["client_talk_request"] = duration_cast<seconds>(system_clock::now().time_since_epoch()).count();
|
||||
else
|
||||
cmd["client_talk_request"] = 0;
|
||||
keys.emplace_back(property::CLIENT_TALK_REQUEST, "client_talk_request");
|
||||
keys.emplace_back(&property::describe(property::CLIENT_TALK_REQUEST), "client_talk_request");
|
||||
continue;
|
||||
} else if (self && key == "client_badges") {
|
||||
std::string str = cmd[key];
|
||||
@@ -576,7 +576,7 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
if(client->properties()[property::CLIENT_OWNER] != this->getClientDatabaseId()) {
|
||||
ACTION_REQUIRES_PERMISSION(permission::i_client_music_modify_power, client->calculate_permission(permission::i_client_music_needed_modify_power, client->getChannelId()), client->getChannelId());
|
||||
}
|
||||
} else if(!self && (*info == property::CLIENT_FLAG_NOTIFY_SONG_CHANGE/* || *info == property::CLIENT_NOTIFY_SONG_MESSAGE*/)) {
|
||||
} 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()) {
|
||||
ACTION_REQUIRES_PERMISSION(permission::i_client_music_modify_power, client->calculate_permission(permission::i_client_music_needed_modify_power, client->getChannelId()), client->getChannelId());
|
||||
@@ -596,8 +596,8 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
cmd["client_lastconnected"] = value;
|
||||
}
|
||||
|
||||
keys.emplace_back(property::CLIENT_LASTCONNECTED, "client_lastconnected");
|
||||
} else if(!self && *info == property::CLIENT_BOT_TYPE) {
|
||||
keys.emplace_back(&property::describe(property::CLIENT_LASTCONNECTED), "client_lastconnected");
|
||||
} else if(!self && info == property::CLIENT_BOT_TYPE) {
|
||||
ACTION_REQUIRES_PERMISSION(permission::i_client_music_modify_power, client->calculate_permission(permission::i_client_music_needed_modify_power, client->getChannelId()), client->getChannelId());
|
||||
auto type = cmd["client_bot_type"].as<MusicClient::Type::value>();
|
||||
if(type == MusicClient::Type::TEMPORARY) {
|
||||
@@ -608,7 +608,7 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
ACTION_REQUIRES_PERMISSION(permission::b_client_music_modify_permanent, 1, client->getChannelId());
|
||||
} else
|
||||
return command_result{error::parameter_invalid};
|
||||
} else if(*info == property::CLIENT_AWAY_MESSAGE) {
|
||||
} else if(info == property::CLIENT_AWAY_MESSAGE) {
|
||||
if(!self) continue;
|
||||
|
||||
if(cmd["client_away_message"].string().length() > 256)
|
||||
@@ -617,12 +617,12 @@ command_result ConnectedClient::handleCommandClientEdit(Command &cmd, const std:
|
||||
continue;
|
||||
}
|
||||
|
||||
keys.emplace_back((property::ClientProperties) info->property_index, key);
|
||||
keys.emplace_back(&info, key);
|
||||
}
|
||||
|
||||
deque<property::ClientProperties> updates;
|
||||
deque<const property::PropertyDescription*> updates;
|
||||
for(const auto& key : keys) {
|
||||
if(key.first == property::CLIENT_IS_PRIORITY_SPEAKER) {
|
||||
if(*key.first == property::CLIENT_IS_PRIORITY_SPEAKER) {
|
||||
client->clientPermissions->set_permission(permission::b_client_is_priority_speaker, {1, 0}, cmd["client_is_priority_speaker"].as<bool>() ? permission::v2::PermissionUpdateType::set_value : permission::v2::PermissionUpdateType::delete_value, permission::v2::PermissionUpdateType::do_nothing);
|
||||
}
|
||||
client->properties()[key.first] = cmd[0][key.second].value();
|
||||
@@ -1116,7 +1116,7 @@ command_result ConnectedClient::handleCommandClientInfo(Command &cmd) {
|
||||
}
|
||||
|
||||
for (const auto &key : client->properties()->list_properties(property::FLAG_CLIENT_VIEW | property::FLAG_CLIENT_VARIABLE | property::FLAG_CLIENT_INFO, this->getType() == CLIENT_TEAMSPEAK ? property::FLAG_NEW : (uint16_t) 0))
|
||||
res[result_index][key.type().name] = key.value();
|
||||
res[result_index][std::string{key.type().name}] = key.value();
|
||||
if(view_remote)
|
||||
res[result_index]["connection_client_ip"] = client->properties()[property::CONNECTION_CLIENT_IP].as<string>();
|
||||
else
|
||||
|
||||
@@ -366,7 +366,7 @@ command_result ConnectedClient::handleCommandPermissionList(Command &cmd) {
|
||||
|
||||
#define M(ptype) \
|
||||
do { \
|
||||
for(const auto& prop : property::impl::list<ptype>()) { \
|
||||
for(const auto& prop : property::list<ptype>()) { \
|
||||
if((prop->flags & property::FLAG_INTERNAL) > 0) continue; \
|
||||
response[index]["name"] = prop->name; \
|
||||
response[index]["flags"] = prop->flags; \
|
||||
|
||||
@@ -447,41 +447,41 @@ command_result ConnectedClient::handleCommandPlaylistEdit(ts::Command &cmd) {
|
||||
if(auto perr = playlist->client_has_permissions(this->ref(), permission::i_playlist_needed_modify_power, permission::i_playlist_modify_power); perr)
|
||||
return command_result{perr};
|
||||
|
||||
deque<pair<shared_ptr<property::PropertyDescription>, string>> properties;
|
||||
deque<pair<const property::PropertyDescription*, string>> properties;
|
||||
|
||||
for(const auto& key : cmd[0].keys()) {
|
||||
if(key == "playlist_id") continue;
|
||||
if(key == "return_code") continue;
|
||||
|
||||
auto property = property::info<property::PlaylistProperties>(key);
|
||||
if(*property == property::PLAYLIST_UNDEFINED) {
|
||||
const auto& property = property::find<property::PlaylistProperties>(key);
|
||||
if(property == property::PLAYLIST_UNDEFINED) {
|
||||
logError(this->getServerId(), R"([{}] Tried to edit a not existing playlist property "{}" to "{}")", CLIENT_STR_LOG_PREFIX, key, cmd[key].string());
|
||||
continue;
|
||||
}
|
||||
|
||||
if((property->flags & property::FLAG_USER_EDITABLE) == 0) {
|
||||
if((property.flags & property::FLAG_USER_EDITABLE) == 0) {
|
||||
logError(this->getServerId(), "[{}] Tried to change a playlist property which is not changeable. (Key: {}, Value: \"{}\")", CLIENT_STR_LOG_PREFIX, key, cmd[key].string());
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!property->validate_input(cmd[key].as<string>())) {
|
||||
if(!property.validate_input(cmd[key].as<string>())) {
|
||||
logError(this->getServerId(), "[{}] Tried to change a playlist property to an invalid value. (Key: {}, Value: \"{}\")", CLIENT_STR_LOG_PREFIX, key, cmd[key].string());
|
||||
continue;
|
||||
}
|
||||
|
||||
if(*property == property::PLAYLIST_CURRENT_SONG_ID) {
|
||||
if(property == property::PLAYLIST_CURRENT_SONG_ID) {
|
||||
auto song_id = cmd[key].as<SongId>();
|
||||
auto song = song_id > 0 ? playlist->find_song(song_id) : nullptr;
|
||||
if(song_id != 0 && !song)
|
||||
return command_result{error::playlist_invalid_song_id};
|
||||
} else if(*property == property::PLAYLIST_MAX_SONGS) {
|
||||
} else if(property == property::PLAYLIST_MAX_SONGS) {
|
||||
auto value = cmd[key].as<int32_t>();
|
||||
auto max_value = this->calculate_permission(permission::i_max_playlist_size, this->getChannelId());
|
||||
if(max_value.has_value && !permission::v2::permission_granted(value, max_value))
|
||||
return command_result{permission::i_max_playlist_size};
|
||||
}
|
||||
|
||||
properties.emplace_back(property, key);
|
||||
properties.emplace_back(&property, key);
|
||||
}
|
||||
for(const auto& property : properties) {
|
||||
if(*property.first == property::PLAYLIST_CURRENT_SONG_ID) {
|
||||
|
||||
@@ -224,14 +224,14 @@ command_result ConnectedClient::handleCommandServerEdit(Command &cmd) {
|
||||
std::deque<std::string> keys;
|
||||
bool group_update = false;
|
||||
for (const auto& elm : toApplay) {
|
||||
auto info = property::impl::info<property::VirtualServerProperties>(elm.first);
|
||||
if(*info == property::VIRTUALSERVER_UNDEFINED) {
|
||||
const auto& info = property::find<property::VirtualServerProperties>(elm.first);
|
||||
if(info == property::VIRTUALSERVER_UNDEFINED) {
|
||||
logCritical(target_server ? target_server->getServerId() : 0, "Missing server property " + elm.first);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!info->validate_input(elm.second)) {
|
||||
logError(target_server ? target_server->getServerId() : 0, "Client " + this->getDisplayName() + " tried to change a property to an invalid value. (Value: '" + elm.second + "', Property: '" + info->name + "')");
|
||||
if(!info.validate_input(elm.second)) {
|
||||
logError(target_server ? target_server->getServerId() : 0, "Client " + this->getDisplayName() + " tried to change a property to an invalid value. (Value: '" + elm.second + "', Property: '" + std::string{info.name} + "')");
|
||||
continue;
|
||||
}
|
||||
if(target_server)
|
||||
@@ -240,7 +240,7 @@ command_result ConnectedClient::handleCommandServerEdit(Command &cmd) {
|
||||
(*serverInstance->getDefaultServerProperties())[info] = elm.second;
|
||||
keys.push_back(elm.first);
|
||||
|
||||
group_update |= *info == property::VIRTUALSERVER_DEFAULT_SERVER_GROUP || *info == property::VIRTUALSERVER_DEFAULT_CHANNEL_GROUP || *info == property::VIRTUALSERVER_DEFAULT_MUSIC_GROUP;
|
||||
group_update |= info == property::VIRTUALSERVER_DEFAULT_SERVER_GROUP || info == property::VIRTUALSERVER_DEFAULT_CHANNEL_GROUP || info == property::VIRTUALSERVER_DEFAULT_MUSIC_GROUP;
|
||||
}
|
||||
|
||||
if(target_server) {
|
||||
@@ -262,35 +262,39 @@ command_result ConnectedClient::handleCommandServerRequestConnectionInfo(Command
|
||||
CMD_REQ_SERVER;
|
||||
ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_virtualserver_connectioninfo_view, 1);
|
||||
|
||||
Command notify("notifyserverconnectioninfo");
|
||||
ts::command_builder result{"notifyserverconnectioninfo"};
|
||||
auto first_bulk = result.bulk(0);
|
||||
|
||||
auto statistics = this->server->getServerStatistics()->statistics();
|
||||
auto report = this->server->getServerStatistics()->dataReport();
|
||||
auto total_stats = this->server->getServerStatistics()->total_stats();
|
||||
auto minute_report = this->server->getServerStatistics()->minute_stats();
|
||||
auto second_report = this->server->getServerStatistics()->second_stats();
|
||||
auto network_report = this->server->generate_network_report();
|
||||
|
||||
notify[0]["connection_filetransfer_bandwidth_sent"] = report.file_send;
|
||||
notify[0]["connection_filetransfer_bandwidth_received"] = report.file_recv;
|
||||
first_bulk.put_unchecked(property::CONNECTION_FILETRANSFER_BANDWIDTH_SENT, minute_report.file_bytes_sent);
|
||||
first_bulk.put_unchecked(property::CONNECTION_FILETRANSFER_BANDWIDTH_RECEIVED, minute_report.file_bytes_received);
|
||||
|
||||
notify[0]["connection_filetransfer_bytes_sent_total"] = (*statistics)[property::CONNECTION_FILETRANSFER_BYTES_SENT_TOTAL].as<string>();
|
||||
notify[0]["connection_filetransfer_bytes_received_total"] = (*statistics)[property::CONNECTION_FILETRANSFER_BYTES_RECEIVED_TOTAL].as<string>();
|
||||
first_bulk.put_unchecked(property::CONNECTION_FILETRANSFER_BYTES_SENT_TOTAL, minute_report.file_bytes_sent);
|
||||
first_bulk.put_unchecked(property::CONNECTION_FILETRANSFER_BYTES_RECEIVED_TOTAL, minute_report.file_bytes_received);
|
||||
|
||||
notify[0]["connection_filetransfer_bytes_sent_month"] = this->server->properties()[property::VIRTUALSERVER_MONTH_BYTES_DOWNLOADED].as<string>();
|
||||
notify[0]["connection_filetransfer_bytes_received_month"] = this->server->properties()[property::VIRTUALSERVER_MONTH_BYTES_UPLOADED].as<string>();
|
||||
first_bulk.put_unchecked("connection_filetransfer_bytes_sent_month", this->server->properties()[property::VIRTUALSERVER_MONTH_BYTES_DOWNLOADED].as<string>());
|
||||
first_bulk.put_unchecked("connection_filetransfer_bytes_received_month", this->server->properties()[property::VIRTUALSERVER_MONTH_BYTES_UPLOADED].as<string>());
|
||||
|
||||
notify[0]["connection_packets_sent_total"] = (*statistics)[property::CONNECTION_PACKETS_SENT_TOTAL].as<string>();
|
||||
notify[0]["connection_bytes_sent_total"] = (*statistics)[property::CONNECTION_BYTES_SENT_TOTAL].as<string>();
|
||||
notify[0]["connection_packets_received_total"] = (*statistics)[property::CONNECTION_PACKETS_RECEIVED_TOTAL].as<string>();
|
||||
notify[0]["connection_bytes_received_total"] = (*statistics)[property::CONNECTION_BYTES_RECEIVED_TOTAL].as<string>();
|
||||
first_bulk.put_unchecked(property::CONNECTION_PACKETS_SENT_TOTAL, std::accumulate(total_stats.connection_packets_sent.begin(), total_stats.connection_packets_sent.end(), 0U));
|
||||
first_bulk.put_unchecked(property::CONNECTION_BYTES_SENT_TOTAL, std::accumulate(total_stats.connection_bytes_sent.begin(), total_stats.connection_bytes_sent.end(), 0U));
|
||||
first_bulk.put_unchecked(property::CONNECTION_PACKETS_RECEIVED_TOTAL, std::accumulate(total_stats.connection_packets_received.begin(), total_stats.connection_packets_received.end(), 0U));
|
||||
first_bulk.put_unchecked(property::CONNECTION_BYTES_RECEIVED_TOTAL, std::accumulate(total_stats.connection_bytes_received.begin(), total_stats.connection_bytes_received.end(), 0U));
|
||||
|
||||
notify[0]["connection_bandwidth_sent_last_second_total"] = report.send_second;
|
||||
notify[0]["connection_bandwidth_sent_last_minute_total"] = report.send_minute;
|
||||
notify[0]["connection_bandwidth_received_last_second_total"] = report.recv_second;
|
||||
notify[0]["connection_bandwidth_received_last_minute_total"] = report.recv_minute;
|
||||
|
||||
notify[0]["connection_connected_time"] = this->server->properties()[property::VIRTUALSERVER_UPTIME].as<string>();
|
||||
notify[0]["connection_packetloss_total"] = this->server->averagePacketLoss();
|
||||
notify[0]["connection_ping"] = this->server->averagePing();
|
||||
first_bulk.put_unchecked(property::CONNECTION_BANDWIDTH_SENT_LAST_SECOND_TOTAL, std::accumulate(second_report.connection_bytes_sent.begin(), second_report.connection_bytes_sent.end(), 0U));
|
||||
first_bulk.put_unchecked(property::CONNECTION_BANDWIDTH_SENT_LAST_MINUTE_TOTAL, std::accumulate(minute_report.connection_bytes_sent.begin(), minute_report.connection_bytes_sent.end(), 0U));
|
||||
first_bulk.put_unchecked(property::CONNECTION_BANDWIDTH_RECEIVED_LAST_SECOND_TOTAL, std::accumulate(second_report.connection_bytes_received.begin(), second_report.connection_bytes_received.end(), 0U));
|
||||
first_bulk.put_unchecked(property::CONNECTION_BANDWIDTH_RECEIVED_LAST_MINUTE_TOTAL, std::accumulate(minute_report.connection_bytes_received.begin(), minute_report.connection_bytes_received.end(), 0U));
|
||||
|
||||
this->sendCommand(notify);
|
||||
first_bulk.put_unchecked(property::CONNECTION_CONNECTED_TIME, this->server->properties()[property::VIRTUALSERVER_UPTIME].as<string>());
|
||||
first_bulk.put_unchecked(property::CONNECTION_PACKETLOSS_TOTAL, network_report.average_loss);
|
||||
first_bulk.put_unchecked(property::CONNECTION_PING, network_report.average_ping);
|
||||
|
||||
this->sendCommand(result);
|
||||
return command_result{error::ok};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user