Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
httpd: Add review ids to review json
Sebastian Martinez committed 2 years ago
commit 9abad78582b1ad3e3fef56ce1c7de1b5826afcb3
parent 4496b80b3ebc785c04fb9b6d6568f6b0e6ab66d5
2 files changed +13 -5
modified radicle-httpd/src/api/json.rs
@@ -6,6 +6,7 @@ use std::str;

use base64::prelude::{Engine, BASE64_STANDARD};
use radicle::cob::{CodeLocation, Reaction};
+
use radicle::patch::ReviewId;
use serde_json::{json, Value};

use radicle::cob::issue::{Issue, IssueId};
@@ -137,15 +138,19 @@ pub(crate) fn patch(
                        acc
                    });
                    reactions.iter().map(|(emoji, authors)|
-
                        json!({"location": location, "emoji": emoji, "authors": authors })
+
                        json!({ "location": location, "emoji": emoji, "authors": authors })
                    ).collect::<Vec<_>>()
                }).collect::<Vec<_>>(),
                "base": rev.base(),
                "oid": rev.head(),
                "refs": get_refs(repo, patch.author().id(), &rev.head()).unwrap_or_default(),
-
                "discussions": rev.discussion().comments().map(|(id, c)| patch_comment(id, c,  aliases)).collect::<Vec<_>>(),
+
                "discussions": rev.discussion().comments().map(|(id, c)| {
+
                    patch_comment(id, c, aliases)
+
                }).collect::<Vec<_>>(),
                "timestamp": rev.timestamp().as_secs(),
-
                "reviews": rev.reviews().map(|(nid, r)| review(nid, r, aliases)).collect::<Vec<_>>(),
+
                "reviews": patch.reviews_of(id).map(move |(id, r)| {
+
                    review(id, r, aliases)
+
                }).collect::<Vec<_>>(),
            })
        }).collect::<Vec<_>>(),
    })
@@ -173,9 +178,11 @@ fn merge(nid: &NodeId, merge: &Merge, aliases: &impl AliasStore) -> Value {
}

/// Returns JSON for a patch `Review` and fills in `alias` when present.
-
fn review(nid: &NodeId, review: &Review, aliases: &impl AliasStore) -> Value {
+
fn review(id: &ReviewId, review: &Review, aliases: &impl AliasStore) -> Value {
+
    let a = review.author();
    json!({
-
        "author": author(&Author::from(*nid), aliases.alias(nid)),
+
        "id": id,
+
        "author": author(a, aliases.alias(a.id())),
        "verdict": review.verdict(),
        "summary": review.summary(),
        "comments": review.comments().map(|(id, c)| review_comment(id, c, aliases)).collect::<Vec<_>>(),
modified radicle-httpd/src/api/v1/projects.rs
@@ -3446,6 +3446,7 @@ mod routes {
                  "timestamp": TIMESTAMP,
                  "reviews": [
                    {
+
                      "id": "37ed60b8a11949d5db32bce3dd5ab117d3a82841",
                      "author": {
                          "id": CONTRIBUTOR_DID,
                      },