This commit is contained in:
parent
c2bfa06faa
commit
a56ca40204
16 changed files with 816 additions and 234 deletions
|
|
@ -464,9 +464,24 @@ void ChatWebSocketController::handleChatMessage(const WebSocketConnectionPtr& ws
|
|||
selfDestructSeconds = 300;
|
||||
}
|
||||
|
||||
// Get connection info first to check if guest
|
||||
ConnectionInfo currentInfo;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(connectionsMutex_);
|
||||
auto it = connections_.find(wsConnPtr);
|
||||
if (it == connections_.end()) {
|
||||
return;
|
||||
}
|
||||
currentInfo = it->second;
|
||||
}
|
||||
|
||||
// Guests cannot send self-destructing messages
|
||||
if (currentInfo.isGuest && selfDestructSeconds > 0) {
|
||||
selfDestructSeconds = 0;
|
||||
}
|
||||
|
||||
// Re-fetch current connection info to prevent TOCTOU race conditions
|
||||
// (user could have been banned/disconnected since the initial copy)
|
||||
ConnectionInfo currentInfo;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(connectionsMutex_);
|
||||
auto it = connections_.find(wsConnPtr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue