Block WS access if Matrix account is not linked

This commit is contained in:
2025-11-21 09:12:13 +01:00
parent 6b70842b61
commit 24f06a78a9
7 changed files with 26 additions and 4 deletions

View File

@@ -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,