Block WS access if Matrix account is not linked
This commit is contained in:
@@ -6,7 +6,7 @@ use crate::extractors::matrix_client_extractor::MatrixClientExtractor;
|
||||
use crate::matrix_connection::matrix_client::MatrixClient;
|
||||
use crate::matrix_connection::matrix_manager::MatrixManagerMsg;
|
||||
use actix_web::dev::Payload;
|
||||
use actix_web::{FromRequest, HttpRequest, web};
|
||||
use actix_web::{FromRequest, HttpRequest, HttpResponse, web};
|
||||
use actix_ws::Message;
|
||||
use futures_util::StreamExt;
|
||||
use matrix_sdk::ruma::OwnedRoomId;
|
||||
@@ -38,6 +38,11 @@ pub async fn ws(
|
||||
// Forcefully ignore request payload by manually extracting authentication information
|
||||
let client = MatrixClientExtractor::from_request(&req, &mut Payload::None).await?;
|
||||
|
||||
// Check if Matrix link has been established first
|
||||
if !client.client.is_client_connected() {
|
||||
return Ok(HttpResponse::ExpectationFailed().json("Matrix link not established yet!"));
|
||||
}
|
||||
|
||||
// Ensure sync thread is started
|
||||
ractor::cast!(
|
||||
manager,
|
||||
|
||||
Reference in New Issue
Block a user