[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:
BruebachL 2026-10-16 22:46:40 +02:00 • committed by GitHub
parent ce51e7147d
commit 155f7b0143
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 34 additions and 9 deletions

View file

@ -441,7 +441,7 @@ void Server::externalRoomUserLeft(int roomId, const QString &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.
QReadLocker locker(&roomsLock);
@ -451,10 +451,22 @@ void Server::externalRoomSay(int roomId, const QString &userName, const QString
qDebug() << "externalRoomSay: room id=" << roomId << "not found";
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,
room->getId(), room->getName());
if (channelId.isEmpty()) {
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)

View file

@ -265,7 +265,7 @@ protected slots:
void externalUserLeft(const QString &userName);
void externalRoomUserJoined(int roomId, const ServerInfo_User &userInfo);
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 externalRoomGameListChanged(int roomId, const ServerInfo_Game &gameInfo);
void

View file

@ -36,6 +36,7 @@
#include <libcockatrice/protocol/pb/event_leave_room.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_room_channel_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_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)
{
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)
@ -459,6 +467,9 @@ void IslInterface::processRoomEvent(const RoomEvent &event)
case RoomEvent::ROOM_SAY:
roomEvent_Say(event.room_id(), event.GetExtension(Event_RoomSay::ext));
break;
case RoomEvent::ROOM_CHANNEL_SAY:
roomEvent_ChannelSay(event.room_id(), event.GetExtension(Event_RoomChannelSay::ext));
break;
case RoomEvent::LIST_GAMES:
roomEvent_ListGames(event.room_id(), event.GetExtension(Event_ListGames::ext));
break;

View file

@ -26,6 +26,7 @@ class Event_UserLeft;
class Event_JoinRoom;
class Event_LeaveRoom;
class Event_RoomSay;
class Event_RoomChannelSay;
class Event_ListGames;
class Event_RemoveMessages;
class Command_JoinGame;
@ -49,7 +50,7 @@ signals:
void externalUserLeft(QString userName);
void externalRoomUserJoined(int roomId, ServerInfo_User userInfo);
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 externalRoomRemoveMessages(int roomId, QString userName, int amount);
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_UserLeft(int roomId, const Event_LeaveRoom &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_RemoveMessages(int roomId, const Event_RemoveMessages &event);

View file

@ -1078,8 +1078,8 @@ void Servatrice::addIslInterface(int _serverId, IslInterface *interface)
connect(interface, SIGNAL(externalRoomUserJoined(int, ServerInfo_User)), this,
SLOT(externalRoomUserJoined(int, ServerInfo_User)));
connect(interface, SIGNAL(externalRoomUserLeft(int, QString)), this, SLOT(externalRoomUserLeft(int, QString)));
connect(interface, SIGNAL(externalRoomSay(int, QString, QString)), this,
SLOT(externalRoomSay(int, QString, QString)));
connect(interface, SIGNAL(externalRoomSay(int, QString, QString, QString)), this,
SLOT(externalRoomSay(int, QString, QString, QString)));
connect(interface, SIGNAL(externalRoomRemoveMessages(int, QString, int)), this,
SLOT(externalRoomRemoveMessages(int, QString, int)));
connect(interface, SIGNAL(externalRoomGameListChanged(int, ServerInfo_Game)), this,