From 2496a1d93d88a921c5c210fcd38c2d80ff9da66c Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Tue, 4 Jul 2023 00:26:10 +0200 Subject: [PATCH] node: Make node aliases required This is a fairly substantial change, which adds a new configuration file to the user's `$RAD_HOME` that includes node configuration, including the alias, and also makes node aliases required. When running `rad auth`, the user is now prompted for an alias, which defaults to `$USER`. When running `rad self`, the alias is now shown. If the user runs radicle without a config file, the defaults are loaded, and `$USER` is used as the alias. --- radicle-httpd/src/api/json.rs | 8 ++++---- radicle-httpd/src/test.rs | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/radicle-httpd/src/api/json.rs b/radicle-httpd/src/api/json.rs index 2b1d7dbae..3fa310ccb 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; use radicle::cob::{ActorId, Author, Reaction, Timestamp}; use radicle::git::RefString; -use radicle::node::AliasStore; +use radicle::node::{Alias, AliasStore}; use radicle::prelude::NodeId; use radicle::storage::{git, refs, ReadRepository}; use radicle_surf::blob::Blob; @@ -146,7 +146,7 @@ pub(crate) fn patch( } /// Returns JSON for an `author` and fills in `alias` when present. -fn author(author: &Author, alias: Option) -> Value { +fn author(author: &Author, alias: Option) -> Value { match alias { Some(alias) => json!({ "id": author.id, @@ -157,7 +157,7 @@ fn author(author: &Author, alias: Option) -> Value { } /// Returns JSON for a patch `Merge` and fills in `alias` when present. -fn merge(merge: &Merge, nid: &NodeId, alias: Option) -> Value { +fn merge(merge: &Merge, nid: &NodeId, alias: Option) -> Value { match alias { Some(alias) => json!({ "author": { @@ -180,7 +180,7 @@ fn merge(merge: &Merge, nid: &NodeId, alias: Option) -> Value { } /// Returns JSON for a patch `Review` and fills in `alias` when present. -fn review(nid: &NodeId, alias: Option, review: &Review) -> Value { +fn review(nid: &NodeId, alias: Option, review: &Review) -> Value { match alias { Some(alias) => json!({ "author": { diff --git a/radicle-httpd/src/test.rs b/radicle-httpd/src/test.rs index aad3054d0..82967df09 100644 --- a/radicle-httpd/src/test.rs +++ b/radicle-httpd/src/test.rs @@ -16,9 +16,11 @@ use radicle::crypto::ssh::keystore::MemorySigner; use radicle::crypto::ssh::Keystore; use radicle::crypto::{KeyPair, Seed, Signer}; use radicle::git::{raw as git2, RefString}; +use radicle::node; use radicle::node::address as AddressStore; use radicle::node::routing as RoutingStore; use radicle::node::tracking::store as TrackingStore; +use radicle::profile; use radicle::profile::Home; use radicle::storage::ReadStorage; use radicle::Storage; @@ -63,6 +65,9 @@ pub fn profile(home: &Path, seed: [u8; 32]) -> radicle::Profile { storage, keystore, public_key: keypair.pk.into(), + config: profile::Config { + node: node::Config::new(node::Alias::new("seed")), + }, } }