Build a webhook payload with HMAC signature. Returns `(json_body, hmac_signature_hex)`.
(&self, events: &[AuditEntry])
| 113 | /// |
| 114 | /// Returns `(json_body, hmac_signature_hex)`. |
| 115 | pub fn build_webhook_payload(&self, events: &[AuditEntry]) -> (String, String) { |
| 116 | let body = serde_json::json!({ |
| 117 | "source": "nodedb", |
| 118 | "event_count": events.len(), |
| 119 | "events": events, |
| 120 | }) |
| 121 | .to_string(); |
| 122 | |
| 123 | let signature = if !self.config.webhook_hmac_secret.is_empty() { |
| 124 | compute_hmac(&self.config.webhook_hmac_secret, &body) |
| 125 | } else { |
| 126 | String::new() |
| 127 | }; |
| 128 | |
| 129 | (body, signature) |
| 130 | } |
| 131 | |
| 132 | /// Send buffered events to configured webhook (async). |
| 133 | pub async fn flush_webhook(&self) { |