upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/nostr
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-11-26 08:45:16 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-11-26 09:56:44 +0000
commita6edb42dfc653b6826b59b7f296e0d0c4ee74557 (patch)
tree4355445d8d51672cbf1dd86af0a4bd2ffcde1a7a /src/nostr
parent30411a938d072a59d68815c975735d40366ad874 (diff)
fix: parsing maintainers from announcement event
Diffstat (limited to 'src/nostr')
-rw-r--r--src/nostr/events.rs24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/nostr/events.rs b/src/nostr/events.rs
index ddbb8f0..643269a 100644
--- a/src/nostr/events.rs
+++ b/src/nostr/events.rs
@@ -105,14 +105,19 @@ impl RepositoryAnnouncement {
105 }) 105 })
106 .collect(); 106 .collect();
107 107
108 // Extract maintainers (other-user tags) 108 // Extract maintainers from "maintainers" tag per NIP-34
109 // Format: ["maintainers", "<pubkey1-hex>", "<pubkey2-hex>", ...]
109 let maintainers = event 110 let maintainers = event
110 .tags 111 .tags
111 .iter() 112 .iter()
112 .filter(|t| t.kind() == TagKind::p()) 113 .find(|tag| tag.as_slice().first().map(|s| s.as_str()) == Some("maintainers"))
113 .filter_map(|t| t.content()) 114 .map(|tag| {
114 .map(|s| s.to_string()) 115 tag.as_slice()[1..] // Skip the "maintainers" tag name
115 .collect(); 116 .iter()
117 .map(|s| s.to_string())
118 .collect()
119 })
120 .unwrap_or_default();
116 121
117 Ok(RepositoryAnnouncement { 122 Ok(RepositoryAnnouncement {
118 event, 123 event,
@@ -546,8 +551,12 @@ mod tests {
546 ), 551 ),
547 ]; 552 ];
548 553
549 // Add maintainer 554 // Add maintainer using NIP-34 "maintainers" tag format
550 tags.push(Tag::public_key(maintainer_keys.public_key())); 555 // Format: ["maintainers", "<pubkey1-hex>", "<pubkey2-hex>", ...]
556 tags.push(Tag::custom(
557 nostr_sdk::TagKind::Custom("maintainers".into()),
558 vec![maintainer_keys.public_key().to_hex()],
559 ));
551 560
552 let event = EventBuilder::new(Kind::from(KIND_REPOSITORY_ANNOUNCEMENT), "Test repository") 561 let event = EventBuilder::new(Kind::from(KIND_REPOSITORY_ANNOUNCEMENT), "Test repository")
553 .tags(tags) 562 .tags(tags)
@@ -556,6 +565,7 @@ mod tests {
556 565
557 let announcement = RepositoryAnnouncement::from_event(event).unwrap(); 566 let announcement = RepositoryAnnouncement::from_event(event).unwrap();
558 assert_eq!(announcement.maintainers.len(), 1); 567 assert_eq!(announcement.maintainers.len(), 1);
568 assert_eq!(announcement.maintainers[0], maintainer_keys.public_key().to_hex());
559 } 569 }
560 570
561 #[test] 571 #[test]