@@ -342,6 +342,21 @@ impl NostrClient {
|
||||
utils::add_read_relays(self.user_relays_list(user).await.ok().flatten().as_ref())
|
||||
}
|
||||
|
||||
/// Returns the read relays of the given users if found, otherwise empty
|
||||
/// vector
|
||||
pub async fn read_relays_from_users(&self, users: &[PublicKey]) -> Vec<RelayUrl> {
|
||||
self.fetch_events(
|
||||
Filter::new()
|
||||
.kind(nostr::event::Kind::RelayList)
|
||||
.authors(utils::dedup(users.iter().copied())),
|
||||
)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.flat_map(|e| utils::add_read_relays(Some(&e)))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Parse the given content and returns the details that inside it
|
||||
pub async fn parse_content(&self, content: &str) -> ContentDetails {
|
||||
let mut write_relays = Vec::new();
|
||||
|
||||
@@ -111,18 +111,27 @@ impl EventBuilder {
|
||||
/// Creates a new [`GitIssue`] event builder with the given
|
||||
/// issue details.
|
||||
pub fn new_git_issue(
|
||||
repository: Coordinate,
|
||||
coordinates: &[Coordinate],
|
||||
content: String,
|
||||
subject: Option<String>,
|
||||
labels: Vec<String>,
|
||||
) -> N34Result<EventBuilder> {
|
||||
let mut coordinates = coordinates.iter();
|
||||
let first_coordinate = coordinates.next().ok_or(N34Error::EmptyNaddrs)?;
|
||||
|
||||
let mut event_builder = EventBuilder::git_issue(GitIssue {
|
||||
repository,
|
||||
repository: first_coordinate.clone(),
|
||||
content,
|
||||
subject: subject.clone(),
|
||||
labels: labels.into_iter().map(|l| l.trim().to_owned()).collect(),
|
||||
})
|
||||
.map_err(N34Error::from)?;
|
||||
.map_err(N34Error::from)?
|
||||
.tags(
|
||||
coordinates
|
||||
.clone()
|
||||
.map(|c| Tag::coordinate(c.clone(), None)),
|
||||
)
|
||||
.tags(coordinates.map(|c| Tag::public_key(c.public_key)));
|
||||
|
||||
if let Some(issue_subject) = subject {
|
||||
event_builder =
|
||||
@@ -196,4 +205,10 @@ impl Vec<GitRepositoryAnnouncement> {
|
||||
pub fn extract_relays(&self) -> Vec<RelayUrl> {
|
||||
self.iter().flat_map(|n| n.relays.clone()).collect()
|
||||
}
|
||||
|
||||
/// Extract all the maintainers from these repositories
|
||||
pub fn extract_maintainers(&self) -> Vec<PublicKey> {
|
||||
self.iter().flat_map(|r| r.maintainers.clone()).collect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user