diff options
author | metamuffin <metamuffin@disroot.org> | 2025-02-07 14:08:20 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-02-07 14:08:20 +0100 |
commit | 346095d20e3d817d150cbea49e87a49fbcaa2304 (patch) | |
tree | 1fc3868fa68287e916e511c8f5b43b62087f0ff9 /server/src/routes/ui/player.rs | |
parent | 976bdd8e2d14049c766a654a7575f9f5109c7395 (diff) | |
download | jellything-346095d20e3d817d150cbea49e87a49fbcaa2304.tar jellything-346095d20e3d817d150cbea49e87a49fbcaa2304.tar.bz2 jellything-346095d20e3d817d150cbea49e87a49fbcaa2304.tar.zst |
nodeid guard
Diffstat (limited to 'server/src/routes/ui/player.rs')
-rw-r--r-- | server/src/routes/ui/player.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/server/src/routes/ui/player.rs b/server/src/routes/ui/player.rs index b24e5e9..f680a45 100644 --- a/server/src/routes/ui/player.rs +++ b/server/src/routes/ui/player.rs @@ -20,7 +20,7 @@ use jellybase::{permission::PermissionSetExt, CONF}; use jellycommon::{ stream::{StreamFormat, StreamSpec}, user::{PermissionSet, PlayerKind, UserPermission}, - Node, SourceTrackKind, TrackID, + Node, NodeID, SourceTrackKind, TrackID, }; use markup::DynRender; use rocket::{get, response::Redirect, Either, FromForm, State, UriDisplayQuery}; @@ -61,12 +61,10 @@ fn jellynative_url(action: &str, seek: f64, secret: &str, node: &str, session: & pub fn r_player<'a>( sess: Session, db: &'a State<Database>, - id: &'a str, + id: NodeID, conf: PlayerConfig, ) -> MyResult<Either<DynLayoutPage<'a>, Redirect>> { - let item = db - .get_node_slug(id)? - .ok_or(anyhow!("node does not exist"))?; + let node = db.get_node(id)?.ok_or(anyhow!("node does not exist"))?; let native_session = |action: &str| { let perm = [ @@ -81,7 +79,7 @@ pub fn r_player<'a>( action, conf.t.unwrap_or(0.), &sess.user.native_secret, - id, + &id.to_string(), &token::create( sess.user.name, PermissionSet(perm.map(|e| (e, true)).into()), @@ -114,15 +112,15 @@ pub fn r_player<'a>( let playing = !spec.track.is_empty(); - let conf = player_conf(item.clone(), playing)?; + let conf = player_conf(node.clone(), playing)?; Ok(Either::Left(LayoutPage { - title: item.title.to_owned().unwrap_or_default(), + title: node.title.to_owned().unwrap_or_default(), class: Some("player"), content: markup::new! { @if playing { - video[src=uri!(r_stream(&id, &spec)), controls, preload="auto"]{} + video[src=uri!(r_stream(&node.slug, &spec)), controls, preload="auto"]{} } else { - img.backdrop[src=uri!(r_item_backdrop(&id, Some(2048))).to_string()]; + img.backdrop[src=uri!(r_item_backdrop(&node.slug, Some(2048))).to_string()]; } @conf }, |