/**
 * Create and save a new conversation in DB
 */
Create and save a new conversation in DB
Create and save a new conversation in DB
fn create_new_conversation<'a>(
    context: &mut Context,
    bot: &'a CsmlBot,
    flow_found: Option<(&'a CsmlFlow, String)>,
    client: &Client,
    ttl: Option<chrono::Duration>,
    db: &mut Database,
) -> Result<String, EngineError> {
    let (flow, step) = match flow_found {
        Some((flow, step)) => (flow, step),
        None => (get_default_flow(bot)?, "start".to_owned()),
    };
    let conversation_id = create_conversation(&flow.id, &step, client, ttl, db)?;
    context.step = ContextStepInfo::UnknownFlow(step);
    context.flow = flow.name.to_owned();
    Ok(conversation_id)
}
fn create_new_conversation < ' a > ( context : & mut Context , bot : & ' a CsmlBot , flow_found : Option < ( & ' a CsmlFlow , String ) > , client : & Client , ttl : Option < chrono :: Duration > , db : & mut Database , ) -> Result < String , EngineError > { let ( flow , step ) = match flow_found { Some ( ( flow , step ) ) => ( flow , step ) , None => ( get_default_flow ( bot ) ? , " " . to_owned ( ) ) , } ; let conversation_id = create_conversation ( & flow . id , & step , client , ttl , db ) ? ; context . step = ContextStepInfo :: UnknownFlow ( step ) ; context . flow = flow . name . to_owned ( ) ; Ok ( conversation_id ) }
Create and save a new conversation in DB
Create and save a new conversation in DB
context
&mut Context
bot
&'a CsmlBot
flow_found
Option<(&'a CsmlFlow, String)>
client
&Client
ttl
Option<chrono::Duration>
db
&mut Database