forked from jmug/stoatchat
feat: include user in responses when creating and editing bots
This commit is contained in:
@@ -14,7 +14,7 @@ pub async fn create_bot(
|
||||
db: &State<Database>,
|
||||
user: User,
|
||||
info: Json<v0::DataCreateBot>,
|
||||
) -> Result<Json<v0::Bot>> {
|
||||
) -> Result<Json<v0::BotWithUserResponse>> {
|
||||
let info = info.into_inner();
|
||||
info.validate().map_err(|error| {
|
||||
create_error!(FailedValidation {
|
||||
@@ -22,8 +22,11 @@ pub async fn create_bot(
|
||||
})
|
||||
})?;
|
||||
|
||||
let bot = Bot::create(db, info.name, &user, None).await?;
|
||||
Ok(Json(bot.into()))
|
||||
let (bot, user) = Bot::create(db, info.name, &user, None).await?;
|
||||
Ok(Json(v0::BotWithUserResponse {
|
||||
bot: bot.into(),
|
||||
user: user.into_self(false).await,
|
||||
}))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user