[Server] Expose moderation history reads on the database interface (#7829)

The ban/warn history, session, alt-account, and moderator-login readers existed only on Servatrice_DatabaseInterface, so the socket handler had to hold the concrete class to call them and to ask checkSql() whether the store was reachable. Declare them on Server_DatabaseInterface with empty-list defaults and a checkSql() that reports ready for stores without a connection, mark the Servatrice implementations as overrides, and let those five commands ask the injected interface.
This commit is contained in:
BruebachL 2026-11-10 12:16:21 +01:00 • committed by GitHub
parent 52d8f84ec8
commit 2ca3117765
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 56 additions and 16 deletions

View file

@ -1,7 +1,12 @@
#ifndef SERVER_DATABASE_INTERFACE_H
#define SERVER_DATABASE_INTERFACE_H
#include "libcockatrice/protocol/pb/serverinfo_ban.pb.h"
#include "libcockatrice/protocol/pb/serverinfo_moderator_login.pb.h"
#include "libcockatrice/protocol/pb/serverinfo_user.pb.h"
#include "libcockatrice/protocol/pb/serverinfo_user_alt.pb.h"
#include "libcockatrice/protocol/pb/serverinfo_user_session.pb.h"
#include "libcockatrice/protocol/pb/serverinfo_warning.pb.h"
#include "server.h"
#include <QMap>
@ -98,6 +103,41 @@ public:
{
return false;
}
virtual QList<ServerInfo_Ban> getUserBanHistory(const QString & /* userName */)
{
return {};
}
virtual QList<ServerInfo_Warning> getUserWarnHistory(const QString & /* userName */)
{
return {};
}
virtual QList<ServerInfo_UserSession> getUserSessions(const QString & /* userName */, int /* limit */)
{
return {};
}
virtual QList<ServerInfo_UserAlt> getUserAlts(const QString & /* userName */,
int /* depth */ = 1,
bool /* useEmail */ = true,
bool /* useClientId */ = true,
bool /* useIp */ = true,
int /* sessionMonths */ = 6)
{
return {};
}
virtual QList<ServerInfo_ModeratorLogin> getModeratorLastLogins()
{
return {};
}
/**
* @brief Whether the backing store is reachable, reconnecting when it is not.
*
* Implementations that cannot report readiness are always ready, so callers
* do not have to know which kind of store they hold.
*/
virtual bool checkSql()
{
return true;
}
virtual ServerInfo_User getUserData(const QString &name, bool withId = false) = 0;
virtual void storeGameInformation(const QString & /* roomName */,
const QStringList & /* roomGameTypes */,