Skip to content

Commit

Permalink
Don't check rate limit twice.
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines authored and Nutomic committed Mar 28, 2022
1 parent 66bfb2b commit 1ae4fe2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/websocket/src/chat_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,15 +485,15 @@ impl ChatServer {
UserOperationCrud::CreatePost => rate_limiter.post().check(ip),
UserOperationCrud::CreateCommunity => rate_limiter.register().check(ip),
UserOperationCrud::CreateComment => rate_limiter.comment().check(ip),
_ => rate_limiter.message().check(ip),
_ => true,
};
let fut = (message_handler_crud)(context, msg.id, user_operation_crud, data);
(passed, fut)
} else {
let user_operation = UserOperation::from_str(op)?;
let passed = match user_operation {
UserOperation::GetCaptcha => rate_limiter.post().check(ip),
_ => rate_limiter.message().check(ip),
_ => true,
};
let fut = (message_handler)(context, msg.id, user_operation, data);
(passed, fut)
Expand Down

0 comments on commit 1ae4fe2

Please sign in to comment.