A lot of updates
This commit is contained in:
@@ -228,6 +228,9 @@ command_result ConnectedClient::handleCommand(Command &cmd) {
|
||||
else if (command == "playlistpermlist") return this->handleCommandPlaylistPermList(cmd);
|
||||
else if (command == "playlistaddperm") return this->handleCommandPlaylistAddPerm(cmd);
|
||||
else if (command == "playlistdelperm") return this->handleCommandPlaylistDelPerm(cmd);
|
||||
else if (command == "playlistclientpermlist") return this->handleCommandPlaylistClientPermList(cmd);
|
||||
else if (command == "playlistclientaddperm") return this->handleCommandPlaylistClientAddPerm(cmd);
|
||||
else if (command == "playlistclientdelperm") return this->handleCommandPlaylistClientDelPerm(cmd);
|
||||
else if (command == "playlistinfo") return this->handleCommandPlaylistInfo(cmd);
|
||||
else if (command == "playlistedit") return this->handleCommandPlaylistEdit(cmd);
|
||||
|
||||
@@ -256,13 +259,13 @@ command_result ConnectedClient::handleCommandGetConnectionInfo(Command &cmd) {
|
||||
CMD_REQ_SERVER;
|
||||
CMD_CHK_AND_INC_FLOOD_POINTS(5);
|
||||
|
||||
auto client = this->server->findClient(cmd["clid"].as<ClientId>());
|
||||
ConnectedLockedClient client{this->server->find_client_by_id(cmd["clid"].as<ClientId>())};
|
||||
if (!client) return command_result{error::client_invalid_id};
|
||||
|
||||
bool send_temp;
|
||||
auto info = client->request_connection_info(_this.lock(), send_temp);
|
||||
if (info) {
|
||||
this->notifyConnectionInfo(client, info);
|
||||
this->notifyConnectionInfo(client.client, info);
|
||||
} else if(send_temp) {
|
||||
return command_result{error::no_cached_connection_info};
|
||||
}
|
||||
@@ -489,7 +492,7 @@ command_result ConnectedClient::handleCommandSendTextMessage(Command &cmd) {
|
||||
|
||||
auto timestamp = system_clock::now();
|
||||
if (cmd["targetmode"].as<ChatMessageMode>() == ChatMessageMode::TEXTMODE_PRIVATE) {
|
||||
auto target = this->server->findClient(cmd["target"].as<ClientId>());
|
||||
ConnectedLockedClient target{this->server->find_client_by_id(cmd["target"].as<ClientId>())};
|
||||
if (!target) return command_result{error::client_invalid_id};
|
||||
|
||||
bool chat_open = false;
|
||||
@@ -506,24 +509,24 @@ command_result ConnectedClient::handleCommandSendTextMessage(Command &cmd) {
|
||||
}
|
||||
|
||||
if(!chat_open) {
|
||||
if (target == this)
|
||||
if (target.client == this)
|
||||
ACTION_REQUIRES_PERMISSION(permission::b_client_even_textmessage_send, 1, this->getChannelId());
|
||||
if(!permission::v2::permission_granted(target->calculate_permission(permission::i_client_needed_private_textmessage_power, target->getClientId()), this->calculate_permission(permission::i_client_private_textmessage_power, this->getClientId()), false))
|
||||
return command_result{permission::i_client_private_textmessage_power};
|
||||
|
||||
|
||||
{
|
||||
unique_lock channel_lock(target->channel_lock);
|
||||
unique_lock channel_lock(target->get_channel_lock());
|
||||
target->openChats.push_back(_this);
|
||||
}
|
||||
|
||||
{
|
||||
unique_lock channel_lock(this->channel_lock);
|
||||
this->openChats.push_back(target);
|
||||
this->openChats.push_back(target.client);
|
||||
}
|
||||
}
|
||||
|
||||
if(this->handleTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, cmd["msg"], target)) return command_result{error::ok};
|
||||
if(this->handleTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, cmd["msg"], target.client)) return command_result{error::ok};
|
||||
target->notifyTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, _this.lock(), target->getClientId(), 0, timestamp, cmd["msg"].string());
|
||||
this->notifyTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, _this.lock(), target->getClientId(), 0, timestamp, cmd["msg"].string());
|
||||
} else if (cmd["targetmode"] == ChatMessageMode::TEXTMODE_CHANNEL) {
|
||||
@@ -809,7 +812,7 @@ command_result ConnectedClient::handleCommandBanClient(Command &cmd) {
|
||||
if(client->getType() == ClientType::CLIENT_MUSIC)
|
||||
return command_result{error::client_invalid_id, "You cant ban a music bot!"};
|
||||
} else {
|
||||
target_clients = {this->server->findClient(cmd["clid"].as<ClientId>())};
|
||||
target_clients = {this->server->find_client_by_id(cmd["clid"].as<ClientId>())};
|
||||
if(!target_clients[0]) {
|
||||
return command_result{error::client_invalid_id, "Could not find target client"};
|
||||
}
|
||||
@@ -855,7 +858,7 @@ command_result ConnectedClient::handleCommandBanClient(Command &cmd) {
|
||||
if (client->getType() != CLIENT_TEAMSPEAK && client->getType() != CLIENT_QUERY) continue; //Remember if you add new type you have to change stuff here
|
||||
|
||||
this->server->notify_client_ban(client, this->ref(), reason, time);
|
||||
client->closeConnection(system_clock::now() + seconds(2));
|
||||
client->close_connection(system_clock::now() + seconds(2));
|
||||
|
||||
string entry_name, entry_ip, entry_hardware_id;
|
||||
if(b_ban_name && !no_nickname) {
|
||||
@@ -1108,8 +1111,8 @@ command_result ConnectedClient::handleCommandPluginCmd(Command &cmd) {
|
||||
} else if (mode == PluginTargetMode::PLUGINCMD_CLIENT) {
|
||||
for (int index = 0; index < cmd.bulkCount(); index++) {
|
||||
auto target = cmd[index]["target"].as<ClientId>();
|
||||
auto cl = this->server->findClient(target);
|
||||
if (!cl) return command_result{error::client_invalid_id, "invalid target id"};
|
||||
ConnectedLockedClient cl{this->server->find_client_by_id(target)};
|
||||
if (!cl) return command_result{error::client_invalid_id};
|
||||
cl->notifyPluginCmd(cmd["name"], cmd["data"], _this.lock());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user