diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.rs | 6 | ||||
| -rw-r--r-- | src/key_handling/users.rs | 12 | ||||
| -rw-r--r-- | src/repo_ref.rs | 14 | ||||
| -rw-r--r-- | src/sub_commands/init.rs | 10 |
4 files changed, 21 insertions, 21 deletions
diff --git a/src/config.rs b/src/config.rs index 2370e34..7fca446 100644 --- a/src/config.rs +++ b/src/config.rs | |||
| @@ -4,7 +4,7 @@ use anyhow::{anyhow, Context, Result}; | |||
| 4 | use directories::ProjectDirs; | 4 | use directories::ProjectDirs; |
| 5 | #[cfg(test)] | 5 | #[cfg(test)] |
| 6 | use mockall::*; | 6 | use mockall::*; |
| 7 | use nostr::{secp256k1::XOnlyPublicKey, ToBech32}; | 7 | use nostr::{PublicKey, ToBech32}; |
| 8 | use serde::{self, Deserialize, Serialize}; | 8 | use serde::{self, Deserialize, Serialize}; |
| 9 | 9 | ||
| 10 | #[derive(Default)] | 10 | #[derive(Default)] |
| @@ -69,7 +69,7 @@ pub struct MyConfig { | |||
| 69 | 69 | ||
| 70 | #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] | 70 | #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] |
| 71 | pub struct UserRef { | 71 | pub struct UserRef { |
| 72 | pub public_key: XOnlyPublicKey, | 72 | pub public_key: PublicKey, |
| 73 | pub encrypted_key: String, | 73 | pub encrypted_key: String, |
| 74 | pub metadata: UserMetadata, | 74 | pub metadata: UserMetadata, |
| 75 | pub relays: UserRelays, | 75 | pub relays: UserRelays, |
| @@ -77,7 +77,7 @@ pub struct UserRef { | |||
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | impl UserRef { | 79 | impl UserRef { |
| 80 | pub fn new(public_key: XOnlyPublicKey, encrypted_key: String) -> Self { | 80 | pub fn new(public_key: PublicKey, encrypted_key: String) -> Self { |
| 81 | Self { | 81 | Self { |
| 82 | public_key, | 82 | public_key, |
| 83 | encrypted_key, | 83 | encrypted_key, |
diff --git a/src/key_handling/users.rs b/src/key_handling/users.rs index c061cd3..751c577 100644 --- a/src/key_handling/users.rs +++ b/src/key_handling/users.rs | |||
| @@ -32,13 +32,13 @@ pub trait UserManagement { | |||
| 32 | &self, | 32 | &self, |
| 33 | #[cfg(test)] client: &MockConnect, | 33 | #[cfg(test)] client: &MockConnect, |
| 34 | #[cfg(not(test))] client: &Client, | 34 | #[cfg(not(test))] client: &Client, |
| 35 | public_key: &XOnlyPublicKey, | 35 | public_key: &PublicKey, |
| 36 | after: u64, | 36 | after: u64, |
| 37 | ) -> Result<UserRef>; | 37 | ) -> Result<UserRef>; |
| 38 | fn get_user_from_cache(&self, public_key: &XOnlyPublicKey) -> Result<UserRef>; | 38 | fn get_user_from_cache(&self, public_key: &PublicKey) -> Result<UserRef>; |
| 39 | fn add_user_to_config( | 39 | fn add_user_to_config( |
| 40 | &self, | 40 | &self, |
| 41 | public_key: XOnlyPublicKey, | 41 | public_key: PublicKey, |
| 42 | encrypted_secret_key: Option<String>, | 42 | encrypted_secret_key: Option<String>, |
| 43 | overwrite: bool, | 43 | overwrite: bool, |
| 44 | ) -> Result<()>; | 44 | ) -> Result<()>; |
| @@ -99,7 +99,7 @@ impl UserManagement for UserManager { | |||
| 99 | 99 | ||
| 100 | fn add_user_to_config( | 100 | fn add_user_to_config( |
| 101 | &self, | 101 | &self, |
| 102 | public_key: XOnlyPublicKey, | 102 | public_key: PublicKey, |
| 103 | encrypted_secret_key: Option<String>, | 103 | encrypted_secret_key: Option<String>, |
| 104 | overwrite: bool, | 104 | overwrite: bool, |
| 105 | ) -> Result<()> { | 105 | ) -> Result<()> { |
| @@ -129,7 +129,7 @@ impl UserManagement for UserManager { | |||
| 129 | .context("failed to save application configuration with new user details in") | 129 | .context("failed to save application configuration with new user details in") |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | fn get_user_from_cache(&self, public_key: &XOnlyPublicKey) -> Result<UserRef> { | 132 | fn get_user_from_cache(&self, public_key: &PublicKey) -> Result<UserRef> { |
| 133 | let cfg = self | 133 | let cfg = self |
| 134 | .config_manager | 134 | .config_manager |
| 135 | .load() | 135 | .load() |
| @@ -148,7 +148,7 @@ impl UserManagement for UserManager { | |||
| 148 | &self, | 148 | &self, |
| 149 | #[cfg(test)] client: &MockConnect, | 149 | #[cfg(test)] client: &MockConnect, |
| 150 | #[cfg(not(test))] client: &Client, | 150 | #[cfg(not(test))] client: &Client, |
| 151 | public_key: &XOnlyPublicKey, | 151 | public_key: &PublicKey, |
| 152 | use_cache_unless_checked_more_than_x_secs_ago: u64, | 152 | use_cache_unless_checked_more_than_x_secs_ago: u64, |
| 153 | ) -> Result<UserRef> { | 153 | ) -> Result<UserRef> { |
| 154 | let cfg = self | 154 | let cfg = self |
diff --git a/src/repo_ref.rs b/src/repo_ref.rs index c7b42fa..0a14005 100644 --- a/src/repo_ref.rs +++ b/src/repo_ref.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use std::{fs::File, io::BufReader, str::FromStr}; | 1 | use std::{fs::File, io::BufReader, str::FromStr}; |
| 2 | 2 | ||
| 3 | use anyhow::{bail, Context, Result}; | 3 | use anyhow::{bail, Context, Result}; |
| 4 | use nostr::{nips::nip19::Nip19, secp256k1::XOnlyPublicKey, FromBech32, Tag, ToBech32}; | 4 | use nostr::{nips::nip19::Nip19, FromBech32, PublicKey, Tag, ToBech32}; |
| 5 | use serde::{Deserialize, Serialize}; | 5 | use serde::{Deserialize, Serialize}; |
| 6 | 6 | ||
| 7 | #[cfg(not(test))] | 7 | #[cfg(not(test))] |
| @@ -23,7 +23,7 @@ pub struct RepoRef { | |||
| 23 | pub git_server: String, | 23 | pub git_server: String, |
| 24 | pub web: Vec<String>, | 24 | pub web: Vec<String>, |
| 25 | pub relays: Vec<String>, | 25 | pub relays: Vec<String>, |
| 26 | pub maintainers: Vec<XOnlyPublicKey>, | 26 | pub maintainers: Vec<PublicKey>, |
| 27 | // code languages and hashtags | 27 | // code languages and hashtags |
| 28 | } | 28 | } |
| 29 | 29 | ||
| @@ -78,7 +78,7 @@ impl TryFrom<nostr::Event> for RepoRef { | |||
| 78 | } | 78 | } |
| 79 | for pk in maintainers { | 79 | for pk in maintainers { |
| 80 | r.maintainers.push( | 80 | r.maintainers.push( |
| 81 | nostr_sdk::prelude::XOnlyPublicKey::from_str(&pk) | 81 | nostr_sdk::prelude::PublicKey::from_str(&pk) |
| 82 | .context(format!("cannot convert entry from maintainers tag {pk} into a valid nostr public key. it should be in hex format")) | 82 | .context(format!("cannot convert entry from maintainers tag {pk} into a valid nostr public key. it should be in hex format")) |
| 83 | .context("invalid repository event")?, | 83 | .context("invalid repository event")?, |
| 84 | ); | 84 | ); |
| @@ -246,11 +246,11 @@ pub fn get_repo_config_from_yaml(git_repo: &Repo) -> Result<RepoConfigYaml> { | |||
| 246 | Ok(repo_config_yaml) | 246 | Ok(repo_config_yaml) |
| 247 | } | 247 | } |
| 248 | 248 | ||
| 249 | pub fn extract_pks(pk_strings: Vec<String>) -> Result<Vec<XOnlyPublicKey>> { | 249 | pub fn extract_pks(pk_strings: Vec<String>) -> Result<Vec<PublicKey>> { |
| 250 | let mut pks: Vec<XOnlyPublicKey> = vec![]; | 250 | let mut pks: Vec<PublicKey> = vec![]; |
| 251 | for s in pk_strings { | 251 | for s in pk_strings { |
| 252 | pks.push( | 252 | pks.push( |
| 253 | nostr_sdk::prelude::XOnlyPublicKey::from_bech32(s.clone()) | 253 | nostr_sdk::prelude::PublicKey::from_bech32(s.clone()) |
| 254 | .context(format!("cannot convert {s} into a valid nostr public key"))?, | 254 | .context(format!("cannot convert {s} into a valid nostr public key"))?, |
| 255 | ); | 255 | ); |
| 256 | } | 256 | } |
| @@ -259,7 +259,7 @@ pub fn extract_pks(pk_strings: Vec<String>) -> Result<Vec<XOnlyPublicKey>> { | |||
| 259 | 259 | ||
| 260 | pub fn save_repo_config_to_yaml( | 260 | pub fn save_repo_config_to_yaml( |
| 261 | git_repo: &Repo, | 261 | git_repo: &Repo, |
| 262 | maintainers: Vec<XOnlyPublicKey>, | 262 | maintainers: Vec<PublicKey>, |
| 263 | relays: Vec<String>, | 263 | relays: Vec<String>, |
| 264 | ) -> Result<()> { | 264 | ) -> Result<()> { |
| 265 | let path = git_repo.get_path()?.join("maintainers.yaml"); | 265 | let path = git_repo.get_path()?.join("maintainers.yaml"); |
diff --git a/src/sub_commands/init.rs b/src/sub_commands/init.rs index 4f098c0..56129a6 100644 --- a/src/sub_commands/init.rs +++ b/src/sub_commands/init.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use anyhow::{Context, Result}; | 1 | use anyhow::{Context, Result}; |
| 2 | use nostr::{secp256k1::XOnlyPublicKey, FromBech32, ToBech32}; | 2 | use nostr::{FromBech32, PublicKey, ToBech32}; |
| 3 | 3 | ||
| 4 | use super::send::send_events; | 4 | use super::send::send_events; |
| 5 | #[cfg(not(test))] | 5 | #[cfg(not(test))] |
| @@ -163,7 +163,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 163 | args.web.clone() | 163 | args.web.clone() |
| 164 | }; | 164 | }; |
| 165 | 165 | ||
| 166 | let maintainers: Vec<XOnlyPublicKey> = { | 166 | let maintainers: Vec<PublicKey> = { |
| 167 | let mut dont_ask = !args.other_maintainers.is_empty(); | 167 | let mut dont_ask = !args.other_maintainers.is_empty(); |
| 168 | let mut maintainers_string = if !args.other_maintainers.is_empty() { | 168 | let mut maintainers_string = if !args.other_maintainers.is_empty() { |
| 169 | [args.other_maintainers.clone()].concat().join(" ") | 169 | [args.other_maintainers.clone()].concat().join(" ") |
| @@ -185,7 +185,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 185 | }; | 185 | }; |
| 186 | // add current user if not present | 186 | // add current user if not present |
| 187 | if maintainers.iter().any(|m| { | 187 | if maintainers.iter().any(|m| { |
| 188 | if let Ok(m_pubkey) = XOnlyPublicKey::from_bech32(m) { | 188 | if let Ok(m_pubkey) = PublicKey::from_bech32(m) { |
| 189 | user_ref.public_key.eq(&m_pubkey) | 189 | user_ref.public_key.eq(&m_pubkey) |
| 190 | } else { | 190 | } else { |
| 191 | false | 191 | false |
| @@ -210,9 +210,9 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 210 | .map(std::string::ToString::to_string) | 210 | .map(std::string::ToString::to_string) |
| 211 | .collect(); | 211 | .collect(); |
| 212 | } | 212 | } |
| 213 | let mut maintainers: Vec<XOnlyPublicKey> = vec![]; | 213 | let mut maintainers: Vec<PublicKey> = vec![]; |
| 214 | for m in maintainers_string.split(' ') { | 214 | for m in maintainers_string.split(' ') { |
| 215 | if let Ok(m_pubkey) = XOnlyPublicKey::from_bech32(m) { | 215 | if let Ok(m_pubkey) = PublicKey::from_bech32(m) { |
| 216 | maintainers.push(m_pubkey); | 216 | maintainers.push(m_pubkey); |
| 217 | } else { | 217 | } else { |
| 218 | println!("not a valid set of npubs seperated by a space"); | 218 | println!("not a valid set of npubs seperated by a space"); |