A lot of updates

This commit is contained in:
WolverinDEV 2020-02-22 14:14:44 +01:00
parent 41d3d30386
commit 86942e45c9
7 changed files with 43 additions and 17 deletions

View File

@ -314,7 +314,7 @@ GroupId GroupManager::copyGroup(std::shared_ptr<Group> group, GroupType type, st
auto groupId = generateGroupId(this->sql);
auto print = LOG_SQL_CMD;
auto res = sql::command(this->sql, "INSERT INTO `permissions` (`serverId`, `type`, `id`, `channelId`, `permId`, `value`, `grant`) SELECT :tsid AS `serverId`, `type`, :target AS `id`, 0 AS `channelId`, `permId`, `value`,`grant` FROM `permissions` WHERE `serverId` = :ssid AND `type` = :type AND `id` = :source",
auto res = sql::command(this->sql, "INSERT INTO `permissions` (`serverId`, `type`, `id`, `channelId`, `permId`, `value`, `grant`, `flag_skip`, `flag_negate`) SELECT :tsid AS `serverId`, `type`, :target AS `id`, 0 AS `channelId`, `permId`, `value`,`grant`,`flag_skip`, `flag_negate` FROM `permissions` WHERE `serverId` = :ssid AND `type` = :type AND `id` = :source",
variable{":target", groupId}, variable{":ssid", group_server}, variable{":tsid", targetServerId}, variable{":source", group->groupId()}, variable{":type", SQL_PERM_GROUP}).execute();
print(res);

View File

@ -161,6 +161,14 @@ InstanceHandler::InstanceHandler(SqlDataManager *sql) : sql(sql) {
this->properties()[property::SERVERINSTANCE_UNIQUE_ID] = ""; /* we def got a new instance */
}
if(this->default_tree->channel_count() == 4) {
auto default_channel = this->default_tree->findChannel("[cspacer04]Default Channel", nullptr);
if(default_channel) {
auto ch = this->default_tree->createChannel(0, default_channel->channelId(), "[cspacer05]Administrator Room");
ch->permissions()->set_permission(permission::i_channel_needed_view_power, {75, 0}, permission::v2::set_value, permission::v2::do_nothing, false, false);
this->save_channel_permissions();
}
}
if(!this->default_tree->getDefaultChannel()) this->default_tree->setDefaultChannel(this->default_tree->findChannel("[cspacer04]Default Channel", nullptr));
if(!this->default_tree->getDefaultChannel()) this->default_tree->setDefaultChannel(*this->default_tree->channels().begin());
assert(this->default_tree->getDefaultChannel());

View File

@ -560,14 +560,8 @@ bool ConnectedClient::notifyClientNeededPermissions() {
cache_lock.unlock();
for(const auto& value : permissions) {
if(value.second.has_value) {
cmd[index]["permid"] = value.first;
cmd[index++]["permvalue"] = value.second.value;
}
}
if(permissions.empty()) {
cmd[0]["permid"] = permission::b_client_force_push_to_talk;
cmd[0]["permvalue"] = false;
cmd[index]["permid"] = value.first;
cmd[index++]["permvalue"] = value.second.has_value ? value.second.value : 0;
}
this->sendCommand(cmd);

View File

@ -130,6 +130,8 @@ inline bool permission_require_granted_value(ts::permission::PermissionType type
case permission::i_icon_id:
case permission::i_max_icon_filesize:
case permission::i_client_max_avatar_filesize:
case permission::i_ft_quota_mb_download_per_client:
case permission::i_ft_quota_mb_upload_per_client:
case permission::i_client_max_channels:
case permission::i_client_max_permanent_channels:

View File

@ -303,8 +303,7 @@ command_result QueryClient::handleCommandServerSelect(Command &cmd) {
target = serverInstance->getVoiceServerManager()->findServerById(static_cast<ServerId>(stol(parm)));
if(!target && (!cmd[0].has("0") && (!cmd[0].has("sid") || !cmd["sid"] == 0))) return command_result{error::server_invalid_id, "Invalid server id"};
if(target && target->getState() != ServerState::ONLINE) return command_result{error::server_is_not_running};
if(target == this->server) return command_result{error::ok};
if(target) {
@ -375,8 +374,8 @@ command_result QueryClient::handleCommandServerSelect(Command &cmd) {
command_result QueryClient::handleCommandJoin(Command &) {
CMD_REQ_SERVER;
CMD_RESET_IDLE;
if(!this->server->running())
return command_result{error::server_is_not_running, "server isnt started yet"};
if(this->server->state != ServerState::ONLINE)
return command_result{error::server_is_not_running};
if(this->currentChannel)
return command_result{error::server_already_joined, "already joined!"};
@ -670,7 +669,18 @@ command_result QueryClient::handleCommandServerStart(Command& cmd) {
auto server = serverInstance->getVoiceServerManager()->findServerById(cmd["sid"]);
if(!server) return command_result{error::server_invalid_id, "invalid bounded server"};
if(server->running()) return command_result{error::server_running, "server already running"};
switch (server->state) {
case ServerState::BOOTING:
return command_result{error::server_is_booting};
case ServerState::ONLINE:
return command_result{error::server_running};
case ServerState::SUSPENDING:
return command_result{error::server_is_shutting_down};
case ServerState::DELETING:
return command_result{error::server_invalid_id};
case ServerState::OFFLINE: break;
}
if(!permission::v2::permission_granted(1, server->calculate_permission(permission::b_virtualserver_start, this->getClientDatabaseId(), ClientType::CLIENT_QUERY, 0)))
ACTION_REQUIRES_INSTANCE_PERMISSION(permission::b_virtualserver_start_any, 1);
@ -688,7 +698,17 @@ command_result QueryClient::handleCommandServerStop(Command& cmd) {
auto server = serverInstance->getVoiceServerManager()->findServerById(cmd["sid"]);
if(!server) return command_result{error::server_invalid_id, "invalid bounded server"};
if(!server->running()) return command_result{error::server_is_not_running, "server is not running"};
switch (server->state) {
case ServerState::BOOTING:
return command_result{error::server_is_booting};
case ServerState::OFFLINE:
return command_result{error::server_is_not_running};
case ServerState::SUSPENDING:
return command_result{error::server_is_shutting_down};
case ServerState::DELETING:
return command_result{error::server_invalid_id};
case ServerState::ONLINE: break;
}
if(!permission::v2::permission_granted(1, server->calculate_permission(permission::b_virtualserver_stop, this->getClientDatabaseId(), ClientType::CLIENT_QUERY, 0)))
ACTION_REQUIRES_INSTANCE_PERMISSION(permission::b_virtualserver_stop_any, 1);

View File

@ -61,7 +61,9 @@ VoiceBridge::VoiceBridge(const shared_ptr<WebClient>& owner) : _owner(owner) {
this->connection = make_unique<rtc::PeerConnection>(config);
}
VoiceBridge::~VoiceBridge() {}
VoiceBridge::~VoiceBridge() {
__asm__("nop");
}
int VoiceBridge::server_id() {
auto locked = this->_owner.lock();

View File

@ -25,7 +25,7 @@ namespace ts {
static void adjustTickPool();
MusicBotManager(const std::shared_ptr<server::VirtualServer>&);
explicit MusicBotManager(const std::shared_ptr<server::VirtualServer>&);
~MusicBotManager();
void load_bots();