Returns participants for a gamenight

This commit is contained in:
2025-05-31 22:37:51 +02:00
parent 156be1821a
commit f1d23cb495
5 changed files with 17 additions and 12 deletions

View File

@@ -112,7 +112,6 @@ components:
- name
- datetime
- owner_id
- participants
Failure:
title: Failure
type: object

View File

@@ -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)?))
}