feat(sync): implement settings and unreads fetch

This commit is contained in:
Paul Makles
2022-02-10 16:55:59 +00:00
parent a8d5fcec9e
commit f676071641
7 changed files with 146 additions and 37 deletions

View File

@@ -1,8 +1,7 @@
use revolt_quark::{Error, Result};
use revolt_quark::{Result, models::{UserSettings, User}, Db};
use mongodb::bson::doc;
use mongodb::options::FindOneOptions;
use rocket::serde::json::{Json, Value};
use rocket::serde::json::Json;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
@@ -11,6 +10,6 @@ pub struct Options {
}
#[post("/settings/fetch", data = "<options>")]
pub async fn req(/*user: UserRef,*/ options: Json<Options>) -> Result<Value> {
todo!()
pub async fn req(db: &Db, user: User, options: Json<Options>) -> Result<Json<UserSettings>> {
db.fetch_user_settings(&user.id, &options.into_inner().keys).await.map(Json)
}