httpd: Allow edit revision embeds
This commit is contained in:
parent
5331cf3bcf
commit
ee3dcfacf0
|
|
@ -1,6 +1,6 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use radicle::cob::patch;
|
use radicle::cob::{patch, resolve_embed};
|
||||||
use radicle::prelude::*;
|
use radicle::prelude::*;
|
||||||
use radicle::storage::git::Repository;
|
use radicle::storage::git::Repository;
|
||||||
|
|
||||||
|
|
@ -38,13 +38,18 @@ pub fn run(
|
||||||
|
|
||||||
let (root, _) = patch.root();
|
let (root, _) = patch.root();
|
||||||
let target = patch.target();
|
let target = patch.target();
|
||||||
|
let embeds = patch
|
||||||
|
.embeds()
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|embed| resolve_embed(repository, embed.clone()))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
patch.transaction("Edit", &signer, |tx| {
|
patch.transaction("Edit", &signer, |tx| {
|
||||||
if let Some(t) = title {
|
if let Some(t) = title {
|
||||||
tx.edit(t, target)?;
|
tx.edit(t, target)?;
|
||||||
}
|
}
|
||||||
if let Some(d) = description {
|
if let Some(d) = description {
|
||||||
tx.edit_revision(root, d, Vec::default())?;
|
tx.edit_revision(root, d, embeds)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tower_http::set_header::SetResponseHeaderLayer;
|
use tower_http::set_header::SetResponseHeaderLayer;
|
||||||
|
|
||||||
use radicle::cob::{issue, patch, Embed, Label, Uri};
|
use radicle::cob::{issue, patch, resolve_embed, Embed, Label, Uri};
|
||||||
use radicle::identity::{Did, Id, Visibility};
|
use radicle::identity::{Did, Id, Visibility};
|
||||||
use radicle::node::routing::Store;
|
use radicle::node::routing::Store;
|
||||||
use radicle::node::{AliasStore, Node, NodeId};
|
use radicle::node::{AliasStore, Node, NodeId};
|
||||||
|
|
@ -24,7 +24,7 @@ use radicle_surf::{diff, Glob, Oid, Repository};
|
||||||
|
|
||||||
use crate::api::error::Error;
|
use crate::api::error::Error;
|
||||||
use crate::api::project::Info;
|
use crate::api::project::Info;
|
||||||
use crate::api::{self, announce_refs, resolve_embed, CobsQuery, Context, PaginationQuery};
|
use crate::api::{self, announce_refs, CobsQuery, Context, PaginationQuery};
|
||||||
use crate::axum_extra::{Path, Query};
|
use crate::axum_extra::{Path, Query};
|
||||||
|
|
||||||
const CACHE_1_HOUR: &str = "public, max-age=3600, must-revalidate";
|
const CACHE_1_HOUR: &str = "public, max-age=3600, must-revalidate";
|
||||||
|
|
@ -844,7 +844,14 @@ async fn patch_update_handler(
|
||||||
patch::Action::RevisionEdit {
|
patch::Action::RevisionEdit {
|
||||||
revision,
|
revision,
|
||||||
description,
|
description,
|
||||||
} => patch.edit_revision(revision, description, &signer)?,
|
embeds,
|
||||||
|
} => {
|
||||||
|
let embeds: Vec<Embed> = embeds
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|embed| resolve_embed(&repo, embed))
|
||||||
|
.collect();
|
||||||
|
patch.edit_revision(revision, description, embeds, &signer)?
|
||||||
|
}
|
||||||
patch::Action::RevisionRedact { revision } => patch.redact(revision, &signer)?,
|
patch::Action::RevisionRedact { revision } => patch.redact(revision, &signer)?,
|
||||||
patch::Action::RevisionComment {
|
patch::Action::RevisionComment {
|
||||||
revision,
|
revision,
|
||||||
|
|
|
||||||
|
|
@ -442,6 +442,12 @@ impl Patch {
|
||||||
r.description()
|
r.description()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Patch embeds.
|
||||||
|
pub fn embeds(&self) -> &Vec<Embed<Uri>> {
|
||||||
|
let (_, r) = self.root();
|
||||||
|
r.embeds()
|
||||||
|
}
|
||||||
|
|
||||||
/// Author of the first revision of the patch.
|
/// Author of the first revision of the patch.
|
||||||
pub fn author(&self) -> &Author {
|
pub fn author(&self) -> &Author {
|
||||||
&self.author
|
&self.author
|
||||||
|
|
@ -1302,6 +1308,10 @@ impl Revision {
|
||||||
self.description.last().body.as_str()
|
self.description.last().body.as_str()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn embeds(&self) -> &Vec<Embed<Uri>> {
|
||||||
|
&self.description.last().embeds
|
||||||
|
}
|
||||||
|
|
||||||
/// Author of the revision.
|
/// Author of the revision.
|
||||||
pub fn author(&self) -> &Author {
|
pub fn author(&self) -> &Author {
|
||||||
&self.author
|
&self.author
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue