From 237e1e9adb3f8d80d21c65f00cfec13c7a8a1f22 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Thu, 17 Aug 2023 12:23:20 +0200 Subject: [PATCH] cob: Add support for media embeds in COBs This change allows for files (blobs) to be embedded into COB entries. This allows for things like image attachments in issue comments for example. For now, we only enable this in the `issue` COB. The way it works is that relevant COB actions carry metadata about which files are attached to them; and we store those files as blobs inside the COB entry's *tree* object, under an `embeds/` folder. The `Embed` type is used for the above, and either carries actual content, or carries a content-id. Retrieving the actual content is as simple as asking the repository for a blob with that content-id. As a possible future extension, MIME types could be stored alongside the files in a "metadata" file. This could help clients display the content appropriately. --- radicle-httpd/src/api/v1/projects.rs | 5 +++-- radicle-httpd/src/test.rs | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/radicle-httpd/src/api/v1/projects.rs b/radicle-httpd/src/api/v1/projects.rs index 9b930e728..d9e235fca 100644 --- a/radicle-httpd/src/api/v1/projects.rs +++ b/radicle-httpd/src/api/v1/projects.rs @@ -507,6 +507,7 @@ async fn issue_create_handler( issue.description, &issue.labels, &issue.assignees, + [], &signer, ) .map_err(Error::from)?; @@ -546,9 +547,9 @@ async fn issue_update_handler( issue::Action::Edit { title } => { issue.edit(title, &signer)?; } - issue::Action::Comment { body, reply_to } => { + issue::Action::Comment { body, reply_to, .. } => { if let Some(to) = reply_to { - issue.comment(body, to, &signer)?; + issue.comment(body, to, [], &signer)?; } else { return Err(Error::BadRequest("`replyTo` missing".to_owned())); } diff --git a/radicle-httpd/src/test.rs b/radicle-httpd/src/test.rs index 641096e28..08e52112e 100644 --- a/radicle-httpd/src/test.rs +++ b/radicle-httpd/src/test.rs @@ -185,6 +185,7 @@ fn seed_with_signer(dir: &Path, profile: radicle::Profile, signer: &G "Change 'hello world' to 'hello everyone'".to_string(), &[], &[], + [], signer, ) .unwrap();