mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-09 03:23:24 -08:00
[Servatrice] Relay room channel messages over ISL (#7480)
* [Servatrice] Relay room channel messages over ISL * [Servatrice] Skip audit log for unknown ISL channel per review - externalRoomSay drops messages for channels not in the local catalog, matching Server_Room::say, instead of logging what was never delivered --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
ce51e7147d
commit
155f7b0143
5 changed files with 34 additions and 9 deletions
|
|
@ -441,7 +441,7 @@ void Server::externalRoomUserLeft(int roomId, const QString &userName)
|
||||||
room->removeExternalUser(userName);
|
room->removeExternalUser(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::externalRoomSay(int roomId, const QString &userName, const QString &message)
|
void Server::externalRoomSay(int roomId, const QString &userName, const QString &message, const QString &channelId)
|
||||||
{
|
{
|
||||||
// This function is always called from the main thread via signal/slot.
|
// This function is always called from the main thread via signal/slot.
|
||||||
QReadLocker locker(&roomsLock);
|
QReadLocker locker(&roomsLock);
|
||||||
|
|
@ -451,10 +451,22 @@ void Server::externalRoomSay(int roomId, const QString &userName, const QString
|
||||||
qDebug() << "externalRoomSay: room id=" << roomId << "not found";
|
qDebug() << "externalRoomSay: room id=" << roomId << "not found";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
room->say(userName, message, QString(), false);
|
if (!channelId.isEmpty() && !Server_Room::isMainChannel(channelId) && room->findChannel(channelId) == nullptr) {
|
||||||
|
// The receiver does not know this channel; say() would drop it, so do
|
||||||
|
// not log what was never delivered.
|
||||||
|
qDebug() << "externalRoomSay: unknown channel" << channelId << "for room id=" << roomId << "dropping";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
room->say(userName, message, channelId, false);
|
||||||
|
|
||||||
getDatabaseInterface()->logMessage(0, userName, "ISL", message, Server_DatabaseInterface::MessageTargetIslRoom,
|
if (channelId.isEmpty()) {
|
||||||
room->getId(), room->getName());
|
getDatabaseInterface()->logMessage(0, userName, "ISL", message, Server_DatabaseInterface::MessageTargetIslRoom,
|
||||||
|
room->getId(), room->getName());
|
||||||
|
} else {
|
||||||
|
getDatabaseInterface()->logMessage(0, userName, "ISL", message,
|
||||||
|
Server_DatabaseInterface::MessageTargetRoomChannel, room->getId(),
|
||||||
|
room->getName(), channelId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::externalRoomRemoveMessages(int roomId, const QString &userName, int amount)
|
void Server::externalRoomRemoveMessages(int roomId, const QString &userName, int amount)
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@ protected slots:
|
||||||
void externalUserLeft(const QString &userName);
|
void externalUserLeft(const QString &userName);
|
||||||
void externalRoomUserJoined(int roomId, const ServerInfo_User &userInfo);
|
void externalRoomUserJoined(int roomId, const ServerInfo_User &userInfo);
|
||||||
void externalRoomUserLeft(int roomId, const QString &userName);
|
void externalRoomUserLeft(int roomId, const QString &userName);
|
||||||
void externalRoomSay(int roomId, const QString &userName, const QString &message);
|
void externalRoomSay(int roomId, const QString &userName, const QString &message, const QString &channelId);
|
||||||
void externalRoomRemoveMessages(int roomId, const QString &userName, int amount);
|
void externalRoomRemoveMessages(int roomId, const QString &userName, int amount);
|
||||||
void externalRoomGameListChanged(int roomId, const ServerInfo_Game &gameInfo);
|
void externalRoomGameListChanged(int roomId, const ServerInfo_Game &gameInfo);
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
#include <libcockatrice/protocol/pb/event_leave_room.pb.h>
|
#include <libcockatrice/protocol/pb/event_leave_room.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/event_list_games.pb.h>
|
#include <libcockatrice/protocol/pb/event_list_games.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/event_remove_messages.pb.h>
|
#include <libcockatrice/protocol/pb/event_remove_messages.pb.h>
|
||||||
|
#include <libcockatrice/protocol/pb/event_room_channel_say.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/event_room_say.pb.h>
|
#include <libcockatrice/protocol/pb/event_room_say.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/event_server_complete_list.pb.h>
|
#include <libcockatrice/protocol/pb/event_server_complete_list.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/event_user_joined.pb.h>
|
#include <libcockatrice/protocol/pb/event_user_joined.pb.h>
|
||||||
|
|
@ -383,7 +384,14 @@ void IslInterface::roomEvent_UserLeft(int roomId, const Event_LeaveRoom &event)
|
||||||
|
|
||||||
void IslInterface::roomEvent_Say(int roomId, const Event_RoomSay &event)
|
void IslInterface::roomEvent_Say(int roomId, const Event_RoomSay &event)
|
||||||
{
|
{
|
||||||
emit externalRoomSay(roomId, QString::fromStdString(event.name()), QString::fromStdString(event.message()));
|
emit externalRoomSay(roomId, QString::fromStdString(event.name()), QString::fromStdString(event.message()),
|
||||||
|
QString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void IslInterface::roomEvent_ChannelSay(int roomId, const Event_RoomChannelSay &event)
|
||||||
|
{
|
||||||
|
emit externalRoomSay(roomId, QString::fromStdString(event.name()), QString::fromStdString(event.message()),
|
||||||
|
QString::fromStdString(event.channel_id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IslInterface::roomEvent_ListGames(int roomId, const Event_ListGames &event)
|
void IslInterface::roomEvent_ListGames(int roomId, const Event_ListGames &event)
|
||||||
|
|
@ -459,6 +467,9 @@ void IslInterface::processRoomEvent(const RoomEvent &event)
|
||||||
case RoomEvent::ROOM_SAY:
|
case RoomEvent::ROOM_SAY:
|
||||||
roomEvent_Say(event.room_id(), event.GetExtension(Event_RoomSay::ext));
|
roomEvent_Say(event.room_id(), event.GetExtension(Event_RoomSay::ext));
|
||||||
break;
|
break;
|
||||||
|
case RoomEvent::ROOM_CHANNEL_SAY:
|
||||||
|
roomEvent_ChannelSay(event.room_id(), event.GetExtension(Event_RoomChannelSay::ext));
|
||||||
|
break;
|
||||||
case RoomEvent::LIST_GAMES:
|
case RoomEvent::LIST_GAMES:
|
||||||
roomEvent_ListGames(event.room_id(), event.GetExtension(Event_ListGames::ext));
|
roomEvent_ListGames(event.room_id(), event.GetExtension(Event_ListGames::ext));
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ class Event_UserLeft;
|
||||||
class Event_JoinRoom;
|
class Event_JoinRoom;
|
||||||
class Event_LeaveRoom;
|
class Event_LeaveRoom;
|
||||||
class Event_RoomSay;
|
class Event_RoomSay;
|
||||||
|
class Event_RoomChannelSay;
|
||||||
class Event_ListGames;
|
class Event_ListGames;
|
||||||
class Event_RemoveMessages;
|
class Event_RemoveMessages;
|
||||||
class Command_JoinGame;
|
class Command_JoinGame;
|
||||||
|
|
@ -49,7 +50,7 @@ signals:
|
||||||
void externalUserLeft(QString userName);
|
void externalUserLeft(QString userName);
|
||||||
void externalRoomUserJoined(int roomId, ServerInfo_User userInfo);
|
void externalRoomUserJoined(int roomId, ServerInfo_User userInfo);
|
||||||
void externalRoomUserLeft(int roomId, QString userName);
|
void externalRoomUserLeft(int roomId, QString userName);
|
||||||
void externalRoomSay(int roomId, QString userName, QString message);
|
void externalRoomSay(int roomId, QString userName, QString message, QString channelId);
|
||||||
void externalRoomGameListChanged(int roomId, ServerInfo_Game gameInfo);
|
void externalRoomGameListChanged(int roomId, ServerInfo_Game gameInfo);
|
||||||
void externalRoomRemoveMessages(int roomId, QString userName, int amount);
|
void externalRoomRemoveMessages(int roomId, QString userName, int amount);
|
||||||
void joinGameCommandReceived(const Command_JoinGame &cmd, int cmdId, int roomId, int serverId, qint64 sessionId);
|
void joinGameCommandReceived(const Command_JoinGame &cmd, int cmdId, int roomId, int serverId, qint64 sessionId);
|
||||||
|
|
@ -79,6 +80,7 @@ private:
|
||||||
void roomEvent_UserJoined(int roomId, const Event_JoinRoom &event);
|
void roomEvent_UserJoined(int roomId, const Event_JoinRoom &event);
|
||||||
void roomEvent_UserLeft(int roomId, const Event_LeaveRoom &event);
|
void roomEvent_UserLeft(int roomId, const Event_LeaveRoom &event);
|
||||||
void roomEvent_Say(int roomId, const Event_RoomSay &event);
|
void roomEvent_Say(int roomId, const Event_RoomSay &event);
|
||||||
|
void roomEvent_ChannelSay(int roomId, const Event_RoomChannelSay &event);
|
||||||
void roomEvent_ListGames(int roomId, const Event_ListGames &event);
|
void roomEvent_ListGames(int roomId, const Event_ListGames &event);
|
||||||
void roomEvent_RemoveMessages(int roomId, const Event_RemoveMessages &event);
|
void roomEvent_RemoveMessages(int roomId, const Event_RemoveMessages &event);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1078,8 +1078,8 @@ void Servatrice::addIslInterface(int _serverId, IslInterface *interface)
|
||||||
connect(interface, SIGNAL(externalRoomUserJoined(int, ServerInfo_User)), this,
|
connect(interface, SIGNAL(externalRoomUserJoined(int, ServerInfo_User)), this,
|
||||||
SLOT(externalRoomUserJoined(int, ServerInfo_User)));
|
SLOT(externalRoomUserJoined(int, ServerInfo_User)));
|
||||||
connect(interface, SIGNAL(externalRoomUserLeft(int, QString)), this, SLOT(externalRoomUserLeft(int, QString)));
|
connect(interface, SIGNAL(externalRoomUserLeft(int, QString)), this, SLOT(externalRoomUserLeft(int, QString)));
|
||||||
connect(interface, SIGNAL(externalRoomSay(int, QString, QString)), this,
|
connect(interface, SIGNAL(externalRoomSay(int, QString, QString, QString)), this,
|
||||||
SLOT(externalRoomSay(int, QString, QString)));
|
SLOT(externalRoomSay(int, QString, QString, QString)));
|
||||||
connect(interface, SIGNAL(externalRoomRemoveMessages(int, QString, int)), this,
|
connect(interface, SIGNAL(externalRoomRemoveMessages(int, QString, int)), this,
|
||||||
SLOT(externalRoomRemoveMessages(int, QString, int)));
|
SLOT(externalRoomRemoveMessages(int, QString, int)));
|
||||||
connect(interface, SIGNAL(externalRoomGameListChanged(int, ServerInfo_Game)), this,
|
connect(interface, SIGNAL(externalRoomGameListChanged(int, ServerInfo_Game)), this,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue