summaryrefslogtreecommitdiff
path: root/makima/src/server/state.rs
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/server/state.rs')
-rw-r--r--makima/src/server/state.rs30
1 files changed, 29 insertions, 1 deletions
diff --git a/makima/src/server/state.rs b/makima/src/server/state.rs
index 58e8545..41c336e 100644
--- a/makima/src/server/state.rs
+++ b/makima/src/server/state.rs
@@ -142,8 +142,11 @@ pub struct SupervisorQuestionNotification {
pub question_id: Uuid,
/// Supervisor task that asked the question
pub task_id: Uuid,
- /// Contract this question relates to
+ /// Contract this question relates to (Uuid::nil() for directive context)
pub contract_id: Uuid,
+ /// Directive this question relates to (if from a directive task)
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub directive_id: Option<Uuid>,
/// Owner ID for data isolation
#[serde(skip)]
pub owner_id: Option<Uuid>,
@@ -170,6 +173,8 @@ pub struct PendingSupervisorQuestion {
pub question_id: Uuid,
pub task_id: Uuid,
pub contract_id: Uuid,
+ /// Directive this question relates to (if from a directive task)
+ pub directive_id: Option<Uuid>,
pub owner_id: Uuid,
pub question: String,
pub choices: Vec<String>,
@@ -819,6 +824,25 @@ impl AppState {
multi_select: bool,
question_type: String,
) -> Uuid {
+ self.add_supervisor_question_with_directive(
+ task_id, contract_id, None, owner_id,
+ question, choices, context, multi_select, question_type,
+ )
+ }
+
+ /// Add a pending supervisor question with optional directive context and broadcast it.
+ pub fn add_supervisor_question_with_directive(
+ &self,
+ task_id: Uuid,
+ contract_id: Uuid,
+ directive_id: Option<Uuid>,
+ owner_id: Uuid,
+ question: String,
+ choices: Vec<String>,
+ context: Option<String>,
+ multi_select: bool,
+ question_type: String,
+ ) -> Uuid {
let question_id = Uuid::new_v4();
let now = chrono::Utc::now();
@@ -829,6 +853,7 @@ impl AppState {
question_id,
task_id,
contract_id,
+ directive_id,
owner_id,
question: question.clone(),
choices: choices.clone(),
@@ -844,6 +869,7 @@ impl AppState {
question_id,
task_id,
contract_id,
+ directive_id,
owner_id: Some(owner_id),
question,
choices,
@@ -857,6 +883,7 @@ impl AppState {
question_id = %question_id,
task_id = %task_id,
contract_id = %contract_id,
+ directive_id = ?directive_id,
question_type = %question_type,
"Supervisor question added"
);
@@ -904,6 +931,7 @@ impl AppState {
question_id,
task_id: question.1.task_id,
contract_id: question.1.contract_id,
+ directive_id: question.1.directive_id,
owner_id: Some(question.1.owner_id),
question: question.1.question,
choices: question.1.choices,