diff --git a/git-teaspeak b/git-teaspeak index b36b1e1..a1530bc 160000 --- a/git-teaspeak +++ b/git-teaspeak @@ -1 +1 @@ -Subproject commit b36b1e19aeb8bd5026437d2bb0b4d91c480ed65b +Subproject commit a1530bc0ffa4566d4d601ada07a33fd8ea9f7078 diff --git a/server/src/client/command_handler/channel.cpp b/server/src/client/command_handler/channel.cpp index c95c4cd..b360457 100644 --- a/server/src/client/command_handler/channel.cpp +++ b/server/src/client/command_handler/channel.cpp @@ -163,12 +163,29 @@ command_result ConnectedClient::handleCommandChannelGroupAdd(Command &cmd) { auto group = group_manager->createGroup(GroupTarget::GROUPTARGET_CHANNEL, cmd["type"].as(), cmd["name"].string()); serverInstance->action_logger()->group_logger.log_group_create(this->getServerId(), this->ref(), log::GroupTarget::CHANNEL, log_group_type, group->groupId(), group->name(), 0, ""); + { + ts::command_builder notify{this->notify_response_command("notifychannelgroupadded")}; + notify.put_unchecked(0, "cgid", group->groupId()); + this->sendCommand(notify); + } + if (group) { group->permissions()->set_permission(permission::b_group_is_permanent, {1, 0}, permission::v2::set_value, permission::v2::do_nothing); - if(this->server) - this->server->forEachClient([](shared_ptr cl) { - cl->notifyChannelGroupList(); - }); + if(this->server) { + if(this->getType() == ClientType::CLIENT_QUERY) { + this->server->forEachClient([&](const std::shared_ptr& cl) { + if(cl == this) { + return; + } + + cl->notifyChannelGroupList(); + }); + } else { + this->server->forEachClient([](const std::shared_ptr& cl) { + cl->notifyChannelGroupList(); + }); + } + } } else return command_result{error::group_invalid_id}; return command_result{error::ok}; } diff --git a/server/src/client/command_handler/server.cpp b/server/src/client/command_handler/server.cpp index e53da16..0d8faf7 100644 --- a/server/src/client/command_handler/server.cpp +++ b/server/src/client/command_handler/server.cpp @@ -304,9 +304,15 @@ command_result ConnectedClient::handleCommandServerGroupAdd(Command &cmd) { CMD_CHK_AND_INC_FLOOD_POINTS(5); ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_virtualserver_servergroup_create, 1); - if(cmd["name"].string().empty()) return command_result{error::parameter_invalid}; + if(cmd["name"].string().empty()) { + return command_result{error::parameter_invalid, "name"}; + } log::GroupType log_group_type; + if(!cmd[0].has("type")) { + cmd["type"] = GroupType::GROUP_TYPE_NORMAL; + } + if(cmd["type"].as() == GroupType::GROUP_TYPE_QUERY) { ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_serverinstance_modify_querygroup, 1); log_group_type = log::GroupType::QUERY; @@ -321,17 +327,39 @@ command_result ConnectedClient::handleCommandServerGroupAdd(Command &cmd) { } auto group_manager = this->server ? this->server->getGroupManager() : serverInstance->getGroupManager().get(); - for(const auto& gr : group_manager->availableServerGroups(true)) - if(gr->name() == cmd["name"].string() && gr->target() == GroupTarget::GROUPTARGET_SERVER) return command_result{error::parameter_invalid, "Group already exists"}; + for(const auto& gr : group_manager->availableServerGroups(true)) { + if(gr->name() == cmd["name"].string() && gr->target() == GroupTarget::GROUPTARGET_SERVER) { + return command_result{error::parameter_invalid, "Group already exists"}; + } + } + auto group = group_manager->createGroup(GroupTarget::GROUPTARGET_SERVER, cmd["type"].as(), cmd["name"].string()); - if(!group) + if(!group) { return command_result{error::vs_critical}; + } group->permissions()->set_permission(permission::b_group_is_permanent, {1,0}, permission::v2::set_value, permission::v2::do_nothing); + + { + ts::command_builder notify{this->notify_response_command("notifyservergroupadded")}; + notify.put_unchecked(0, "sgid", group->groupId()); + this->sendCommand(notify); + } + if(this->server) { - this->server->forEachClient([](shared_ptr cl) { - cl->notifyServerGroupList(); - }); + if(this->getType() == ClientType::CLIENT_QUERY) { + this->server->forEachClient([&](const shared_ptr& cl) { + if(cl == this) { + return; + } + + cl->notifyServerGroupList(); + }); + } else { + this->server->forEachClient([&](const shared_ptr& cl) { + cl->notifyServerGroupList(); + }); + } } serverInstance->action_logger()->group_logger.log_group_create(this->getServerId(), this->ref(), log::GroupTarget::SERVER, log_group_type, group->groupId(), group->name(), 0, ""); return command_result{error::ok};