refactor(quark): port get/set_settings, get_unreads

#283
This commit is contained in:
Paul Makles
2024-04-07 18:10:11 +01:00
parent f6a565385e
commit 2de7598f8d
11 changed files with 69 additions and 68 deletions
+8 -17
View File
@@ -1,33 +1,24 @@
use revolt_quark::models::User;
use revolt_quark::r#impl::UserSettingsImpl;
use revolt_quark::{Db, EmptyResponse, Result};
use revolt_database::{Database, User, UserSettingsImpl};
use revolt_models::v0;
use chrono::prelude::*;
use rocket::serde::json::Json;
use serde::{Deserialize, Serialize};
use revolt_result::Result;
use rocket::{serde::json::Json, State};
use rocket_empty::EmptyResponse;
use std::collections::HashMap;
type Data = HashMap<String, String>;
/// # Set Options
#[derive(FromForm, Serialize, Deserialize, JsonSchema)]
pub struct OptionsSetSettings {
/// Timestamp of settings change.
///
/// Used to avoid feedback loops.
timestamp: Option<i64>,
}
/// # Set Settings
///
/// Upload data to save to settings.
#[openapi(tag = "Sync")]
#[post("/settings/set?<options..>", data = "<data>")]
pub async fn req(
db: &Db,
pub async fn set(
db: &State<Database>,
user: User,
data: Json<Data>,
options: OptionsSetSettings,
options: v0::OptionsSetSettings,
) -> Result<EmptyResponse> {
let data = data.into_inner();
let current_time = Utc::now().timestamp_millis();