Реформат путей к эндпоинтам.

Добавлен экстрактор пользователя с дополнительными полями.

Добавлена связь таблиц User и FCM.

Завершена реализация авторизации с помощью VK ID.

Добавлен эндпоинт fcm/update-callback/{version}.
This commit is contained in:
2025-04-14 22:04:41 +04:00
parent 680419ea78
commit 5b6f5c830f
27 changed files with 406 additions and 106 deletions

View File

@@ -0,0 +1,48 @@
use self::schema::*;
use crate::AppState;
use crate::routes::schedule::schema::ErrorCode;
use crate::routes::schema::{IntoResponseAsError, ResponseError};
use actix_web::{get, web};
#[utoipa::path(responses(
(status = OK, body = Response),
(status = SERVICE_UNAVAILABLE, body = ResponseError<ErrorCode>),
))]
#[get("/group-names")]
pub async fn group_names(app_state: web::Data<AppState>) -> ServiceResponse {
// Prevent thread lock
let schedule_lock = app_state.schedule.lock().unwrap();
match schedule_lock.as_ref() {
None => ErrorCode::NoSchedule.into_response(),
Some(schedule) => {
let mut names: Vec<String> = schedule.data.groups.keys().cloned().collect();
names.sort();
Ok(names.into()).into()
}
}
.into()
}
mod schema {
use crate::routes::schedule::schema::ErrorCode;
use serde::Serialize;
use utoipa::ToSchema;
pub type ServiceResponse = crate::routes::schema::Response<Response, ErrorCode>;
#[derive(Serialize, ToSchema)]
#[schema(as = GetGroupNames::Response)]
pub struct Response {
/// Список названий групп отсортированный в алфавитном порядке
#[schema(examples(json!(["ИС-214/23"])))]
pub names: Vec<String>,
}
impl From<Vec<String>> for Response {
fn from(names: Vec<String>) -> Self {
Self { names }
}
}
}