Revert "don't start tutorial after registration"

This reverts commit bc0d00fd2be909a7ba50ee81b51115ed04f8e642.
This commit is contained in:
ntr 2020-01-17 16:31:25 +10:00
parent 62b8fa37a4
commit 5bac39d86c
2 changed files with 25 additions and 0 deletions

View File

@ -530,3 +530,24 @@ pub fn img_check(account: &Account) -> Result<Uuid, Error> {
}
}
pub fn tutorial(tx: &mut Transaction, account: &Account) -> Result<Option<Instance>, Error> {
let query = "
SELECT count(id)
FROM players
WHERE account = $1;
";
let result = tx
.query(query, &[&account.id])?;
let row = result.iter().next()
.ok_or(format_err!("unable to fetch joined games account={:?}", account))?;
let count: i64 = row.get(0);
if count == 0 {
return Ok(Some(instance_practice(tx, account)?));
}
return Ok(None);
}

View File

@ -128,6 +128,10 @@ impl User for Authenticated {
let wheel = account::chat_wheel(&db, a.id)?;
self.ws.send(RpcMessage::ChatWheel(wheel))?;
if let Some(instance) = account::tutorial(&mut tx, &a)? {
self.ws.send(RpcMessage::InstanceState(instance))?;
}
// tx should do nothing
tx.commit()?;