upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nostr/policy/state.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/nostr/policy/state.rs b/src/nostr/policy/state.rs
index 4bfb513..9ad72c2 100644
--- a/src/nostr/policy/state.rs
+++ b/src/nostr/policy/state.rs
@@ -1,3 +1,4 @@
1use std::collections::HashSet;
1use std::path::{Path, PathBuf}; 2use std::path::{Path, PathBuf};
2 3
3use anyhow::{Context, Result}; 4use anyhow::{Context, Result};
@@ -192,6 +193,42 @@ impl StatePolicy {
192 } 193 }
193 } 194 }
194 195
196 // After copying OIDs to other owner repos, promote any purgatory announcements
197 // for those repos. This handles the case where two maintainers push to the same
198 // identifier on the same relay with identical commit hashes: the second maintainer's
199 // announcement sits in purgatory, and when their state event arrives the relay copies
200 // commits from the first maintainer's repo — but without this call the announcement
201 // would stay in purgatory indefinitely.
202 let local_relay = self.ctx.get_local_relay();
203 let empty_oids: HashSet<String> = HashSet::new();
204 for announcement in &db_repo_data.announcements {
205 let target_repo_path = self.ctx.git_data_path.join(announcement.repo_path());
206 if target_repo_path != repo_with_git_data {
207 // OIDs were copied to this repo by process_state_with_git_data;
208 // check if there's a purgatory announcement waiting for it.
209 if let Err(e) = crate::git::sync::process_newly_available_git_data(
210 &target_repo_path,
211 &empty_oids,
212 &self.ctx.database,
213 local_relay.as_ref(),
214 &self.ctx.purgatory,
215 &self.ctx.git_data_path,
216 None,
217 None,
218 )
219 .await
220 {
221 tracing::warn!(
222 identifier = %state.identifier,
223 event_id = %event.id,
224 repo_path = %target_repo_path.display(),
225 error = %e,
226 "Failed to process purgatory announcements for target repo after git sync copy"
227 );
228 }
229 }
230 }
231
195 // Event will be saved and broadcast by relay builder 232 // Event will be saved and broadcast by relay builder
196 Ok(WritePolicyResult::Accept) 233 Ok(WritePolicyResult::Accept)
197 } else { 234 } else {