[Server] Move buddy and ignore list writes into the database interface

cmdAddToList/cmdRemoveFromList issued raw SQL against the buddy and ignore tables and looked accounts up through getUserIdInDB, a method that only exists on the MySQL implementation. Add getUserId plus add/remove operations to Server_DatabaseInterface, implement them in Servatrice_DatabaseInterface over the shared single-row helpers, and let the handler ask the injected interface instead of the concrete class.
This commit is contained in:
Lukas Brübach 2026-11-09 17:26:07 +01:00
parent 9677c953a0
commit f825903a21
4 changed files with 77 additions and 12 deletions

View file

@ -67,6 +67,8 @@ private:
* backup key is unset or the sealed value does not fit the column. */
QString sealLegacyBackup(const QString &storedName, const QString &credential);
bool isStrictModeEnabled(bool &ok) const;
bool addToList(const QString &table, int userId, int targetId);
bool removeFromList(const QString &table, int userId, int targetId);
protected:
AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler,
@ -113,6 +115,11 @@ public:
/** @brief Drop every legacy password backup that has not been used within the TTL. */
void purgeExpiredLegacyBackups();
int getUserIdInDB(const QString &name);
int getUserId(const QString &name) override;
bool addToBuddyList(int userId, int targetId) override;
bool removeFromBuddyList(int userId, int targetId) override;
bool addToIgnoreList(int userId, int targetId) override;
bool removeFromIgnoreList(int userId, int targetId) override;
QMap<QString, ServerInfo_User> getBuddyList(const QString &name) override;
QMap<QString, ServerInfo_User> getIgnoreList(const QString &name) override;
bool isInBuddyList(const QString &whoseList, const QString &who) override;