Make Doc type payload generic

This commit is contained in:
Alexis Sellier
2022-12-09 22:05:38 +01:00
parent 0b138f2c0c
commit cc942024ce
3 changed files with 10 additions and 9 deletions
+4 -4
View File
@@ -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,
+4 -3
View File
@@ -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;
}
+2 -2
View File
@@ -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 };