Any text a person reads may be a list, one entry per storyline, every list the same length. A visitor is given one storyline for the whole site and reads it on every page and in every mail about their case. Records and events carry the storyline; GET /report gives counts per bucket, storyline and state, and nothing else. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GT37Z1Xtfd9pUuQtMTg6Yt
34 lines
1.0 KiB
Rust
34 lines
1.0 KiB
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,
|
|
/// The storyline the person read (see `content/variants.rs`): what
|
|
/// the storylines are compared on, and nothing else about them.
|
|
#[serde(default)]
|
|
pub storyline: u32,
|
|
}
|
|
|
|
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(())
|
|
}
|