feat(task): list all participants

This commit is contained in:
xeruf 2024-11-25 14:07:08 +01:00
parent ca263b50d2
commit 591adafd6e
1 changed files with 7 additions and 4 deletions

View File

@ -71,14 +71,17 @@ impl Task {
&self.event.id &self.event.id
} }
pub(crate) fn get_owner(&self) -> PublicKey { pub(crate) fn get_participants(&self) -> impl Iterator<Item=PublicKey> + '_ {
self.tags() self.tags()
.find(|t| t.kind() == TagKind::SingleLetter(SingleLetterTag::lowercase(Alphabet::P))) .filter(|t| t.kind() == TagKind::SingleLetter(SingleLetterTag::lowercase(Alphabet::P)))
.and_then(|t| t.content() .filter_map(|t| t.content()
.and_then(|c| PublicKey::from_str(c).inspect_err(|e| warn!("Unparseable pubkey in {:?}", t)).ok())) .and_then(|c| PublicKey::from_str(c).inspect_err(|e| warn!("Unparseable pubkey in {:?}", t)).ok()))
.unwrap_or_else(|| self.event.pubkey)
} }
pub(crate) fn get_owner(&self) -> PublicKey {
self.get_participants().next()
.unwrap_or_else(|| self.event.pubkey)
}
pub(crate) fn find_refs<'a>(&'a self, marker: &'a str) -> impl Iterator<Item=&'a EventId> { pub(crate) fn find_refs<'a>(&'a self, marker: &'a str) -> impl Iterator<Item=&'a EventId> {
self.refs.iter().filter_map(move |(str, id)| Some(id).filter(|_| str == marker)) self.refs.iter().filter_map(move |(str, id)| Some(id).filter(|_| str == marker))