upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/sync/self_subscriber.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-01-08 11:20:35 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-01-08 11:23:28 +0000
commit5d02ad6b893f9059044914c115d77cf9d8e589c3 (patch)
treeb727f9c44d2f2d4e203dc2344e4c9bd5144a77dd /src/sync/self_subscriber.rs
parent075307804bf66bba10f5bc55cb40e2e6a98a65ee (diff)
refactor: replace hardcoded Kind constants with rust-nostr variants
- Replace KIND_REPOSITORY_ANNOUNCEMENT with Kind::GitRepoAnnouncement - Replace KIND_REPOSITORY_STATE with Kind::RepoState - Replace KIND_PR with Kind::GitPullRequest - Replace KIND_PR_UPDATE with Kind::GitPullRequestUpdate - Replace KIND_USER_GRASP_LIST with Kind::GitUserGraspList - Replace KIND_PATCH with Kind::GitPatch - Replace KIND_ISSUE with Kind::GitIssue - Replace KIND_COMMENT with Kind::Comment - Replace all Kind::Custom(30617|30618|1617|1618|1619|1621|1111|10317) patterns - Remove all hardcoded KIND_* constants from events.rs - Update all match statements to use Kind enum directly - Update all filter builders to use Kind variants - Update all test helpers and assertions Benefits: - Type safety: compiler prevents wrong kind numbers - Readability: Kind::GitRepoAnnouncement is self-documenting - Maintainability: single source of truth (rust-nostr) - IDE support: full autocompletion and refactoring - Standards: aligns with rust-nostr best practices Files modified: 21 Constants removed: 9 Patterns replaced: 100+ Tests passing: 222/222
Diffstat (limited to 'src/sync/self_subscriber.rs')
-rw-r--r--src/sync/self_subscriber.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/sync/self_subscriber.rs b/src/sync/self_subscriber.rs
index 09e3b56..9f6fa70 100644
--- a/src/sync/self_subscriber.rs
+++ b/src/sync/self_subscriber.rs
@@ -149,7 +149,7 @@ impl SelfSubscriber {
149 match notification { 149 match notification {
150 Ok(RelayPoolNotification::Event { event, .. }) => { 150 Ok(RelayPoolNotification::Event { event, .. }) => {
151 // Only process 30617 events that list our relay 151 // Only process 30617 events that list our relay
152 if event.kind == Kind::Custom(30617) { 152 if event.kind == Kind::GitRepoAnnouncement {
153 if !self.lists_our_relay(&event) { 153 if !self.lists_our_relay(&event) {
154 return LoopControl::Continue; 154 return LoopControl::Continue;
155 } 155 }
@@ -236,7 +236,7 @@ impl SelfSubscriber {
236 /// Format: 30617:pubkey:identifier 236 /// Format: 30617:pubkey:identifier
237 fn extract_repo_id(event: &Event) -> Option<String> { 237 fn extract_repo_id(event: &Event) -> Option<String> {
238 // For kind 30617, extract d tag and build addressable ref 238 // For kind 30617, extract d tag and build addressable ref
239 if event.kind == Kind::Custom(30617) { 239 if event.kind == Kind::GitRepoAnnouncement {
240 for tag in event.tags.iter() { 240 for tag in event.tags.iter() {
241 let tag_vec = tag.as_slice(); 241 let tag_vec = tag.as_slice();
242 if tag_vec.len() >= 2 && tag_vec[0] == "d" { 242 if tag_vec.len() >= 2 && tag_vec[0] == "d" {
@@ -296,21 +296,21 @@ impl SelfSubscriber {
296 ); 296 );
297 Filter::new() 297 Filter::new()
298 .kinds(vec![ 298 .kinds(vec![
299 Kind::Custom(30617), // Repository Announcements 299 Kind::GitRepoAnnouncement, // Repository Announcements
300 Kind::Custom(1617), // Patches 300 Kind::GitPatch, // Patches
301 Kind::Custom(1621), // Issues 301 Kind::GitIssue, // Issues
302 Kind::Custom(1618), // Pull Requests 302 Kind::GitPullRequest, // Pull Requests
303 Kind::Custom(10317), // User Grasp List 303 Kind::GitUserGraspList, // User Grasp List
304 ]) 304 ])
305 .since(since) 305 .since(since)
306 } else { 306 } else {
307 // First connection - no since filter 307 // First connection - no since filter
308 Filter::new().kinds(vec![ 308 Filter::new().kinds(vec![
309 Kind::Custom(30617), // Repository Announcements 309 Kind::GitRepoAnnouncement, // Repository Announcements
310 Kind::Custom(1617), // Patches 310 Kind::GitPatch, // Patches
311 Kind::Custom(1621), // Issues 311 Kind::GitIssue, // Issues
312 Kind::Custom(1618), // Pull Requests 312 Kind::GitPullRequest, // Pull Requests
313 Kind::Custom(10317), // User Grasp List 313 Kind::GitUserGraspList, // User Grasp List
314 ]) 314 ])
315 }; 315 };
316 316