Revert "chore: Bump async-tungstenite to 0.23 (and tungstenite to 0.20.1) (#15039)" (#15048)

This reverts commit 4d65f7eea3.

Reverting because it causes auth with collab to break.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-07-23 18:22:37 -04:00 committed by GitHub
parent 855048041d
commit 6769e55ce0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 63 additions and 30 deletions

View file

@ -12,7 +12,7 @@ use crate::{
executor::Executor,
AppState, Error, RateLimit, RateLimiter, Result,
};
use anyhow::{anyhow, bail, Context as _};
use anyhow::{anyhow, Context as _};
use async_tungstenite::tungstenite::{
protocol::CloseFrame as TungsteniteCloseFrame, Message as TungsteniteMessage,
};
@ -1392,13 +1392,7 @@ pub async fn handle_websocket_request(
let socket = socket
.map_ok(to_tungstenite_message)
.err_into()
.with(|message| async move {
if let Some(message) = to_axum_message(message) {
Ok(message)
} else {
bail!("Could not convert a tungstenite message to axum message");
}
});
.with(|message| async move { Ok(to_axum_message(message)) });
let connection = Connection::new(Box::pin(socket));
async move {
server
@ -5160,21 +5154,16 @@ async fn get_private_user_info(
Ok(())
}
fn to_axum_message(message: TungsteniteMessage) -> Option<AxumMessage> {
fn to_axum_message(message: TungsteniteMessage) -> AxumMessage {
match message {
TungsteniteMessage::Text(payload) => Some(AxumMessage::Text(payload)),
TungsteniteMessage::Binary(payload) => Some(AxumMessage::Binary(payload)),
TungsteniteMessage::Ping(payload) => Some(AxumMessage::Ping(payload)),
TungsteniteMessage::Pong(payload) => Some(AxumMessage::Pong(payload)),
TungsteniteMessage::Close(frame) => {
Some(AxumMessage::Close(frame.map(|frame| AxumCloseFrame {
code: frame.code.into(),
reason: frame.reason,
})))
}
// we can ignore `Frame` frames as recommended by the tungstenite maintainers
// https://github.com/snapview/tungstenite-rs/issues/268
TungsteniteMessage::Frame(_) => None,
TungsteniteMessage::Text(payload) => AxumMessage::Text(payload),
TungsteniteMessage::Binary(payload) => AxumMessage::Binary(payload),
TungsteniteMessage::Ping(payload) => AxumMessage::Ping(payload),
TungsteniteMessage::Pong(payload) => AxumMessage::Pong(payload),
TungsteniteMessage::Close(frame) => AxumMessage::Close(frame.map(|frame| AxumCloseFrame {
code: frame.code.into(),
reason: frame.reason,
})),
}
}