mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 11:21:32 +00:00
Adding websocket blocking.
This commit is contained in:
parent
809cc1049e
commit
6b58080067
1 changed files with 11 additions and 3 deletions
|
@ -896,10 +896,18 @@ where
|
||||||
|
|
||||||
let data = data.to_string();
|
let data = data.to_string();
|
||||||
let op2 = op.clone();
|
let op2 = op.clone();
|
||||||
|
|
||||||
let fut = async move {
|
let fut = async move {
|
||||||
|
actix_web::web::block(move || {
|
||||||
let parsed_data: Data = serde_json::from_str(&data)?;
|
let parsed_data: Data = serde_json::from_str(&data)?;
|
||||||
let res = Oper::new(parsed_data).perform(pool, Some(ws_info))?;
|
let res = Oper::new(parsed_data).perform(pool, Some(ws_info))?;
|
||||||
to_json_string(&op, &res)
|
to_json_string(&op, &res)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|e| match e {
|
||||||
|
actix_web::error::BlockingError::Error(e) => e,
|
||||||
|
_ => APIError::err("Operation canceled").into(),
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
match op2 {
|
match op2 {
|
||||||
|
|
Loading…
Reference in a new issue