Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Make `Doc` type payload generic
Alexis Sellier committed 3 years ago
commit cc942024ce6a7fa4436e0e37cebf328908ccf400
parent 0b138f2c0c0720557b469b83dd594b0a72cc51b2
3 files changed +10 -9
modified radicle-httpd/src/api.rs
@@ -17,7 +17,7 @@ use tower_http::trace::TraceLayer;
use tracing::Span;

use radicle::cob::issue::Issues;
-
use radicle::identity::{Doc, Id};
+
use radicle::identity::Id;
use radicle::storage::{ReadRepository, WriteStorage};
use radicle::Profile;

@@ -49,7 +49,7 @@ impl Context {
        let storage = &self.profile.storage;
        let repo = storage.repository(id)?;
        let (_, head) = repo.head()?;
-
        let Doc { payload, .. } = repo.project_of(self.profile.id())?;
+
        let payload = repo.project_of(self.profile.id())?;
        let issues = (Issues::open(self.profile.public_key, &repo)?).count()?;

        Ok(project::Info {
@@ -142,7 +142,7 @@ pub struct PaginationQuery {

mod project {
    use radicle::git::Oid;
-
    use radicle::identity::project::Payload;
+
    use radicle::identity::project::Project;
    use radicle::identity::Id;
    use serde::Serialize;

@@ -152,7 +152,7 @@ mod project {
    pub struct Info {
        /// Project metadata.
        #[serde(flatten)]
-
        pub payload: Payload,
+
        pub payload: Project,
        pub head: Oid,
        pub patches: usize,
        pub issues: usize,
modified radicle-httpd/src/api/v1/delegates.rs
@@ -3,7 +3,7 @@ use axum::routing::get;
use axum::{Extension, Json, Router};

use radicle::cob::issue::Issues;
-
use radicle::identity::{Did, Doc};
+
use radicle::identity::Did;
use radicle::storage::{ReadRepository, WriteStorage};

use crate::api::axum_extra::{Path, Query};
@@ -38,9 +38,10 @@ async fn delegates_projects_handler(
        .filter_map(|id| {
            let Ok(repo) = storage.repository(id) else { return None };
            let Ok((_, head)) = repo.head() else { return None };
-
            let Ok(Doc { payload, delegates, .. }) = repo.project_of(ctx.profile.id()) else { return None };
+
            let Ok(doc) = repo.identity_of(ctx.profile.id()) else { return None };
+
            let Ok(payload) = doc.project() else { return None };

-
            if !delegates.iter().any(|d| *d == delegate) {
+
            if !doc.delegates.iter().any(|d| *d == delegate) {
                return None;
            }

modified radicle-httpd/src/api/v1/projects.rs
@@ -14,7 +14,7 @@ use radicle::cob::issue::Issues;
use radicle::cob::thread::{self, CommentId};
use radicle::cob::Timestamp;
use radicle::git::raw::BranchType;
-
use radicle::identity::{Doc, Id, PublicKey};
+
use radicle::identity::{Id, PublicKey};
use radicle::node::NodeId;
use radicle::storage::{Oid, ReadRepository, WriteRepository, WriteStorage};
use radicle_surf::git::History;
@@ -68,7 +68,7 @@ async fn project_root_handler(
        .filter_map(|id| {
            let Ok(repo) = storage.repository(id) else { return None };
            let Ok((_, head)) = repo.head() else { return None };
-
            let Ok(Doc { payload, .. }) = repo.project_of(ctx.profile.id()) else { return None };
+
            let Ok(payload) = repo.project_of(ctx.profile.id()) else { return None };
            let Ok(issues) = Issues::open(ctx.profile.public_key, &repo) else { return None };
            let Ok(issues) = (*issues).count() else { return None };