From 6f20e93c3caa952f304dbaef862ceb60ffcf5253 Mon Sep 17 00:00:00 2001 From: xphoniex Date: Sun, 28 May 2023 09:06:47 +0000 Subject: [PATCH] node: Introduce `AliasStore` trait httpd: use the `AliasStore` trait Signed-off-by: xphoniex --- radicle-httpd/src/api/json.rs | 8 ++++---- radicle-httpd/src/api/v1/projects.rs | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/radicle-httpd/src/api/json.rs b/radicle-httpd/src/api/json.rs index 011ad99f2..1a2dbe622 100644 --- a/radicle-httpd/src/api/json.rs +++ b/radicle-httpd/src/api/json.rs @@ -14,7 +14,7 @@ use radicle::cob::thread; use radicle::cob::thread::{CommentId, Thread}; use radicle::cob::{ActorId, Author, Reaction, Timestamp}; use radicle::git::RefString; -use radicle::node::tracking::store as TrackingStore; +use radicle::node::AliasStore; use radicle::prelude::NodeId; use radicle::storage::{git, refs, ReadRepository}; use radicle_surf::blob::Blob; @@ -96,7 +96,7 @@ pub(crate) fn tree(tree: &Tree, path: &str, stats: &Stats) -> Value { } /// Returns JSON for an `issue`. -pub(crate) fn issue(id: IssueId, issue: Issue, aliases: &TrackingStore::Config) -> Value { +pub(crate) fn issue(id: IssueId, issue: Issue, aliases: &impl AliasStore) -> Value { json!({ "id": id.to_string(), "author": author(&issue.author(), aliases.alias(issue.author().id())), @@ -116,7 +116,7 @@ pub(crate) fn patch( id: PatchId, patch: Patch, repo: &git::Repository, - aliases: &TrackingStore::Config, + aliases: &impl AliasStore, ) -> Value { json!({ "id": id.to_string(), @@ -249,7 +249,7 @@ impl<'a> Comment<'a> { id: &'a CommentId, comment: &'a thread::Comment, thread: &'a Thread, - aliases: &TrackingStore::Config, + aliases: &impl AliasStore, ) -> Self { let comment_author = Author::new(comment.author()); Self { diff --git a/radicle-httpd/src/api/v1/projects.rs b/radicle-httpd/src/api/v1/projects.rs index 38653962d..41487f1e9 100644 --- a/radicle-httpd/src/api/v1/projects.rs +++ b/radicle-httpd/src/api/v1/projects.rs @@ -15,6 +15,7 @@ use tower_http::set_header::SetResponseHeaderLayer; use radicle::cob::{issue, patch, thread, ActorId, Tag}; use radicle::identity::Id; use radicle::node::routing::Store; +use radicle::node::AliasStore; use radicle::node::NodeId; use radicle::storage::git::paths; use radicle::storage::{ReadRepository, ReadStorage, WriteRepository}; @@ -456,7 +457,7 @@ async fn issues_handler( let tracking_store = &ctx.profile.tracking()?; let issues = issues .into_iter() - .map(|(id, issue, _)| api::json::issue(id, issue, tracking_store)) + .map(|(id, issue, _)| api::json::issue(id, issue, &tracking_store)) .skip(page * per_page) .take(per_page) .collect::>(); @@ -578,7 +579,7 @@ async fn issue_handler( Ok::<_, Error>(Json(api::json::issue( issue_id.into(), issue, - tracking_store, + &tracking_store, ))) } @@ -740,7 +741,7 @@ async fn patches_handler( let tracking_store = &ctx.profile.tracking()?; let patches = patches .into_iter() - .map(|(id, patch, _)| api::json::patch(id, patch, &repo, tracking_store)) + .map(|(id, patch, _)| api::json::patch(id, patch, &repo, &tracking_store)) .skip(page * per_page) .take(per_page) .collect::>(); @@ -765,7 +766,7 @@ async fn patch_handler( patch_id.into(), patch, &repo, - tracking_store, + &tracking_store, ))) }