diff --git a/libcockatrice_network/libcockatrice/network/server/remote/server_database_interface.h b/libcockatrice_network/libcockatrice/network/server/remote/server_database_interface.h index 9887ecd2f..802b9d3b7 100644 --- a/libcockatrice_network/libcockatrice/network/server/remote/server_database_interface.h +++ b/libcockatrice_network/libcockatrice/network/server/remote/server_database_interface.h @@ -2,7 +2,9 @@ #define SERVER_DATABASE_INTERFACE_H #include "libcockatrice/protocol/pb/serverinfo_ban.pb.h" +#include "libcockatrice/protocol/pb/serverinfo_chat_message.pb.h" #include "libcockatrice/protocol/pb/serverinfo_moderator_login.pb.h" +#include "libcockatrice/protocol/pb/serverinfo_private_chat_message.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" @@ -128,6 +130,33 @@ public: { return {}; } + virtual QList getMessageLogHistory(const QString & /* user */, + const QString & /* ipaddress */, + const QString & /* gamename */, + const QString & /* gameid */, + const QString & /* message */, + bool & /* chat */, + bool & /* game */, + bool & /* room */, + int & /* range */, + int & /* maxresults */, + int /* offset */ = 0, + const QString & /* beforeTime */ = QString(), + bool * /* hasMore */ = nullptr) + { + return {}; + } + virtual bool getPrivateChatHistory(int /* callerId */, + const QString & /* callerName */, + int /* peerId */, + const QString & /* peerName */, + quint64 /* before */, + int /* limit */, + QList & /* messages */, + bool & /* hasMore */) + { + return false; + } /** * @brief Whether the backing store is reachable, reconnecting when it is not. * diff --git a/servatrice/src/servatrice_database_interface.h b/servatrice/src/servatrice_database_interface.h index 9cfdcf4f5..f00a432a7 100644 --- a/servatrice/src/servatrice_database_interface.h +++ b/servatrice/src/servatrice_database_interface.h @@ -230,7 +230,7 @@ public: int &maxresults, int offset = 0, const QString &beforeTime = QString(), - bool *hasMore = nullptr); + bool *hasMore = nullptr) override; QList getUserSessions(const QString &userName, int limit) override; bool getPrivateChatHistory(int callerId, const QString &callerName, @@ -239,7 +239,7 @@ public: quint64 before, int limit, QList &messages, - bool &hasMore); + bool &hasMore) override; QList getUserAlts(const QString &userName, int depth = 1, bool useEmail = true, diff --git a/servatrice/src/serversocketinterface.cpp b/servatrice/src/serversocketinterface.cpp index 1bf9f85f0..9a6f0eebf 100644 --- a/servatrice/src/serversocketinterface.cpp +++ b/servatrice/src/serversocketinterface.cpp @@ -1722,7 +1722,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdGetPrivateChatHistory(c // Resolve the peer to an account id. Matching by name alone would merge the // conversations of everyone who has ever used that name. - const int peerId = sqlInterface->getUserIdInDB(peer); + const int peerId = databaseInterface->getUserId(peer); if (peerId < 1) { return Response::RespNameNotFound; } @@ -1730,8 +1730,8 @@ Response::ResponseCode AbstractServerSocketInterface::cmdGetPrivateChatHistory(c const int limit = qBound(1, cmd.limit(), 200); QList messages; bool hasMore = false; - if (!sqlInterface->getPrivateChatHistory(userInfo->id(), QString::fromStdString(userInfo->name()), peerId, peer, - cmd.before(), limit, messages, hasMore)) { + if (!databaseInterface->getPrivateChatHistory(userInfo->id(), QString::fromStdString(userInfo->name()), peerId, + peer, cmd.before(), limit, messages, hasMore)) { return Response::RespInternalError; } @@ -1793,8 +1793,8 @@ Response::ResponseCode AbstractServerSocketInterface::cmdGetLogHistory(const Com if (servatrice->getEnableLogQuery()) { bool hasMore = false; QList history = - sqlInterface->getMessageLogHistory(userName, ipAddress, gameName, gameID, message, chatType, gameType, - roomType, dateRange, maximumResults, offset, beforeTime, &hasMore); + databaseInterface->getMessageLogHistory(userName, ipAddress, gameName, gameID, message, chatType, gameType, + roomType, dateRange, maximumResults, offset, beforeTime, &hasMore); QListIterator messageIterator(history); while (messageIterator.hasNext()) { ServerInfo_ChatMessage chatMessage = messageIterator.next();