Some minor bugfixes

This commit is contained in:
WolverinDEV
2020-07-13 11:13:09 +02:00
parent e01811e20e
commit 9c7223d016
13 changed files with 86 additions and 67 deletions
+36 -15
View File
@@ -4,8 +4,6 @@
#include <memory>
#include <spdlog/sinks/rotating_file_sink.h>
#include <iostream>
#include <bitset>
#include <algorithm>
@@ -15,7 +13,6 @@
#include "../InternalClient.h"
#include "../../server/VoiceServer.h"
#include "../voice/VoiceClient.h"
#include "PermissionManager.h"
#include "../../InstanceHandler.h"
#include "../../server/QueryServer.h"
#include "../music/MusicClient.h"
@@ -30,16 +27,10 @@
#include "helpers.h"
#include <Properties.h>
#include <log/LogUtils.h>
#include <misc/sassert.h>
#include <misc/base64.h>
#include <misc/hex.h>
#include <misc/digest.h>
#include <misc/rnd.h>
#include <misc/timer.h>
#include <misc/strobf.h>
#include <misc/scope_guard.h>
#include <bbcode/bbcodes.h>
namespace fs = std::experimental::filesystem;
@@ -132,8 +123,34 @@ command_result ConnectedClient::handleCommand(Command &cmd) {
else if (command == "ftgetfilelist") return this->handleCommandFTGetFileList(cmd);
else if (command == "ftcreatedir") return this->handleCommandFTCreateDir(cmd);
else if (command == "ftdeletefile") return this->handleCommandFTDeleteFile(cmd);
else if (command == "ftinitupload") return this->handleCommandFTInitUpload(cmd);
else if (command == "ftinitdownload") return this->handleCommandFTInitDownload(cmd);
else if (command == "ftinitupload") {
auto result = this->handleCommandFTInitUpload(cmd);
if(result.has_error() && this->getType() == ClientType::CLIENT_TEAMSPEAK) {
ts::command_builder notify{"notifystatusfiletransfer"};
notify.put_unchecked(0, "clientftfid", cmd["clientftfid"].string());
notify.put(0, "size", 0);
this->writeCommandResult(notify, result, "status");
this->sendCommand(notify);
result.release_data();
return command_result{error::ok};
}
return result;
}
else if (command == "ftinitdownload") {
auto result = this->handleCommandFTInitDownload(cmd);
if(result.has_error() && this->getType() == ClientType::CLIENT_TEAMSPEAK) {
ts::command_builder notify{"notifystatusfiletransfer"};
notify.put_unchecked(0, "clientftfid", cmd["clientftfid"].string());
notify.put(0, "size", 0);
this->writeCommandResult(notify, result, "status");
this->sendCommand(notify);
result.release_data();
return command_result{error::ok};
}
return result;
}
else if (command == "ftgetfileinfo") return this->handleCommandFTGetFileInfo(cmd);
else if (command == "ftrenamefile") return this->handleCommandFTRenameFile(cmd);
else if (command == "ftlist") return this->handleCommandFTList(cmd);
@@ -2523,6 +2540,7 @@ command_result ConnectedClient::handleCommandConversationHistory(ts::Command &co
auto channel = this->channel_view()->find_channel(conversation_id);
if(!channel)
return command_result{error::conversation_invalid_id};
if(channel->channel()->properties()[property::CHANNEL_FLAG_CONVERSATION_PRIVATE].as<bool>())
return command_result{error::conversation_is_private};
}
@@ -2684,11 +2702,13 @@ command_result ConnectedClient::handleCommandConversationFetch(ts::Command &cmd)
}
auto conversation = conversation_manager->get(conversation_id);
if(conversation)
if(conversation) {
result_bulk["timestamp"] = duration_cast<milliseconds>(conversation->last_message().time_since_epoch()).count();
else
result_bulk["flag_volatile"] = conversation->volatile_only();
} else {
result_bulk["timestamp"] = 0;
result_bulk["flag_volatile"] = conversation->volatile_only();
result_bulk["flag_volatile"] = false;
}
}
if(result_index == 0)
return command_result{error::database_empty_result};
@@ -2737,7 +2757,7 @@ command_result ConnectedClient::handleCommandConversationMessageDelete(ts::Comma
if (!channel->passwordMatch(bulk["cpw"], true))
ACTION_REQUIRES_PERMISSION(permission::b_channel_join_ignore_password, 1, channel->channelId());
if (!permission::v2::permission_granted(1, this->calculate_permission(permission::b_channel_conversation_message_delete, 1, channel->channelId())))
if (!permission::v2::permission_granted(1, this->calculate_permission(permission::b_channel_conversation_message_delete, channel->channelId())))
return command_result{permission::b_channel_conversation_message_delete};
if(auto error_perm = this->calculate_and_get_join_state(channel); error_perm != permission::ok && error_perm != permission::b_client_is_sticky)
@@ -2753,6 +2773,7 @@ command_result ConnectedClient::handleCommandConversationMessageDelete(ts::Comma
auto limit = bulk.has("limit") ? bulk["limit"].as<uint64_t>() : 1;
if(limit > 100)
limit = 100;
auto delete_count = current_conversation->delete_messages(timestamp_end, limit, timestamp_begin, bulk["cldbid"]);
if(delete_count > 0) {
for(const auto& client : ref_server->getClients()) {
+1 -1
View File
@@ -75,7 +75,7 @@ command_result ConnectedClient::handleCommandMusicBotCreate(Command& cmd) {
permission::i_client_music_create_modify_max_volume
}, this->getChannelId());
auto permissions = map<permission::PermissionType, permission::v2::PermissionFlaggedValue>(permissions_list.begin(), permissions_list.end());
auto permissions = std::map<permission::PermissionType, permission::v2::PermissionFlaggedValue>(permissions_list.begin(), permissions_list.end());
auto max_bots = permissions[permission::i_client_music_limit];
if(max_bots.has_value) {