upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/nostr/policy/state.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/nostr/policy/state.rs')
-rw-r--r--src/nostr/policy/state.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/nostr/policy/state.rs b/src/nostr/policy/state.rs
index 9ad72c2..e6de54e 100644
--- a/src/nostr/policy/state.rs
+++ b/src/nostr/policy/state.rs
@@ -146,6 +146,34 @@ impl StatePolicy {
146 "State event author authorized via maintainer set" 146 "State event author authorized via maintainer set"
147 ); 147 );
148 148
149 // Extend expiry for any purgatory announcements for this identifier.
150 //
151 // Per design doc decision #4: state event arrival extends the purgatory
152 // announcement's expiry (reset the 30-minute protocol timer). This prevents
153 // premature expiry during slow sync operations — the repo is actively receiving
154 // metadata so it should stay alive.
155 //
156 // We extend for all owners that authorized this state event, since the state
157 // event proves the repo is active regardless of which owner's announcement
158 // authorized it.
159 for owner_hex in &authorized_owners {
160 if let Ok(owner_pk) = nostr_sdk::PublicKey::from_hex(owner_hex) {
161 if self.ctx.purgatory.has_purgatory_announcement(&owner_pk, &state.identifier) {
162 self.ctx.purgatory.extend_announcement_expiry(
163 &owner_pk,
164 &state.identifier,
165 std::time::Duration::from_secs(1800),
166 );
167 tracing::debug!(
168 event_id = %event.id,
169 identifier = %state.identifier,
170 owner = %owner_hex,
171 "Extended purgatory announcement expiry due to state event arrival"
172 );
173 }
174 }
175 }
176
149 // Duplicate check in db 177 // Duplicate check in db
150 if db_repo_data.states.iter().any(|e| e.event.id.eq(&event.id)) { 178 if db_repo_data.states.iter().any(|e| e.event.id.eq(&event.id)) {
151 tracing::debug!("processed state event duplicate (in db): {}", event.id); 179 tracing::debug!("processed state event duplicate (in db): {}", event.id);