A lot of updates
This commit is contained in:
parent
7c490d2180
commit
787f911b6f
@ -258,6 +258,9 @@ void ConnectionStatistics::tick() {
|
|||||||
|
|
||||||
_properties[property::CONNECTION_FILETRANSFER_BYTES_RECEIVED_TOTAL] = (uint64_t) this->file_bytes_received;
|
_properties[property::CONNECTION_FILETRANSFER_BYTES_RECEIVED_TOTAL] = (uint64_t) this->file_bytes_received;
|
||||||
_properties[property::CONNECTION_FILETRANSFER_BYTES_SENT_TOTAL] = (uint64_t) this->file_bytes_sent;
|
_properties[property::CONNECTION_FILETRANSFER_BYTES_SENT_TOTAL] = (uint64_t) this->file_bytes_sent;
|
||||||
|
|
||||||
|
_properties[property::CONNECTION_FILETRANSFER_BYTES_RECEIVED_TOTAL] = (uint64_t) this->file_bytes_received;
|
||||||
|
_properties[property::CONNECTION_FILETRANSFER_BYTES_SENT_TOTAL] = (uint64_t) this->file_bytes_sent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -746,7 +746,7 @@ void TSServer::broadcastMessage(std::shared_ptr<ConnectedClient> invoker, std::s
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->forEachClient([&](shared_ptr<ConnectedClient> cl){
|
this->forEachClient([&](shared_ptr<ConnectedClient> cl){
|
||||||
cl->notifyTextMessage(ChatMessageMode::TEXTMODE_SERVER, invoker, 0, 0, message);
|
cl->notifyTextMessage(ChatMessageMode::TEXTMODE_SERVER, invoker, 0, 0, system_clock::now(), message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,9 +240,10 @@ std::deque<std::shared_ptr<BasicChannel>> ConnectedClient::subscribeChannel(cons
|
|||||||
|
|
||||||
if(!general_granted && channel != this->currentChannel) {
|
if(!general_granted && channel != this->currentChannel) {
|
||||||
auto granted_permission = this->calculate_permission_value(permission::i_channel_subscribe_power, channel->channelId());
|
auto granted_permission = this->calculate_permission_value(permission::i_channel_subscribe_power, channel->channelId());
|
||||||
if(!channel->permission_granted(permission::i_channel_needed_subscribe_power, granted_permission, false) &&
|
if((granted_permission.has_value && granted_permission.value == -1) || !channel->permission_granted(permission::i_channel_needed_subscribe_power, granted_permission, false)) {
|
||||||
!this->permission_granted(this->permissionValue(permission::b_channel_ignore_subscribe_power, channel), 1, true)) {
|
auto ignore_power = this->calculate_permission_value(permission::b_channel_ignore_subscribe_power, channel->channelId());
|
||||||
continue;
|
if(!ignore_power.has_value && ignore_power.value < 1)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,9 +176,9 @@ namespace ts {
|
|||||||
//Group manager chat
|
//Group manager chat
|
||||||
virtual bool notifyClientChatComposing(const std::shared_ptr<ConnectedClient> &);
|
virtual bool notifyClientChatComposing(const std::shared_ptr<ConnectedClient> &);
|
||||||
virtual bool notifyClientChatClosed(const std::shared_ptr<ConnectedClient> &);
|
virtual bool notifyClientChatClosed(const std::shared_ptr<ConnectedClient> &);
|
||||||
virtual bool notifyTextMessage(ChatMessageMode mode, const std::shared_ptr<ConnectedClient> &sender, uint64_t targetId, ChannelId channel_id, const std::string &textMessage);
|
virtual bool notifyTextMessage(ChatMessageMode mode, const std::shared_ptr<ConnectedClient> &sender, uint64_t targetId, ChannelId channel_id, const std::chrono::system_clock::time_point& /* timestamp */, const std::string &textMessage);
|
||||||
inline void sendChannelMessage(const std::shared_ptr<ConnectedClient>& sender, const std::string& textMessage){
|
inline void sendChannelMessage(const std::shared_ptr<ConnectedClient>& sender, const std::string& textMessage){
|
||||||
this->notifyTextMessage(ChatMessageMode::TEXTMODE_CHANNEL, sender, this->currentChannel ? this->currentChannel->channelId() : 0, 0, textMessage);
|
this->notifyTextMessage(ChatMessageMode::TEXTMODE_CHANNEL, sender, this->currentChannel ? this->currentChannel->channelId() : 0, 0, std::chrono::system_clock::now(), textMessage);
|
||||||
}
|
}
|
||||||
//Group Client Groups
|
//Group Client Groups
|
||||||
virtual bool notifyServerGroupClientAdd(const std::shared_ptr<ConnectedClient> &invoker, const std::shared_ptr<ConnectedClient> &client, const std::shared_ptr<Group> &group);
|
virtual bool notifyServerGroupClientAdd(const std::shared_ptr<ConnectedClient> &invoker, const std::shared_ptr<ConnectedClient> &client, const std::shared_ptr<Group> &group);
|
||||||
@ -259,6 +259,8 @@ namespace ts {
|
|||||||
virtual bool notifyMusicQueueOrderChange(const std::shared_ptr<MusicClient>& bot, const std::shared_ptr<ts::music::SongInfo>& entry, int order, const std::shared_ptr<ConnectedClient>& invoker);
|
virtual bool notifyMusicQueueOrderChange(const std::shared_ptr<MusicClient>& bot, const std::shared_ptr<ts::music::SongInfo>& entry, int order, const std::shared_ptr<ConnectedClient>& invoker);
|
||||||
virtual bool notifyMusicPlayerStatusUpdate(const std::shared_ptr<MusicClient>&);
|
virtual bool notifyMusicPlayerStatusUpdate(const std::shared_ptr<MusicClient>&);
|
||||||
|
|
||||||
|
virtual bool notifyConversationMessageDelete(const ChannelId /* conversation id */, const std::chrono::system_clock::time_point& /* begin timestamp */, const std::chrono::system_clock::time_point& /* begin end */, ClientDbId /* client id */, size_t /* messages */);
|
||||||
|
|
||||||
virtual bool closeConnection(const std::chrono::system_clock::time_point &timeout = std::chrono::system_clock::time_point()) = 0;
|
virtual bool closeConnection(const std::chrono::system_clock::time_point &timeout = std::chrono::system_clock::time_point()) = 0;
|
||||||
virtual bool disconnect(const std::string& reason) = 0;
|
virtual bool disconnect(const std::string& reason) = 0;
|
||||||
|
|
||||||
|
@ -364,6 +364,7 @@ CommandResult ConnectedClient::handleCommand(Command &cmd) {
|
|||||||
else if (command == "dummy_ipchange") return this->handleCommandDummy_IpChange(cmd);
|
else if (command == "dummy_ipchange") return this->handleCommandDummy_IpChange(cmd);
|
||||||
else if (command == "conversationhistory") return this->handleCommandConversationHistory(cmd);
|
else if (command == "conversationhistory") return this->handleCommandConversationHistory(cmd);
|
||||||
else if (command == "conversationfetch") return this->handleCommandConversationFetch(cmd);
|
else if (command == "conversationfetch") return this->handleCommandConversationFetch(cmd);
|
||||||
|
else if (command == "conversationmessagedelete") return this->handleCommandConversationMessageDelete(cmd);
|
||||||
|
|
||||||
if (this->getType() == ClientType::CLIENT_QUERY) return CommandResult::NotImplemented; //Dont log query invalid commands
|
if (this->getType() == ClientType::CLIENT_QUERY) return CommandResult::NotImplemented; //Dont log query invalid commands
|
||||||
if (this->getType() == ClientType::CLIENT_TEAMSPEAK)
|
if (this->getType() == ClientType::CLIENT_TEAMSPEAK)
|
||||||
@ -699,9 +700,13 @@ CommandResult ConnectedClient::handleCommandServerRequestConnectionInfo(Command
|
|||||||
|
|
||||||
notify[0]["connection_filetransfer_bandwidth_sent"] = report.file_send;
|
notify[0]["connection_filetransfer_bandwidth_sent"] = report.file_send;
|
||||||
notify[0]["connection_filetransfer_bandwidth_received"] = report.file_recv;
|
notify[0]["connection_filetransfer_bandwidth_received"] = report.file_recv;
|
||||||
|
|
||||||
notify[0]["connection_filetransfer_bytes_sent_total"] = (*statistics)[property::CONNECTION_FILETRANSFER_BYTES_SENT_TOTAL].as<string>();
|
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>();
|
notify[0]["connection_filetransfer_bytes_received_total"] = (*statistics)[property::CONNECTION_FILETRANSFER_BYTES_RECEIVED_TOTAL].as<string>();
|
||||||
|
|
||||||
|
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>();
|
||||||
|
|
||||||
notify[0]["connection_packets_sent_total"] = (*statistics)[property::CONNECTION_PACKETS_SENT_TOTAL].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_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_packets_received_total"] = (*statistics)[property::CONNECTION_PACKETS_RECEIVED_TOTAL].as<string>();
|
||||||
@ -3237,6 +3242,7 @@ CommandResult ConnectedClient::handleCommandSendTextMessage(Command &cmd) {
|
|||||||
CMD_RESET_IDLE;
|
CMD_RESET_IDLE;
|
||||||
CMD_CHK_AND_INC_FLOOD_POINTS(5);
|
CMD_CHK_AND_INC_FLOOD_POINTS(5);
|
||||||
|
|
||||||
|
auto timestamp = system_clock::now();
|
||||||
if (cmd["targetmode"].as<ChatMessageMode>() == ChatMessageMode::TEXTMODE_PRIVATE) {
|
if (cmd["targetmode"].as<ChatMessageMode>() == ChatMessageMode::TEXTMODE_PRIVATE) {
|
||||||
auto target = this->server->findClient(cmd["target"].as<ClientId>());
|
auto target = this->server->findClient(cmd["target"].as<ClientId>());
|
||||||
if (!target) return {findError("client_invalid_id"), "invalid target clid"};
|
if (!target) return {findError("client_invalid_id"), "invalid target clid"};
|
||||||
@ -3274,8 +3280,8 @@ CommandResult ConnectedClient::handleCommandSendTextMessage(Command &cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(this->handleTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, cmd["msg"], target)) return CommandResult::Success;
|
if(this->handleTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, cmd["msg"], target)) return CommandResult::Success;
|
||||||
target->notifyTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, _this.lock(), target->getClientId(), 0, cmd["msg"].string());
|
target->notifyTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, _this.lock(), target->getClientId(), 0, timestamp, cmd["msg"].string());
|
||||||
this->notifyTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, _this.lock(), target->getClientId(), 0, cmd["msg"].string());
|
this->notifyTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, _this.lock(), target->getClientId(), 0, timestamp, cmd["msg"].string());
|
||||||
} else if (cmd["targetmode"] == ChatMessageMode::TEXTMODE_CHANNEL) {
|
} else if (cmd["targetmode"] == ChatMessageMode::TEXTMODE_CHANNEL) {
|
||||||
if(!cmd[0].has("cid"))
|
if(!cmd[0].has("cid"))
|
||||||
cmd["cid"] = 0;
|
cmd["cid"] = 0;
|
||||||
@ -3327,14 +3333,14 @@ CommandResult ConnectedClient::handleCommandSendTextMessage(Command &cmd) {
|
|||||||
if(!client->calculate_and_get_join_state(channel))
|
if(!client->calculate_and_get_join_state(channel))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
client->notifyTextMessage(ChatMessageMode::TEXTMODE_CHANNEL, _this, client_id, channel_id, message);
|
client->notifyTextMessage(ChatMessageMode::TEXTMODE_CHANNEL, _this, client_id, channel_id, timestamp, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!conversation_private) {
|
if(!conversation_private) {
|
||||||
auto conversations = this->server->conversation_manager();
|
auto conversations = this->server->conversation_manager();
|
||||||
auto conversation = conversations->get_or_create(channel->channelId());
|
auto conversation = conversations->get_or_create(channel->channelId());
|
||||||
conversation->register_message(this->getClientDatabaseId(), this->getUid(), this->getDisplayName(), cmd["msg"].string());
|
conversation->register_message(this->getClientDatabaseId(), this->getUid(), this->getDisplayName(), timestamp, cmd["msg"].string());
|
||||||
}
|
}
|
||||||
} else if (cmd["targetmode"] == ChatMessageMode::TEXTMODE_SERVER) {
|
} else if (cmd["targetmode"] == ChatMessageMode::TEXTMODE_SERVER) {
|
||||||
CACHED_PERM_CHECK(permission::b_client_server_textmessage_send, 1);
|
CACHED_PERM_CHECK(permission::b_client_server_textmessage_send, 1);
|
||||||
@ -3348,13 +3354,13 @@ CommandResult ConnectedClient::handleCommandSendTextMessage(Command &cmd) {
|
|||||||
if (type == ClientType::CLIENT_INTERNAL || type == ClientType::CLIENT_MUSIC)
|
if (type == ClientType::CLIENT_INTERNAL || type == ClientType::CLIENT_MUSIC)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
client->notifyTextMessage(ChatMessageMode::TEXTMODE_SERVER, _this.lock(), this->getClientId(), 0, cmd["msg"].string());
|
client->notifyTextMessage(ChatMessageMode::TEXTMODE_SERVER, _this.lock(), this->getClientId(), 0, timestamp, cmd["msg"].string());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto conversations = this->server->conversation_manager();
|
auto conversations = this->server->conversation_manager();
|
||||||
auto conversation = conversations->get_or_create(0);
|
auto conversation = conversations->get_or_create(0);
|
||||||
conversation->register_message(this->getClientDatabaseId(), this->getUid(), this->getDisplayName(), cmd["msg"].string());
|
conversation->register_message(this->getClientDatabaseId(), this->getUid(), this->getDisplayName(), timestamp, cmd["msg"].string());
|
||||||
}
|
}
|
||||||
} else return {findError("parameter_invalid"), "invalid target mode"};
|
} else return {findError("parameter_invalid"), "invalid target mode"};
|
||||||
|
|
||||||
@ -4682,7 +4688,7 @@ CommandResult ConnectedClient::handleCommandClientMute(Command &cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config::voice::notifyMuted)
|
if (config::voice::notifyMuted)
|
||||||
client->notifyTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, _this.lock(), client->getClientId(), 0, config::messages::mute_notify_message);
|
client->notifyTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, _this.lock(), client->getClientId(), 0, system_clock::now(), config::messages::mute_notify_message);
|
||||||
|
|
||||||
return CommandResult::Success;
|
return CommandResult::Success;
|
||||||
}
|
}
|
||||||
@ -4703,7 +4709,7 @@ CommandResult ConnectedClient::handleCommandClientUnmute(Command &cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config::voice::notifyMuted)
|
if (config::voice::notifyMuted)
|
||||||
client->notifyTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, _this.lock(), client->getClientId(), 0, config::messages::unmute_notify_message);
|
client->notifyTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, _this.lock(), client->getClientId(), 0, system_clock::now(), config::messages::unmute_notify_message);
|
||||||
|
|
||||||
return CommandResult::Success;
|
return CommandResult::Success;
|
||||||
}
|
}
|
||||||
@ -7611,7 +7617,6 @@ CommandResult ConnectedClient::handleCommandConversationFetch(ts::Command &cmd)
|
|||||||
return CommandResult::Success;
|
return CommandResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CommandResult ConnectedClient::handleCommandConversationMessageDelete(ts::Command &cmd) {
|
CommandResult ConnectedClient::handleCommandConversationMessageDelete(ts::Command &cmd) {
|
||||||
CMD_REF_SERVER(ref_server);
|
CMD_REF_SERVER(ref_server);
|
||||||
CMD_CHK_AND_INC_FLOOD_POINTS(25);
|
CMD_CHK_AND_INC_FLOOD_POINTS(25);
|
||||||
@ -7667,13 +7672,22 @@ CommandResult ConnectedClient::handleCommandConversationMessageDelete(ts::Comman
|
|||||||
if(!current_conversation) continue;
|
if(!current_conversation) continue;
|
||||||
|
|
||||||
auto timestamp_begin = system_clock::time_point{} + milliseconds{bulk["timestamp_begin"]};
|
auto timestamp_begin = system_clock::time_point{} + milliseconds{bulk["timestamp_begin"]};
|
||||||
auto timestamp_end = system_clock::time_point{} + milliseconds{bulk.has("timestamp_begin") ? bulk["timestamp_begin"].as<uint64_t>() : 0};
|
auto timestamp_end = system_clock::time_point{} + milliseconds{bulk.has("timestamp_end") ? bulk["timestamp_end"].as<uint64_t>() : 0};
|
||||||
auto limit = bulk.has("limit") ? bulk["limit"].as<uint64_t>() : 1;
|
auto limit = bulk.has("limit") ? bulk["limit"].as<uint64_t>() : 1;
|
||||||
if(limit > 100)
|
if(limit > 100)
|
||||||
limit = 100;
|
limit = 100;
|
||||||
auto delete_count = current_conversation->delete_messages(timestamp_begin, limit, timestamp_end, bulk["cldbid"]);
|
auto delete_count = current_conversation->delete_messages(timestamp_end, limit, timestamp_begin, bulk["cldbid"]);
|
||||||
if(delete_count > 0) {
|
if(delete_count > 0) {
|
||||||
//TODO: Notify
|
for(const auto& client : ref_server->getClients()) {
|
||||||
|
if(client->connectionState() != ConnectionState::CONNECTED)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto type = client->getType();
|
||||||
|
if(type == ClientType::CLIENT_INTERNAL || type == ClientType::CLIENT_MUSIC)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
client->notifyConversationMessageDelete(current_conversation_id, timestamp_begin, timestamp_end, bulk["cldbid"], delete_count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,13 +179,14 @@ bool ConnectedClient::notifyChannelGroupList() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConnectedClient::notifyTextMessage(ChatMessageMode mode, const shared_ptr<ConnectedClient> &invoker, uint64_t targetId, ChannelId channel_id, const string &textMessage) {
|
bool ConnectedClient::notifyTextMessage(ChatMessageMode mode, const shared_ptr<ConnectedClient> &invoker, uint64_t targetId, ChannelId channel_id, const std::chrono::system_clock::time_point& timestamp, const string &textMessage) {
|
||||||
//notifytextmessage targetmode=1 msg=asdasd target=2 invokerid=1 invokername=WolverinDEV invokeruid=xxjnc14LmvTk+Lyrm8OOeo4tOqw=
|
//notifytextmessage targetmode=1 msg=asdasd target=2 invokerid=1 invokername=WolverinDEV invokeruid=xxjnc14LmvTk+Lyrm8OOeo4tOqw=
|
||||||
Command cmd("notifytextmessage");
|
Command cmd("notifytextmessage");
|
||||||
INVOKER(cmd, invoker);
|
INVOKER(cmd, invoker);
|
||||||
cmd["targetmode"] = mode;
|
cmd["targetmode"] = mode;
|
||||||
cmd["target"] = targetId;
|
cmd["target"] = targetId;
|
||||||
cmd["msg"] = textMessage;
|
cmd["msg"] = textMessage;
|
||||||
|
cmd["timestamp"] = floor<milliseconds>(timestamp.time_since_epoch()).count();
|
||||||
if(this->getType() != ClientType::CLIENT_TEAMSPEAK)
|
if(this->getType() != ClientType::CLIENT_TEAMSPEAK)
|
||||||
cmd["cid"] = channel_id;
|
cmd["cid"] = channel_id;
|
||||||
this->sendCommand(cmd);
|
this->sendCommand(cmd);
|
||||||
@ -709,6 +710,19 @@ bool ConnectedClient::notifyMusicPlayerSongChange(const std::shared_ptr<MusicCli
|
|||||||
} else {
|
} else {
|
||||||
notify["song_id"] = 0;
|
notify["song_id"] = 0;
|
||||||
}
|
}
|
||||||
|
this->sendCommand(notify);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ConnectedClient::notifyConversationMessageDelete(const ts::ChannelId channel_id, const std::chrono::system_clock::time_point& begin, const std::chrono::system_clock::time_point& end, ts::ClientDbId client_id, size_t size) {
|
||||||
|
Command notify("notifyconversationmessagedelete");
|
||||||
|
|
||||||
|
notify["cid"] = channel_id;
|
||||||
|
notify["timestamp_begin"] = floor<milliseconds>(begin.time_since_epoch()).count();
|
||||||
|
notify["timestamp_end"] = floor<milliseconds>(end.time_since_epoch()).count();
|
||||||
|
notify["cldbid"] = client_id;
|
||||||
|
notify["limit"] = size;
|
||||||
|
|
||||||
this->sendCommand(notify);
|
this->sendCommand(notify);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
@ -122,15 +122,15 @@ bool ConnectedClient::handleTextMessage(ChatMessageMode mode, std::string text,
|
|||||||
handle_text_command_fn_t function;
|
handle_text_command_fn_t function;
|
||||||
if(mode == ChatMessageMode::TEXTMODE_SERVER) {
|
if(mode == ChatMessageMode::TEXTMODE_SERVER) {
|
||||||
function = [&](const shared_ptr<ConnectedClient>& sender, const string& message) {
|
function = [&](const shared_ptr<ConnectedClient>& sender, const string& message) {
|
||||||
this->notifyTextMessage(ChatMessageMode::TEXTMODE_SERVER, sender, 0, 0, message);
|
this->notifyTextMessage(ChatMessageMode::TEXTMODE_SERVER, sender, 0, 0, system_clock::now(), message);
|
||||||
};
|
};
|
||||||
} else if(mode == ChatMessageMode::TEXTMODE_CHANNEL) {
|
} else if(mode == ChatMessageMode::TEXTMODE_CHANNEL) {
|
||||||
function = [&](const shared_ptr<ConnectedClient>& sender, const string& message) {
|
function = [&](const shared_ptr<ConnectedClient>& sender, const string& message) {
|
||||||
this->notifyTextMessage(ChatMessageMode::TEXTMODE_CHANNEL, sender, 0, 0, message);
|
this->notifyTextMessage(ChatMessageMode::TEXTMODE_CHANNEL, sender, 0, 0, system_clock::now(), message);
|
||||||
};
|
};
|
||||||
} else if(mode == ChatMessageMode::TEXTMODE_PRIVATE) {
|
} else if(mode == ChatMessageMode::TEXTMODE_PRIVATE) {
|
||||||
function = [&, target](const shared_ptr<ConnectedClient>& sender, const string& message) {
|
function = [&, target](const shared_ptr<ConnectedClient>& sender, const string& message) {
|
||||||
this->notifyTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, target, this->getClientId(), 0, message);
|
this->notifyTextMessage(ChatMessageMode::TEXTMODE_PRIVATE, target, this->getClientId(), 0, system_clock::now(), message);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,25 @@ CommandResult SpeakingClient::handleCommandHandshakeBegin(Command& cmd) { //If !
|
|||||||
return {findError("web_handshake_invalid"), "Provided data is too old!"};
|
return {findError("web_handshake_invalid"), "Provided data is too old!"};
|
||||||
|
|
||||||
this->properties()[property::CLIENT_UNIQUE_IDENTIFIER] = base64::encode(digest::sha1("TeaSpeak-Forum#" + (*this->handshake.identityData)["user_id"].asString()));
|
this->properties()[property::CLIENT_UNIQUE_IDENTIFIER] = base64::encode(digest::sha1("TeaSpeak-Forum#" + (*this->handshake.identityData)["user_id"].asString()));
|
||||||
|
|
||||||
|
this->properties()[property::CLIENT_TEAFORO_ID] = (*this->handshake.identityData)["user_id"].asInt64();
|
||||||
|
this->properties()[property::CLIENT_TEAFORO_NAME] = (*this->handshake.identityData)["user_name"].asString();
|
||||||
|
|
||||||
|
{
|
||||||
|
///* 0x01 := Banned | 0x02 := Stuff | 0x04 := Premium */
|
||||||
|
uint64_t flags = 0;
|
||||||
|
|
||||||
|
if((*this->handshake.identityData)["is_banned"].isBool() && (*this->handshake.identityData)["is_banned"].asBool())
|
||||||
|
flags |= 0x01U;
|
||||||
|
|
||||||
|
if((*this->handshake.identityData)["is_staff"].isBool() && (*this->handshake.identityData)["is_staff"].asBool())
|
||||||
|
flags |= 0x02U;
|
||||||
|
|
||||||
|
if((*this->handshake.identityData)["is_premium"].isBool() && (*this->handshake.identityData)["is_premium"].asBool())
|
||||||
|
flags |= 0x04U;
|
||||||
|
|
||||||
|
this->properties()[property::CLIENT_TEAFORO_FLAGS] = flags;
|
||||||
|
}
|
||||||
} catch (Json::Exception& exception) {
|
} catch (Json::Exception& exception) {
|
||||||
return {findError("web_handshake_invalid"), "invalid json!"};
|
return {findError("web_handshake_invalid"), "invalid json!"};
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ namespace ts {
|
|||||||
bool notifyPluginCmd(std::string name, std::string msg,std::shared_ptr<ConnectedClient>) override;
|
bool notifyPluginCmd(std::string name, std::string msg,std::shared_ptr<ConnectedClient>) override;
|
||||||
bool notifyClientChatComposing(const std::shared_ptr<ConnectedClient> &ptr) override;
|
bool notifyClientChatComposing(const std::shared_ptr<ConnectedClient> &ptr) override;
|
||||||
bool notifyClientChatClosed(const std::shared_ptr<ConnectedClient> &ptr) override;
|
bool notifyClientChatClosed(const std::shared_ptr<ConnectedClient> &ptr) override;
|
||||||
bool notifyTextMessage(ChatMessageMode mode, const std::shared_ptr<ConnectedClient> &sender, uint64_t targetId, ChannelId channel_id, const std::string &textMessage) override;
|
bool notifyTextMessage(ChatMessageMode mode, const std::shared_ptr<ConnectedClient> &sender, uint64_t targetId, ChannelId channel_id, const std::chrono::system_clock::time_point&, const std::string &textMessage) override;
|
||||||
bool notifyServerGroupClientAdd(const std::shared_ptr<ConnectedClient> &invoker, const std::shared_ptr<ConnectedClient> &client, const std::shared_ptr<Group> &group) override;
|
bool notifyServerGroupClientAdd(const std::shared_ptr<ConnectedClient> &invoker, const std::shared_ptr<ConnectedClient> &client, const std::shared_ptr<Group> &group) override;
|
||||||
bool notifyServerGroupClientRemove(std::shared_ptr<ConnectedClient> invoker, std::shared_ptr<ConnectedClient> client, std::shared_ptr<Group> group) override;
|
bool notifyServerGroupClientRemove(std::shared_ptr<ConnectedClient> invoker, std::shared_ptr<ConnectedClient> client, std::shared_ptr<Group> group) override;
|
||||||
|
|
||||||
|
@ -67,11 +67,11 @@ bool QueryClient::notifyClientChatClosed(const shared_ptr<ConnectedClient> &ptr)
|
|||||||
return ConnectedClient::notifyClientChatClosed(ptr);
|
return ConnectedClient::notifyClientChatClosed(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QueryClient::notifyTextMessage(ChatMessageMode mode, const shared_ptr<ConnectedClient> &sender, uint64_t targetId, ChannelId channel_id, const string &textMessage) {
|
bool QueryClient::notifyTextMessage(ChatMessageMode mode, const shared_ptr<ConnectedClient> &sender, uint64_t targetId, ChannelId channel_id, const std::chrono::system_clock::time_point& tp, const string &textMessage) {
|
||||||
if(mode == ChatMessageMode::TEXTMODE_PRIVATE) CHK_EVENT(QEVENTGROUP_CHAT, QEVENTSPECIFIER_CHAT_MESSAGE_PRIVATE);
|
if(mode == ChatMessageMode::TEXTMODE_PRIVATE) CHK_EVENT(QEVENTGROUP_CHAT, QEVENTSPECIFIER_CHAT_MESSAGE_PRIVATE);
|
||||||
else if(mode == ChatMessageMode::TEXTMODE_CHANNEL) CHK_EVENT(QEVENTGROUP_CHAT, QEVENTSPECIFIER_CHAT_MESSAGE_CHANNEL);
|
else if(mode == ChatMessageMode::TEXTMODE_CHANNEL) CHK_EVENT(QEVENTGROUP_CHAT, QEVENTSPECIFIER_CHAT_MESSAGE_CHANNEL);
|
||||||
else if(mode == ChatMessageMode::TEXTMODE_SERVER) CHK_EVENT(QEVENTGROUP_CHAT, QEVENTSPECIFIER_CHAT_MESSAGE_SERVER);
|
else if(mode == ChatMessageMode::TEXTMODE_SERVER) CHK_EVENT(QEVENTGROUP_CHAT, QEVENTSPECIFIER_CHAT_MESSAGE_SERVER);
|
||||||
return ConnectedClient::notifyTextMessage(mode, sender, targetId, channel_id, textMessage);
|
return ConnectedClient::notifyTextMessage(mode, sender, targetId, channel_id, tp, textMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QueryClient::notifyServerGroupClientAdd(const shared_ptr<ConnectedClient> &invoker, const shared_ptr<ConnectedClient> &client, const shared_ptr<Group> &group) {
|
bool QueryClient::notifyServerGroupClientAdd(const shared_ptr<ConnectedClient> &invoker, const shared_ptr<ConnectedClient> &client, const shared_ptr<Group> &group) {
|
||||||
|
@ -598,7 +598,7 @@ bool Conversation::load_message_block_index(const std::shared_ptr<ts::server::co
|
|||||||
error = "failed to verify message header cookie at index " + to_string(offset);
|
error = "failed to verify message header cookie at index " + to_string(offset);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
index->message_index.emplace_back(fio::IndexedBlockMessage{(uint32_t) (offset - block->block_offset), header, nullptr});
|
index->message_index.emplace_back(fio::IndexedBlockMessage{(uint32_t) (offset - block->block_offset), {header}, nullptr});
|
||||||
offset += header.total_length;
|
offset += header.total_length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -645,6 +645,11 @@ bool Conversation::load_messages(const std::shared_ptr<db::MessageBlock> &block,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto result = fseek(this->file_handle, sizeof(fio::MessageHeader), SEEK_CUR);
|
||||||
|
if(result == EINVAL) {
|
||||||
|
error = "failed to seek to begin of the message data";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto data = make_shared<fio::IndexedMessageData>();
|
auto data = make_shared<fio::IndexedMessageData>();
|
||||||
if(header->meta_encrypted) {
|
if(header->meta_encrypted) {
|
||||||
@ -985,9 +990,9 @@ void Conversation::db_save_block(const std::shared_ptr<db::MessageBlock> &block)
|
|||||||
sql_result.waitAndGetLater(LOG_SQL_CMD, {-1, "future error"});
|
sql_result.waitAndGetLater(LOG_SQL_CMD, {-1, "future error"});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Conversation::register_message(ts::ClientDbId sender_database_id, const std::string &sender_unique_id, const std::string &sender_name, const std::string &message) {
|
void Conversation::register_message(ts::ClientDbId sender_database_id, const std::string &sender_unique_id, const std::string &sender_name, const std::chrono::system_clock::time_point &ts, const std::string &message) {
|
||||||
auto entry = make_shared<ConversationEntry>();
|
auto entry = make_shared<ConversationEntry>();
|
||||||
entry->message_timestamp = system_clock::now();
|
entry->message_timestamp = ts;
|
||||||
this->_last_message_timestamp = entry->message_timestamp;
|
this->_last_message_timestamp = entry->message_timestamp;
|
||||||
entry->message = message;
|
entry->message = message;
|
||||||
entry->sender_name = sender_name;
|
entry->sender_name = sender_name;
|
||||||
@ -1156,7 +1161,7 @@ size_t Conversation::delete_messages(const std::chrono::system_clock::time_point
|
|||||||
if(cldbid != 0 && (*it)->sender_database_id != cldbid)
|
if(cldbid != 0 && (*it)->sender_database_id != cldbid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
(*it)->flag_message_deleted = false;
|
(*it)->flag_message_deleted = true;
|
||||||
if(++delete_count_volatile >= message_count)
|
if(++delete_count_volatile >= message_count)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ namespace ts {
|
|||||||
ssize_t history_length() { return this->_history_length; }
|
ssize_t history_length() { return this->_history_length; }
|
||||||
|
|
||||||
inline std::chrono::system_clock::time_point last_message() { return this->_last_message_timestamp; }
|
inline std::chrono::system_clock::time_point last_message() { return this->_last_message_timestamp; }
|
||||||
void register_message(ClientDbId sender_database_id, const std::string& sender_unique_id, const std::string& sender_name, const std::string& message);
|
void register_message(ClientDbId sender_database_id, const std::string& sender_unique_id, const std::string& sender_name, const std::chrono::system_clock::time_point& /* timestamp */, const std::string& message);
|
||||||
/* Lookup n messages since end timestamp. Upper time limit is begin timestamp */
|
/* Lookup n messages since end timestamp. Upper time limit is begin timestamp */
|
||||||
std::deque<std::shared_ptr<ConversationEntry>> message_history(const std::chrono::system_clock::time_point& /* end timestamp */, size_t /* limit */, const std::chrono::system_clock::time_point& /* begin timestamp */);
|
std::deque<std::shared_ptr<ConversationEntry>> message_history(const std::chrono::system_clock::time_point& /* end timestamp */, size_t /* limit */, const std::chrono::system_clock::time_point& /* begin timestamp */);
|
||||||
|
|
||||||
|
@ -483,6 +483,8 @@ bool SqlDataManager::update_permissions(std::string &error) {
|
|||||||
return false;
|
return false;
|
||||||
if(!auto_update(permission::update::QUERY_ADMIN, "b_channel_create_modify_conversation_private", {1, true}, false, false, {100, true}))
|
if(!auto_update(permission::update::QUERY_ADMIN, "b_channel_create_modify_conversation_private", {1, true}, false, false, {100, true}))
|
||||||
return false;
|
return false;
|
||||||
|
if(!auto_update(permission::update::QUERY_ADMIN, "b_channel_conversation_message_delete", {1, true}, false, false, {100, true}))
|
||||||
|
return false;
|
||||||
|
|
||||||
if(!auto_update(permission::update::SERVER_ADMIN, "b_client_is_priority_speaker", {-2, false}, false, false, {75, true}))
|
if(!auto_update(permission::update::SERVER_ADMIN, "b_client_is_priority_speaker", {-2, false}, false, false, {75, true}))
|
||||||
return false;
|
return false;
|
||||||
@ -502,6 +504,8 @@ bool SqlDataManager::update_permissions(std::string &error) {
|
|||||||
return false;
|
return false;
|
||||||
if(!auto_update(permission::update::SERVER_ADMIN, "b_channel_create_modify_conversation_private", {1, true}, false, false, {75, true}))
|
if(!auto_update(permission::update::SERVER_ADMIN, "b_channel_create_modify_conversation_private", {1, true}, false, false, {75, true}))
|
||||||
return false;
|
return false;
|
||||||
|
if(!auto_update(permission::update::SERVER_ADMIN, "b_channel_conversation_message_delete", {1, true}, false, false, {75, true}))
|
||||||
|
return false;
|
||||||
|
|
||||||
if(!auto_update(permission::update::SERVER_NORMAL, "i_max_playlist_size", {50, true}, false, false, {-2, false}))
|
if(!auto_update(permission::update::SERVER_NORMAL, "i_max_playlist_size", {50, true}, false, false, {-2, false}))
|
||||||
return false;
|
return false;
|
||||||
|
@ -223,7 +223,7 @@ namespace terminal {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(const auto &cl : server->getClientsByChannel(channel))
|
for(const auto &cl : server->getClientsByChannel(channel))
|
||||||
cl->notifyTextMessage(ChatMessageMode::TEXTMODE_CHANNEL, server->getServerRoot(), cl->getClientId(), 0, message);
|
cl->notifyTextMessage(ChatMessageMode::TEXTMODE_CHANNEL, server->getServerRoot(), cl->getClientId(), 0, system_clock::now(), message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ChatMessageMode::TEXTMODE_PRIVATE:
|
case ChatMessageMode::TEXTMODE_PRIVATE:
|
||||||
@ -233,7 +233,7 @@ namespace terminal {
|
|||||||
logError("Cloud not find manager from clid");
|
logError("Cloud not find manager from clid");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
client->notifyTextMessage(ChatMessageMode::TEXTMODE_CHANNEL, server->getServerRoot(), client->getClientId(), 0, message);
|
client->notifyTextMessage(ChatMessageMode::TEXTMODE_CHANNEL, server->getServerRoot(), client->getClientId(), 0, system_clock::now(), message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
2
shared
2
shared
@ -1 +1 @@
|
|||||||
Subproject commit c8cae593a016b842031b5f73e103554a4f87cb66
|
Subproject commit 5c4df786ed9a2d3610c416f2d9c6e7a1fb07d5f0
|
Loading…
Reference in New Issue
Block a user