From 095f1d48b049ea8ff8a4f87226062ac121443888 Mon Sep 17 00:00:00 2001 From: Luna Date: Tue, 14 Jul 2026 05:33:06 -0700 Subject: [PATCH] feat(remote): PeerTube browse passthroughs on RemoteClientKind pt_channels/pt_channel_videos/pt_video_media/pt_watch_url dispatch to the PeerTubeClient; Err for a catacomb remote. RemoteChannelInfo now Serialize. Co-Authored-By: Claude Opus 4.8 --- src/peertube.rs | 3 +-- src/remote.rs | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/peertube.rs b/src/peertube.rs index 2adeb74..624d790 100644 --- a/src/peertube.rs +++ b/src/peertube.rs @@ -24,8 +24,7 @@ struct OAuthTokens { } /// One channel in a PeerTube target's channel list. -#[derive(Clone, Debug, PartialEq)] -#[allow(dead_code)] // consumed by the browse UI in phase 3 +#[derive(Clone, Debug, PartialEq, serde::Serialize)] pub struct RemoteChannelInfo { pub handle: String, pub display_name: String, diff --git a/src/remote.rs b/src/remote.rs index 57eb9ac..42b956f 100644 --- a/src/remote.rs +++ b/src/remote.rs @@ -187,6 +187,30 @@ impl RemoteClientKind { Self::Peertube(_) => crate::config::RemoteKind::Peertube, } } + pub fn pt_channels(&self) -> Result, String> { + match self { + Self::Peertube(p) => p.list_channels(), + Self::Catacomb(_) => Err("not a PeerTube remote".into()), + } + } + pub fn pt_channel_videos(&self, handle: &str, page: usize) -> Result, String> { + match self { + Self::Peertube(p) => p.channel_videos(handle, page), + Self::Catacomb(_) => Err("not a PeerTube remote".into()), + } + } + pub fn pt_video_media(&self, uuid: &str) -> Result, String> { + match self { + Self::Peertube(p) => p.video_media(uuid), + Self::Catacomb(_) => Err("not a PeerTube remote".into()), + } + } + pub fn pt_watch_url(&self, uuid: &str) -> Result { + match self { + Self::Peertube(p) => Ok(p.watch_url(uuid)), + Self::Catacomb(_) => Err("not a PeerTube remote".into()), + } + } } /// Whether a relative URL points at peer media the read-only feed token grants @@ -329,4 +353,18 @@ mod tests { assert_eq!(b.kind(), RemoteKind::Peertube); assert_eq!(b.name(), "p"); } + + #[test] + fn peertube_passthroughs_reject_catacomb() { + use crate::config::{RemoteKind, RemoteSection}; + let cat = RemoteSection { + name: "c".into(), url: "http://p:8081".into(), + kind: RemoteKind::Catacomb, username: None, password: None, + }; + let k = RemoteClientKind::from_section(&cat); + assert!(k.pt_channels().is_err()); + assert!(k.pt_channel_videos("h", 0).is_err()); + assert!(k.pt_video_media("u").is_err()); + assert!(k.pt_watch_url("u").is_err()); + } }