diff options
| -rw-r--r-- | src/nostr/policy/state.rs | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/src/nostr/policy/state.rs b/src/nostr/policy/state.rs index b850e7b..f94f004 100644 --- a/src/nostr/policy/state.rs +++ b/src/nostr/policy/state.rs | |||
| @@ -81,12 +81,21 @@ impl StatePolicy { | |||
| 81 | // CRITICAL: Check if author is authorized via maintainer set | 81 | // CRITICAL: Check if author is authorized via maintainer set |
| 82 | // State events MUST be rejected if author is not in maintainer set of any accepted announcement | 82 | // State events MUST be rejected if author is not in maintainer set of any accepted announcement |
| 83 | if db_repo_data.announcements.is_empty() { | 83 | if db_repo_data.announcements.is_empty() { |
| 84 | tracing::warn!( | 84 | if is_synced { |
| 85 | event_id = %event.id, | 85 | tracing::debug!( |
| 86 | identifier = %state.identifier, | 86 | event_id = %event.id, |
| 87 | author = %event.pubkey.to_hex(), | 87 | identifier = %state.identifier, |
| 88 | "Rejecting state event: no announcement exists for this repository" | 88 | author = %event.pubkey.to_hex(), |
| 89 | ); | 89 | "Rejecting state event: no announcement exists for this repository" |
| 90 | ); | ||
| 91 | } else { | ||
| 92 | tracing::warn!( | ||
| 93 | event_id = %event.id, | ||
| 94 | identifier = %state.identifier, | ||
| 95 | author = %event.pubkey.to_hex(), | ||
| 96 | "Rejecting state event: no announcement exists for this repository" | ||
| 97 | ); | ||
| 98 | } | ||
| 90 | return Ok(WritePolicyResult::Reject { | 99 | return Ok(WritePolicyResult::Reject { |
| 91 | status: false, | 100 | status: false, |
| 92 | message: "invalid: no announcement exists for this repository".into(), | 101 | message: "invalid: no announcement exists for this repository".into(), |
| @@ -99,13 +108,23 @@ impl StatePolicy { | |||
| 99 | ); | 108 | ); |
| 100 | 109 | ||
| 101 | if authorized_owners.is_empty() { | 110 | if authorized_owners.is_empty() { |
| 102 | tracing::warn!( | 111 | if is_synced { |
| 103 | event_id = %event.id, | 112 | tracing::debug!( |
| 104 | identifier = %state.identifier, | 113 | event_id = %event.id, |
| 105 | author = %event.pubkey.to_hex(), | 114 | identifier = %state.identifier, |
| 106 | announcements_count = db_repo_data.announcements.len(), | 115 | author = %event.pubkey.to_hex(), |
| 107 | "Rejecting state event: author not in maintainer set of any announcement" | 116 | announcements_count = db_repo_data.announcements.len(), |
| 108 | ); | 117 | "Rejecting state event: author not in maintainer set of any announcement" |
| 118 | ); | ||
| 119 | } else { | ||
| 120 | tracing::warn!( | ||
| 121 | event_id = %event.id, | ||
| 122 | identifier = %state.identifier, | ||
| 123 | author = %event.pubkey.to_hex(), | ||
| 124 | announcements_count = db_repo_data.announcements.len(), | ||
| 125 | "Rejecting state event: author not in maintainer set of any announcement" | ||
| 126 | ); | ||
| 127 | } | ||
| 109 | return Ok(WritePolicyResult::Reject { | 128 | return Ok(WritePolicyResult::Reject { |
| 110 | status: false, | 129 | status: false, |
| 111 | message: "invalid: author not authorized for this repository".into(), | 130 | message: "invalid: author not authorized for this repository".into(), |