Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod metadata; | ||
pub mod timeline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::{env, time::Duration}; | ||
|
||
use anyhow::Context; | ||
use nostr_sdk::{ | ||
prelude::{FromSkStr, Keys, Kind, SubscriptionFilter}, | ||
Client, | ||
}; | ||
use serde_json::Value; | ||
|
||
pub async fn handle() -> anyhow::Result<()> { | ||
let my_keys = Keys::from_sk_str(env::var("SECRET_KEY")?.as_str())?; | ||
|
||
let client = Client::new(&my_keys); | ||
client | ||
.add_relay("wss://nostr-pub.wellorder.net", None) | ||
.await?; | ||
client.connect().await; | ||
|
||
let filter = SubscriptionFilter::new() | ||
.kind(Kind::Metadata) | ||
.author(my_keys.public_key()) | ||
.limit(1); | ||
let timeout = Duration::from_secs(10); | ||
let events = client.get_events_of(vec![filter], Some(timeout)).await?; | ||
let event = events.first().context("metadata not found")?; | ||
let metadata: Value = serde_json::from_str(event.content.as_str())?; | ||
println!("{}", serde_json::to_string_pretty(&metadata)?); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters