Skip to main content

file_draft

Function file_draft 

Source
pub fn file_draft(
    chat: &mut Chat,
    store: &Chats,
    queue: &Queue,
    priority: i32,
) -> Result<String>
Expand description

Validate the draft with plan::review_draft and queue it.

Returns the queued task’s id. The conversation is left on disk either way: a refused draft is a conversation to continue, not an error to recover from, and the operator’s next message can ask for the missing section.

Re-reads the record under Chats::guard and Chats::claim rather than trusting the caller’s copy of chat, and writes that fresh copy back rather than the one passed in - the same reason abandon does, and for the same concurrent-writer risk: without the shared guard and claim, an abandon landing between this call’s own read and its put - whether from this same magi web or from a separate magi plan --abandon process, which the in-process guard alone cannot see - would either be clobbered by this call filing over it, or - the other order - have this call’s queued task silently orphaned from the record when abandon writes over it. Refuses a conversation that is no longer Open by the time this runs, in the same style say and record already use.