diff --git a/Cargo.lock b/Cargo.lock index 4889a786..63d18012 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -316,9 +316,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" [[package]] name = "base64ct" @@ -1928,6 +1928,7 @@ dependencies = [ "axum", "axum-auth", "axum-server", + "base64 0.21.3", "chrono", "fastrand", "flate2", @@ -2981,7 +2982,7 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b11c96ac7ee530603dcdf68ed1557050f374ce55a5a07193ebf8cbc9f8927e9" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "log", "once_cell", "serde", diff --git a/radicle-cob/src/change/store.rs b/radicle-cob/src/change/store.rs index 43925c74..4cbf8dc4 100644 --- a/radicle-cob/src/change/store.rs +++ b/radicle-cob/src/change/store.rs @@ -206,7 +206,7 @@ impl Embed> { .into() } - /// Return am embed where the content is replaced by a content hash. + /// Return an embed where the content is replaced by a content hash. pub fn hashed>(&self) -> Embed { Embed { name: self.name.clone(), diff --git a/radicle-httpd/Cargo.toml b/radicle-httpd/Cargo.toml index 881784d3..762670e8 100644 --- a/radicle-httpd/Cargo.toml +++ b/radicle-httpd/Cargo.toml @@ -19,6 +19,7 @@ anyhow = { version = "1" } axum = { version = "0.6.7", default-features = false, features = ["headers", "json", "query", "tokio"] } axum-auth = { version= "0.4.0", default-features = false, features = ["auth-bearer"] } axum-server = { version = "0.5.1", default-features = false } +base64 = "0.21.3" chrono = { version = "0.4.22", default-features = false, features = ["clock"] } fastrand = { version = "2.0.0" } flate2 = { version = "1" } diff --git a/radicle-httpd/src/api.rs b/radicle-httpd/src/api.rs index 0d7bb5de..037b14ec 100644 --- a/radicle-httpd/src/api.rs +++ b/radicle-httpd/src/api.rs @@ -127,6 +127,12 @@ pub struct PaginationQuery { pub per_page: Option, } +#[derive(Serialize, Deserialize, Clone)] +#[serde(rename_all = "camelCase")] +pub struct RawQuery { + pub mime: Option, +} + #[derive(Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct CobsQuery { diff --git a/radicle-httpd/src/api/json.rs b/radicle-httpd/src/api/json.rs index d97bc3e2..da1469d0 100644 --- a/radicle-httpd/src/api/json.rs +++ b/radicle-httpd/src/api/json.rs @@ -12,7 +12,7 @@ use radicle::cob::patch::Review; use radicle::cob::patch::{Patch, PatchId}; use radicle::cob::thread; use radicle::cob::thread::CommentId; -use radicle::cob::{ActorId, Author, Reaction, Timestamp}; +use radicle::cob::{ActorId, Author, Embed, Reaction, Timestamp, Uri}; use radicle::git::RefString; use radicle::node::{Alias, AliasStore}; use radicle::prelude::NodeId; @@ -241,6 +241,7 @@ struct Comment<'a> { id: CommentId, author: Value, body: &'a str, + embeds: Vec>, reactions: Vec<(&'a ActorId, &'a Reaction)>, #[serde(with = "radicle::serde_ext::localtime::time")] timestamp: Timestamp, @@ -254,6 +255,7 @@ impl<'a> Comment<'a> { id: *id, author: author(&comment_author, aliases.alias(comment_author.id())), body: comment.body(), + embeds: comment.embeds().to_vec(), reactions: comment.reactions().collect::>(), timestamp: comment.timestamp(), reply_to: comment.reply_to(), diff --git a/radicle-httpd/src/api/v1/projects.rs b/radicle-httpd/src/api/v1/projects.rs index 2773db7c..f9eb37d6 100644 --- a/radicle-httpd/src/api/v1/projects.rs +++ b/radicle-httpd/src/api/v1/projects.rs @@ -7,13 +7,14 @@ use axum::response::IntoResponse; use axum::routing::{get, patch, post}; use axum::{Json, Router}; use axum_auth::AuthBearer; +use base64::prelude::{Engine, BASE64_STANDARD}; use hyper::StatusCode; use radicle_surf::blob::{Blob, BlobRef}; use serde::{Deserialize, Serialize}; use serde_json::json; use tower_http::set_header::SetResponseHeaderLayer; -use radicle::cob::{issue, patch, Label}; +use radicle::cob::{issue, patch, Embed, Label, Uri}; use radicle::identity::{Did, Id}; use radicle::node::routing::Store; use radicle::node::AliasStore; @@ -511,6 +512,7 @@ pub struct IssueCreate { pub description: String, pub labels: Vec