upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/sub_commands/login.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2023-10-01 00:00:00 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2023-10-01 00:00:00 +0100
commite237328ec611a5891586530c1d3cb26c16c1093b (patch)
tree22ac36baa240354d06ae82eb070609fa3e3fcb82 /src/sub_commands/login.rs
parent000901c0cbca8464b5a89bcc93c5474f6564bafd (diff)
feat(login) fetch user relays and metadata
get user relay list and metadata events from relays when keys are used and last fetch attempt was more than an hour ago uses user's write relays if known, otherwise uses fallback relays to achieve this a method for intergration testing event fetching from relays was added
Diffstat (limited to 'src/sub_commands/login.rs')
-rw-r--r--src/sub_commands/login.rs30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/sub_commands/login.rs b/src/sub_commands/login.rs
index 5391024..b93e9bc 100644
--- a/src/sub_commands/login.rs
+++ b/src/sub_commands/login.rs
@@ -1,12 +1,32 @@
1use anyhow::Result; 1use anyhow::Result;
2use clap; 2use clap;
3 3
4use crate::{login, Cli}; 4#[cfg(not(test))]
5use crate::client::Client;
6#[cfg(test)]
7use crate::client::MockConnect;
8use crate::{client::Connect, login, Cli};
5 9
6#[derive(clap::Args)] 10#[derive(clap::Args)]
7pub struct SubCommandArgs; 11pub struct SubCommandArgs {
12 /// don't fetch user metadata and relay list from relays
13 #[arg(long, action)]
14 offline: bool,
15}
16
17pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> {
18 if command_args.offline {
19 login::launch(&args.nsec, &args.password, None).await?;
20 Ok(())
21 } else {
22 #[cfg(not(test))]
23 let client = Client::default();
24 #[cfg(test)]
25 let client = <MockConnect as std::default::Default>::default();
8 26
9pub fn launch(args: &Cli, _command_args: &SubCommandArgs) -> Result<()> { 27 client.connect().await?;
10 let _ = login::launch(&args.nsec, &args.password)?; 28 login::launch(&args.nsec, &args.password, Some(&client)).await?;
11 Ok(()) 29 client.disconnect().await?;
30 Ok(())
31 }
12} 32}