diff options
Diffstat (limited to 'src/nostr/policy/mod.rs')
| -rw-r--r-- | src/nostr/policy/mod.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/nostr/policy/mod.rs b/src/nostr/policy/mod.rs index 1566b6c..c958586 100644 --- a/src/nostr/policy/mod.rs +++ b/src/nostr/policy/mod.rs | |||
| @@ -20,6 +20,7 @@ pub use crate::git::sync::AlignmentResult; | |||
| 20 | 20 | ||
| 21 | use super::SharedDatabase; | 21 | use super::SharedDatabase; |
| 22 | use crate::purgatory::Purgatory; | 22 | use crate::purgatory::Purgatory; |
| 23 | use crate::sync::RepoSyncIndex; | ||
| 23 | use nostr_relay_builder::LocalRelay; | 24 | use nostr_relay_builder::LocalRelay; |
| 24 | use std::sync::Arc; | 25 | use std::sync::Arc; |
| 25 | 26 | ||
| @@ -34,6 +35,8 @@ pub struct PolicyContext { | |||
| 34 | pub local_relay: Arc<std::sync::RwLock<Option<LocalRelay>>>, | 35 | pub local_relay: Arc<std::sync::RwLock<Option<LocalRelay>>>, |
| 35 | /// Configuration reference for policy settings (includes blacklists) | 36 | /// Configuration reference for policy settings (includes blacklists) |
| 36 | pub config: crate::config::Config, | 37 | pub config: crate::config::Config, |
| 38 | /// Repo sync index for registering purgatory announcements (set after SyncManager creation) | ||
| 39 | pub repo_sync_index: Arc<std::sync::RwLock<Option<RepoSyncIndex>>>, | ||
| 37 | } | 40 | } |
| 38 | 41 | ||
| 39 | impl PolicyContext { | 42 | impl PolicyContext { |
| @@ -51,6 +54,7 @@ impl PolicyContext { | |||
| 51 | purgatory, | 54 | purgatory, |
| 52 | local_relay: Arc::new(std::sync::RwLock::new(None)), | 55 | local_relay: Arc::new(std::sync::RwLock::new(None)), |
| 53 | config, | 56 | config, |
| 57 | repo_sync_index: Arc::new(std::sync::RwLock::new(None)), | ||
| 54 | } | 58 | } |
| 55 | } | 59 | } |
| 56 | 60 | ||
| @@ -68,4 +72,19 @@ impl PolicyContext { | |||
| 68 | let guard = self.local_relay.read().unwrap(); | 72 | let guard = self.local_relay.read().unwrap(); |
| 69 | guard.clone() | 73 | guard.clone() |
| 70 | } | 74 | } |
| 75 | |||
| 76 | /// Set the repo sync index after SyncManager has been created. | ||
| 77 | /// | ||
| 78 | /// This allows purgatory announcements submitted by users to be registered | ||
| 79 | /// in the sync index so state event sync starts promptly. | ||
| 80 | pub fn set_repo_sync_index(&self, index: RepoSyncIndex) { | ||
| 81 | let mut guard = self.repo_sync_index.write().unwrap(); | ||
| 82 | *guard = Some(index); | ||
| 83 | } | ||
| 84 | |||
| 85 | /// Get a clone of the repo sync index if it has been set. | ||
| 86 | pub fn get_repo_sync_index(&self) -> Option<RepoSyncIndex> { | ||
| 87 | let guard = self.repo_sync_index.read().unwrap(); | ||
| 88 | guard.clone() | ||
| 89 | } | ||
| 71 | } | 90 | } |