Deploy / deploy (push) Successful in 1m1s
Drops porting-history narratives (dodrenett), superseded-behavior explanations, and restatements of what the next line does. Constraint notes (fail-closed policies, CAS semantics, cascade behavior, id uniqueness) stay, just shorter. No code changes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
30 lines
850 B
Rust
30 lines
850 B
Rust
//! Plain NATS publish of every submission/decision - fire and forget,
|
|
//! no stream bookkeeping. The n8n automations subscribe to
|
|
//! `portal.answers.submitted` and gate on `question_id`/`alternative`.
|
|
#![cfg(feature = "ssr")]
|
|
|
|
pub mod store;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct AnswerSubmitted {
|
|
pub chain_hash: String,
|
|
pub parent_hashes: Vec<String>,
|
|
pub question_id: String,
|
|
pub alternative: String,
|
|
pub responses: serde_json::Value,
|
|
pub timestamp_ms: i64,
|
|
}
|
|
|
|
pub const ANSWERS_SUBJECT: &str = "portal.answers.submitted";
|
|
|
|
pub async fn emit_answer_submitted(
|
|
nats: &async_nats::Client,
|
|
payload: &AnswerSubmitted,
|
|
) -> anyhow::Result<()> {
|
|
let data = serde_json::to_vec(payload)?;
|
|
nats.publish(ANSWERS_SUBJECT, data.into()).await?;
|
|
Ok(())
|
|
}
|