finalize todo
All checks were successful
CI/CD Pipeline / test (push) Successful in 11m46s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
2024-09-10 23:25:26 +02:00
parent d404636261
commit 81dbbeac00
7 changed files with 33 additions and 20 deletions

View File

@ -9,10 +9,21 @@ async fn cal(db: &State<SqlitePool>) -> (ContentType, String) {
(ContentType::Calendar, Event::get_ics_feed(db).await)
}
#[get("/cal/registered")]
async fn cal_registered(db: &State<SqlitePool>, user: User) -> (ContentType, String) {
//TODO: add unit test once proper functionality is there
(ContentType::Calendar, get_personal_cal(db, &user).await)
#[get("/cal/personal/<user_id>/<uuid>")]
async fn cal_registered(
db: &State<SqlitePool>,
user_id: i32,
uuid: &str,
) -> Result<(ContentType, String), String> {
let Some(user) = User::find_by_id(db, user_id).await else {
return Err("Invalid".into());
};
if &user.user_token != uuid {
return Err("Invalid".into());
}
Ok((ContentType::Calendar, get_personal_cal(db, &user).await))
}
pub fn routes() -> Vec<Route> {