diff --git a/radicle-httpd/src/api.rs b/radicle-httpd/src/api.rs index ef8586f55..8c45aa30a 100644 --- a/radicle-httpd/src/api.rs +++ b/radicle-httpd/src/api.rs @@ -9,19 +9,18 @@ use axum::http::Method; use axum::response::{IntoResponse, Json}; use axum::routing::get; use axum::Router; -use base64::prelude::{Engine, BASE64_STANDARD}; use serde::{Deserialize, Serialize}; use serde_json::json; use tokio::sync::RwLock; use tower_http::cors::{self, CorsLayer}; -use radicle::cob::{issue, Uri}; -use radicle::cob::{patch, Embed}; +use radicle::cob::issue; +use radicle::cob::patch; use radicle::identity::{DocAt, Id}; use radicle::node::policy::Scope; use radicle::node::routing::Store; use radicle::node::{Handle, NodeId}; -use radicle::storage::{Oid, ReadRepository, ReadStorage}; +use radicle::storage::{ReadRepository, ReadStorage}; use radicle::{Node, Profile}; mod error; @@ -217,32 +216,6 @@ mod project { } } -/// A `data:` URI. -#[derive(Debug, Clone)] -pub struct DataUri(Vec); - -impl From for Vec { - fn from(value: DataUri) -> Self { - value.0 - } -} - -impl TryFrom<&Uri> for DataUri { - type Error = Uri; - - fn try_from(value: &Uri) -> Result { - if let Some(data_uri) = value.as_str().strip_prefix("data:") { - let (_, uri_data) = data_uri.split_once(',').ok_or(value.clone())?; - let uri_data = BASE64_STANDARD - .decode(uri_data) - .map_err(|_| value.clone())?; - - return Ok(DataUri(uri_data)); - } - Err(value.clone()) - } -} - /// Announce refs to the network for the given RID. pub fn announce_refs(mut node: Node, rid: Id) -> Result<(), Error> { match node.announce_refs(rid) { @@ -251,21 +224,3 @@ pub fn announce_refs(mut node: Node, rid: Id) -> Result<(), Error> { Err(e) => Err(e.into()), } } - -/// Resolve an embed with a URI to one with actual data. -pub fn resolve_embed(repo: &impl ReadRepository, embed: Embed) -> Option>> { - DataUri::try_from(&embed.content) - .ok() - .map(|content| Embed { - name: embed.name.clone(), - content: content.into(), - }) - .or_else(|| { - Oid::try_from(&embed.content).ok().and_then(|oid| { - repo.blob(oid).ok().map(|blob| Embed { - name: embed.name, - content: blob.content().to_vec(), - }) - }) - }) -}