From d446869a281337ea6efd05ce16669f79eb9992a4 Mon Sep 17 00:00:00 2001 From: videogame hacker Date: Fri, 3 Dec 2021 20:51:06 +0000 Subject: [PATCH] Get rid of legacy state change endpoints --- src/main.rs | 60 ++--------------------------------------------------- 1 file changed, 2 insertions(+), 58 deletions(-) diff --git a/src/main.rs b/src/main.rs index cbda565..78824e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,9 +12,8 @@ mod watch_session; use serde::Deserialize; use crate::{ - events::{WatchEvent, WatchEventData}, - viewer_connection::{ws_publish, ws_subscribe}, - watch_session::{get_session, handle_watch_event_data, SubtitleTrack, WatchSession, SESSIONS}, + viewer_connection::ws_subscribe, + watch_session::{get_session, SubtitleTrack, WatchSession, SESSIONS}, }; #[derive(Deserialize)] @@ -79,59 +78,6 @@ async fn main() { RequestedSession::Error(e) => e, }); - let set_playing_route = get_running_session - .and(warb::path!("playing")) - .and(warb::put()) - .and(warb::body::json()) - .map(|requested_session, playing: bool| match requested_session { - RequestedSession::Session(uuid, mut sess) => { - let data = WatchEventData::SetPlaying { - playing, - time: sess.get_time_ms(), - }; - - handle_watch_event_data(uuid, &mut sess, data.clone()); - tokio::spawn(ws_publish( - uuid, - None, - WatchEvent { - user: None, - data, - reflected: false, - }, - )); - - warb::reply::with_status(warb::reply::json(&sess.view()), StatusCode::OK) - } - RequestedSession::Error(e) => e, - }); - - let set_timestamp_route = get_running_session - .and(warb::path!("current_time")) - .and(warb::put()) - .and(warb::body::json()) - .map( - |requested_session, current_time_ms: u64| match requested_session { - RequestedSession::Session(uuid, mut sess) => { - let data = WatchEventData::SetTime(current_time_ms); - - handle_watch_event_data(uuid, &mut sess, data.clone()); - tokio::spawn(ws_publish( - uuid, - None, - WatchEvent { - user: None, - data, - reflected: false, - }, - )); - - warb::reply::with_status(warb::reply::json(&sess.view()), StatusCode::OK) - } - RequestedSession::Error(e) => e, - }, - ); - let ws_subscribe_route = get_running_session .and(warb::path!("subscribe")) .and(warb::query()) @@ -147,8 +93,6 @@ async fn main() { let routes = start_session_route .or(get_status_route) - .or(set_playing_route) - .or(set_timestamp_route) .or(ws_subscribe_route) .or(warb::path::end().and(warb::fs::file("frontend/index.html"))) .or(warb::fs::dir("frontend"));