fix: WHIP not cleaning up
This commit is contained in:
@@ -201,7 +201,6 @@ async fn catalog_handler(
|
||||
user: x.stream_key_user.clone(),
|
||||
started_at: x.started_at,
|
||||
})
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>();
|
||||
Ok(Json(catalog))
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use crate::{
|
||||
pub async fn handle_whip_injest_delete(
|
||||
State(state): State<Arc<HttpServer>>,
|
||||
ConnectInfo(remote): ConnectInfo<SocketAddr>,
|
||||
Path(_slug): Path<String>,
|
||||
headers: HeaderMap,
|
||||
) -> Result<impl IntoResponse, HttpError> {
|
||||
let token = headers
|
||||
@@ -44,14 +45,19 @@ pub async fn handle_whip_injest_delete(
|
||||
.await?
|
||||
.ok_or(HttpError::Unauthorized)?;
|
||||
|
||||
let active_session = stream_session::Model::get_active_by_stream_key_id(&state.db, key.id)
|
||||
.await?
|
||||
.ok_or(HttpError::NotFound)?;
|
||||
// The detach task may have already cleaned up the session when ICE
|
||||
// disconnected (OBS closes the PeerConnection before sending DELETE).
|
||||
// Deleting an already-gone session is still a successful delete.
|
||||
if let Some(active_session) =
|
||||
stream_session::Model::get_active_by_stream_key_id(&state.db, key.id).await?
|
||||
{
|
||||
active_session
|
||||
.into_active_model()
|
||||
.finish_stream_session(&state.db, Utc::now())
|
||||
.await?;
|
||||
}
|
||||
|
||||
active_session
|
||||
.into_active_model()
|
||||
.finish_stream_session(&state.db, Utc::now())
|
||||
.await?;
|
||||
state.appstate.lock().await.stream_sessions.remove(&key.id);
|
||||
|
||||
Ok(StatusCode::OK)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user