forked from Roflin/gamenight
Returns participants for a gamenight
This commit is contained in:
@@ -112,7 +112,6 @@ components:
|
||||
- name
|
||||
- datetime
|
||||
- owner_id
|
||||
- participants
|
||||
Failure:
|
||||
title: Failure
|
||||
type: object
|
||||
|
||||
@@ -4,6 +4,7 @@ use uuid::Uuid;
|
||||
|
||||
use gamenight_database::{gamenight::Gamenight, DbPool, GetConnection};
|
||||
|
||||
use crate::models;
|
||||
use crate::request::authorization::AuthUser;
|
||||
use crate::request::requests::GamenightGet;
|
||||
use crate::request::requests::GamenightPost;
|
||||
@@ -53,9 +54,17 @@ pub async fn gamenight_get(pool: web::Data<DbPool>, _user: AuthUser, gamenight_d
|
||||
let mut conn = pool.get_conn();
|
||||
|
||||
let gamenight = gamenight_database::gamenight::get_gamenight(&mut conn, gamenight_data.into_inner().into())?;
|
||||
//let participants = schema::user::get_participants(&mut conn, gamenight_id);
|
||||
let participants = gamenight_database::gamenight_participants::get_participants(&mut conn, &gamenight.id)?;
|
||||
|
||||
let model = models::gamenight::Gamenight{
|
||||
id: gamenight.id.to_string(),
|
||||
datetime: gamenight.datetime.to_rfc3339(),
|
||||
name: gamenight.name,
|
||||
owner_id: gamenight.owner_id.to_string(),
|
||||
participants: Some(participants.iter().map(|x| {x.to_string()}).collect())
|
||||
};
|
||||
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type(ContentType::json())
|
||||
.body(serde_json::to_string(&gamenight)?))
|
||||
.body(serde_json::to_string(&model)?))
|
||||
}
|
||||
Reference in New Issue
Block a user