[Server] Harden private chat history identity matching

Match both participants by account id and name so a federated user's remote id cannot collide with a local account, and stop storing foreign ids in the local chat log. Extract the paging assembly into a pure helper and cover the whole-second boundary rules with gtests.
This commit is contained in:
Lukas Brübach 2026-11-09 10:21:23 +01:00
parent d9852e13b4
commit 8276777496
9 changed files with 238 additions and 36 deletions

View file

@ -804,10 +804,13 @@ Response::ResponseCode Server_ProtocolHandler::cmdMessage(const Command_Message
userInterface->sendProtocolItem(*se);
rc.enqueuePreResponseItem(ServerMessage::SESSION_EVENT, se);
databaseInterface->logMessage(userInfo->id(), QString::fromStdString(userInfo->name()),
QString::fromStdString(userInfo->address()), QString::fromStdString(cmd.message()),
Server_DatabaseInterface::MessageTargetChat, userInterface->getUserInfo()->id(),
receiver);
databaseInterface->logMessage(
userInfo->id(), QString::fromStdString(userInfo->name()), QString::fromStdString(userInfo->address()),
QString::fromStdString(cmd.message()), Server_DatabaseInterface::MessageTargetChat,
// A federated user's id belongs to the remote server's
// database, not ours. Logging it would collide with a
// local id and corrupt local history lookups.
userInterface->getUserInfo()->server_id() == -1 ? userInterface->getUserInfo()->id() : 0, receiver);
resetIdleTimer();
return Response::RespOk;
}