Files
stoatchat/crates/delta/src/routes/sync/get_settings.rs
2024-04-07 18:10:11 +01:00

23 lines
682 B
Rust

use revolt_database::{Database, User};
use revolt_models::v0;
use revolt_result::Result;
use rocket::serde::json::Json;
use rocket::State;
/// # Fetch Settings
///
/// Fetch settings from server filtered by keys.
///
/// This will return an object with the requested keys, each value is a tuple of `(timestamp, value)`, the value is the previously uploaded data.
#[openapi(tag = "Sync")]
#[post("/settings/fetch", data = "<options>")]
pub async fn fetch(
db: &State<Database>,
user: User,
options: Json<v0::OptionsFetchSettings>,
) -> Result<Json<v0::UserSettings>> {
db.fetch_user_settings(&user.id, &options.into_inner().keys)
.await
.map(Json)
}